Add ViewsDelegate, required when using views::Widget on aura.
This commit is contained in:
parent
2682f3db87
commit
bad7b95ed7
5 changed files with 185 additions and 0 deletions
|
@ -75,6 +75,8 @@
|
||||||
'browser/linux/notification_presenter_linux.cc',
|
'browser/linux/notification_presenter_linux.cc',
|
||||||
'browser/url_request_context_getter.cc',
|
'browser/url_request_context_getter.cc',
|
||||||
'browser/url_request_context_getter.h',
|
'browser/url_request_context_getter.h',
|
||||||
|
'browser/views/views_delegate.cc',
|
||||||
|
'browser/views/views_delegate.h',
|
||||||
'browser/win/devtools_window.cc',
|
'browser/win/devtools_window.cc',
|
||||||
'browser/win/devtools_window.h',
|
'browser/win/devtools_window.h',
|
||||||
'browser/win/inspectable_web_contents_view_win.cc',
|
'browser/win/inspectable_web_contents_view_win.cc',
|
||||||
|
|
|
@ -15,6 +15,11 @@
|
||||||
#include "ui/views/linux_ui/linux_ui.h"
|
#include "ui/views/linux_ui/linux_ui.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(TOOLKIT_VIEWS)
|
||||||
|
#include "browser/views/views_delegate.h"
|
||||||
|
#include "ui/wm/core/wm_state.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
BrowserMainParts::BrowserMainParts() {
|
BrowserMainParts::BrowserMainParts() {
|
||||||
|
@ -37,6 +42,13 @@ void BrowserMainParts::ToolkitInitialized() {
|
||||||
#if defined(USE_AURA) && defined(USE_X11)
|
#if defined(USE_AURA) && defined(USE_X11)
|
||||||
views::LinuxUI::instance()->Initialize();
|
views::LinuxUI::instance()->Initialize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(TOOLKIT_VIEWS)
|
||||||
|
if (!views::ViewsDelegate::views_delegate)
|
||||||
|
views::ViewsDelegate::views_delegate = new ViewsDelegate;
|
||||||
|
|
||||||
|
wm_state_.reset(new wm::WMState);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserMainParts::PreMainMessageLoopStart() {
|
void BrowserMainParts::PreMainMessageLoopStart() {
|
||||||
|
|
|
@ -9,6 +9,12 @@
|
||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
#include "content/public/browser/browser_main_parts.h"
|
#include "content/public/browser/browser_main_parts.h"
|
||||||
|
|
||||||
|
#if defined(TOOLKIT_VIEWS)
|
||||||
|
namespace wm {
|
||||||
|
class WMState;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
class BrowserContext;
|
class BrowserContext;
|
||||||
|
@ -42,6 +48,10 @@ class BrowserMainParts : public content::BrowserMainParts {
|
||||||
scoped_ptr<BrowserContext> browser_context_;
|
scoped_ptr<BrowserContext> browser_context_;
|
||||||
scoped_ptr<WebUIControllerFactory> web_ui_controller_factory_;
|
scoped_ptr<WebUIControllerFactory> web_ui_controller_factory_;
|
||||||
|
|
||||||
|
#if defined(TOOLKIT_VIEWS)
|
||||||
|
scoped_ptr<wm::WMState> wm_state_;
|
||||||
|
#endif
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(BrowserMainParts);
|
DISALLOW_COPY_AND_ASSIGN(BrowserMainParts);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
97
brightray/browser/views/views_delegate.cc
Normal file
97
brightray/browser/views/views_delegate.cc
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
// Copyright (c) 2014 The Chromium Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE-CHROMIUM file.
|
||||||
|
|
||||||
|
#include "browser/views/views_delegate.h"
|
||||||
|
|
||||||
|
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
|
||||||
|
|
||||||
|
namespace brightray {
|
||||||
|
|
||||||
|
ViewsDelegate::ViewsDelegate() {
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewsDelegate::~ViewsDelegate() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewsDelegate::SaveWindowPlacement(const views::Widget* window,
|
||||||
|
const std::string& window_name,
|
||||||
|
const gfx::Rect& bounds,
|
||||||
|
ui::WindowShowState show_state) {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ViewsDelegate::GetSavedWindowPlacement(
|
||||||
|
const views::Widget* widget,
|
||||||
|
const std::string& window_name,
|
||||||
|
gfx::Rect* bounds,
|
||||||
|
ui::WindowShowState* show_state) const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewsDelegate::NotifyAccessibilityEvent(
|
||||||
|
views::View* view, ui::AXEvent event_type) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewsDelegate::NotifyMenuItemFocused(
|
||||||
|
const base::string16& menu_name,
|
||||||
|
const base::string16& menu_item_name,
|
||||||
|
int item_index,
|
||||||
|
int item_count,
|
||||||
|
bool has_submenu) {
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
HICON ViewsDelegate::GetDefaultWindowIcon() const {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ViewsDelegate::IsWindowInMetro(gfx::NativeWindow window) const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
|
||||||
|
gfx::ImageSkia* ViewsDelegate::GetDefaultWindowIcon() const {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
views::NonClientFrameView* ViewsDelegate::CreateDefaultNonClientFrameView(
|
||||||
|
views::Widget* widget) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewsDelegate::AddRef() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewsDelegate::ReleaseRef() {
|
||||||
|
}
|
||||||
|
|
||||||
|
content::WebContents* ViewsDelegate::CreateWebContents(
|
||||||
|
content::BrowserContext* browser_context,
|
||||||
|
content::SiteInstance* site_instance) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewsDelegate::OnBeforeWidgetInit(
|
||||||
|
views::Widget::InitParams* params,
|
||||||
|
views::internal::NativeWidgetDelegate* delegate) {
|
||||||
|
// If we already have a native_widget, we don't have to try to come
|
||||||
|
// up with one.
|
||||||
|
if (params->native_widget)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// The native_widget is required when using aura.
|
||||||
|
if (params->parent == NULL && params->context == NULL && !params->child)
|
||||||
|
params->native_widget = new views::DesktopNativeWidgetAura(delegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
base::TimeDelta ViewsDelegate::GetDefaultTextfieldObscuredRevealDuration() {
|
||||||
|
return base::TimeDelta();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ViewsDelegate::WindowManagerProvidesTitleBar(bool maximized) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace brightray
|
64
brightray/browser/views/views_delegate.h
Normal file
64
brightray/browser/views/views_delegate.h
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
// Copyright (c) 2014 The Chromium Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE-CHROMIUM file.
|
||||||
|
|
||||||
|
#ifndef BRIGHTRAY_BROWSER_VIEWS_VIEWS_DELEGATE_H_
|
||||||
|
#define BRIGHTRAY_BROWSER_VIEWS_VIEWS_DELEGATE_H_
|
||||||
|
|
||||||
|
#include "base/compiler_specific.h"
|
||||||
|
#include "ui/views/views_delegate.h"
|
||||||
|
|
||||||
|
namespace brightray {
|
||||||
|
|
||||||
|
class ViewsDelegate : public views::ViewsDelegate {
|
||||||
|
public:
|
||||||
|
ViewsDelegate();
|
||||||
|
virtual ~ViewsDelegate();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// views::ViewsDelegate:
|
||||||
|
virtual void SaveWindowPlacement(const views::Widget* window,
|
||||||
|
const std::string& window_name,
|
||||||
|
const gfx::Rect& bounds,
|
||||||
|
ui::WindowShowState show_state) OVERRIDE;
|
||||||
|
virtual bool GetSavedWindowPlacement(
|
||||||
|
const views::Widget* widget,
|
||||||
|
const std::string& window_name,
|
||||||
|
gfx::Rect* bounds,
|
||||||
|
ui::WindowShowState* show_state) const OVERRIDE;
|
||||||
|
virtual void NotifyAccessibilityEvent(
|
||||||
|
views::View* view, ui::AXEvent event_type) OVERRIDE;
|
||||||
|
virtual void NotifyMenuItemFocused(const base::string16& menu_name,
|
||||||
|
const base::string16& menu_item_name,
|
||||||
|
int item_index,
|
||||||
|
int item_count,
|
||||||
|
bool has_submenu) OVERRIDE;
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
virtual HICON GetDefaultWindowIcon() const OVERRIDE;
|
||||||
|
virtual bool IsWindowInMetro(gfx::NativeWindow window) const OVERRIDE;
|
||||||
|
#elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
|
||||||
|
virtual gfx::ImageSkia* GetDefaultWindowIcon() const OVERRIDE;
|
||||||
|
#endif
|
||||||
|
virtual views::NonClientFrameView* CreateDefaultNonClientFrameView(
|
||||||
|
views::Widget* widget) OVERRIDE;
|
||||||
|
virtual void AddRef() OVERRIDE;
|
||||||
|
virtual void ReleaseRef() OVERRIDE;
|
||||||
|
virtual content::WebContents* CreateWebContents(
|
||||||
|
content::BrowserContext* browser_context,
|
||||||
|
content::SiteInstance* site_instance) OVERRIDE;
|
||||||
|
virtual void OnBeforeWidgetInit(
|
||||||
|
views::Widget::InitParams* params,
|
||||||
|
views::internal::NativeWidgetDelegate* delegate) OVERRIDE;
|
||||||
|
virtual base::TimeDelta GetDefaultTextfieldObscuredRevealDuration() OVERRIDE;
|
||||||
|
virtual bool WindowManagerProvidesTitleBar(bool maximized) OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(ViewsDelegate);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace brightray
|
||||||
|
|
||||||
|
#endif // BRIGHTRAY_BROWSER_VIEWS_VIEWS_DELEGATE_H_
|
Loading…
Reference in a new issue