mac: Provide ViewsDelegate
This commit is contained in:
parent
fcc82ebd35
commit
37a7df49d6
7 changed files with 93 additions and 1 deletions
|
@ -16,7 +16,6 @@
|
|||
#include "atom/common/api/atom_bindings.h"
|
||||
#include "atom/common/asar/asar_util.h"
|
||||
#include "atom/common/node_bindings.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
|
@ -36,6 +35,13 @@
|
|||
#include "atom/browser/atom_web_ui_controller_factory.h"
|
||||
#endif // defined(ENABLE_PDF_VIEWER)
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
#include "atom/browser/ui/cocoa/views_delegate_mac.h"
|
||||
#endif
|
||||
|
||||
// Must be included after all other headers.
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
@ -171,6 +177,13 @@ int AtomBrowserMainParts::PreCreateThreads() {
|
|||
return result;
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::ToolkitInitialized() {
|
||||
brightray::BrowserMainParts::ToolkitInitialized();
|
||||
#if defined(OS_MACOSX)
|
||||
views_delegate_.reset(new ViewsDelegateMac);
|
||||
#endif
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
||||
js_env_->OnMessageLoopCreated();
|
||||
|
||||
|
|
|
@ -25,6 +25,10 @@ class NodeDebugger;
|
|||
class NodeEnvironment;
|
||||
class BridgeTaskRunner;
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
class ViewsDelegateMac;
|
||||
#endif
|
||||
|
||||
class AtomBrowserMainParts : public brightray::BrowserMainParts {
|
||||
public:
|
||||
AtomBrowserMainParts();
|
||||
|
@ -50,6 +54,7 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
|
|||
void PreEarlyInitialization() override;
|
||||
void PostEarlyInitialization() override;
|
||||
int PreCreateThreads() override;
|
||||
void ToolkitInitialized() override;
|
||||
void PreMainMessageLoopRun() override;
|
||||
bool MainMessageLoopRun(int* result_code) override;
|
||||
void PostMainMessageLoopStart() override;
|
||||
|
@ -69,6 +74,10 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
|
|||
void FreeAppDelegate();
|
||||
#endif
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
std::unique_ptr<ViewsDelegateMac> views_delegate_;
|
||||
#endif
|
||||
|
||||
// A fake BrowserProcess object that used to feed the source code from chrome.
|
||||
std::unique_ptr<BrowserProcess> fake_browser_process_;
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "ui/views/widget/widget_delegate.h"
|
||||
#include "ui/views/widget/widget_observer.h"
|
||||
|
||||
@class AtomNSWindow;
|
||||
@class AtomNSWindowDelegate;
|
||||
|
@ -147,6 +149,8 @@ class NativeWindowMac : public NativeWindow {
|
|||
base::scoped_nsobject<AtomNSWindow> window_;
|
||||
base::scoped_nsobject<AtomNSWindowDelegate> window_delegate_;
|
||||
|
||||
std::unique_ptr<views::Widget> widget_;
|
||||
|
||||
// Event monitor for scroll wheel event.
|
||||
id wheel_event_monitor_;
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "skia/ext/skia_utils_mac.h"
|
||||
#include "ui/gfx/skia_util.h"
|
||||
#include "ui/gl/gpu_switching_manager.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
30
atom/browser/ui/cocoa/views_delegate_mac.h
Normal file
30
atom/browser/ui/cocoa/views_delegate_mac.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Copyright (c) 2018 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_UI_COCOA_VIEWS_DELEGATE_MAC_H_
|
||||
#define ATOM_BROWSER_UI_COCOA_VIEWS_DELEGATE_MAC_H_
|
||||
|
||||
#include "ui/views/views_delegate.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class ViewsDelegateMac : public views::ViewsDelegate {
|
||||
public:
|
||||
ViewsDelegateMac();
|
||||
~ViewsDelegateMac() override;
|
||||
|
||||
// ViewsDelegate:
|
||||
void OnBeforeWidgetInit(
|
||||
views::Widget::InitParams* params,
|
||||
views::internal::NativeWidgetDelegate* delegate) override;
|
||||
ui::ContextFactory* GetContextFactory() override;
|
||||
ui::ContextFactoryPrivate* GetContextFactoryPrivate() override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ViewsDelegateMac);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_UI_COCOA_VIEWS_DELEGATE_MAC_H_
|
33
atom/browser/ui/cocoa/views_delegate_mac.mm
Normal file
33
atom/browser/ui/cocoa/views_delegate_mac.mm
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) 2018 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/ui/cocoa/views_delegate_mac.h"
|
||||
|
||||
#include "content/public/browser/context_factory.h"
|
||||
#include "ui/views/widget/native_widget_mac.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
ViewsDelegateMac::ViewsDelegateMac() {
|
||||
}
|
||||
|
||||
ViewsDelegateMac::~ViewsDelegateMac() {
|
||||
}
|
||||
|
||||
void ViewsDelegateMac::OnBeforeWidgetInit(
|
||||
views::Widget::InitParams* params,
|
||||
views::internal::NativeWidgetDelegate* delegate) {
|
||||
if (!params->native_widget)
|
||||
params->native_widget = new views::NativeWidgetMac(delegate);
|
||||
}
|
||||
|
||||
ui::ContextFactory* ViewsDelegateMac::GetContextFactory() {
|
||||
return content::GetContextFactory();
|
||||
}
|
||||
|
||||
ui::ContextFactoryPrivate* ViewsDelegateMac::GetContextFactoryPrivate() {
|
||||
return content::GetContextFactoryPrivate();
|
||||
}
|
||||
|
||||
} // namespace atom
|
|
@ -318,6 +318,8 @@
|
|||
'atom/browser/ui/cocoa/atom_menu_controller.mm',
|
||||
'atom/browser/ui/cocoa/atom_touch_bar.h',
|
||||
'atom/browser/ui/cocoa/atom_touch_bar.mm',
|
||||
'atom/browser/ui/cocoa/views_delegate_mac.h',
|
||||
'atom/browser/ui/cocoa/views_delegate_mac.mm',
|
||||
'atom/browser/ui/cocoa/touch_bar_forward_declarations.h',
|
||||
'atom/browser/ui/drag_util_mac.mm',
|
||||
'atom/browser/ui/drag_util_views.cc',
|
||||
|
|
Loading…
Reference in a new issue