| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_NATIVE_APP_WINDOW_NATIVE_APP_WINDOW_VIEWS_H_ | 5 #ifndef COMPONENTS_NATIVE_APP_WINDOW_NATIVE_APP_WINDOW_VIEWS_H_ |
| 6 #define COMPONENTS_NATIVE_APP_WINDOW_NATIVE_APP_WINDOW_VIEWS_H_ | 6 #define COMPONENTS_NATIVE_APP_WINDOW_NATIVE_APP_WINDOW_VIEWS_H_ |
| 7 | 7 |
| 8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
| 9 #include "components/native_app_window/native_app_window.h" |
| 10 #include "components/native_app_window/native_app_window_delegate.h" |
| 11 #include "components/native_app_window/native_app_window_export.h" |
| 12 #include "components/native_app_window/size_constraints.h" |
| 9 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
| 10 #include "extensions/browser/app_window/app_window.h" | |
| 11 #include "extensions/browser/app_window/native_app_window.h" | |
| 12 #include "extensions/browser/app_window/size_constraints.h" | |
| 13 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 14 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" | 15 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" |
| 15 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
| 16 #include "ui/views/widget/widget_delegate.h" | 17 #include "ui/views/widget/widget_delegate.h" |
| 17 #include "ui/views/widget/widget_observer.h" | 18 #include "ui/views/widget/widget_observer.h" |
| 18 | 19 |
| 19 class SkRegion; | 20 class SkRegion; |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| 22 class BrowserContext; | 23 class BrowserContext; |
| 23 class RenderViewHost; | 24 class RenderViewHost; |
| 24 class WebContents; | 25 class WebContents; |
| 25 } | 26 } |
| 26 | 27 |
| 27 namespace extensions { | |
| 28 class Extension; | |
| 29 } | |
| 30 | |
| 31 namespace ui { | 28 namespace ui { |
| 32 class MenuModel; | 29 class MenuModel; |
| 33 } | 30 } |
| 34 | 31 |
| 35 namespace views { | 32 namespace views { |
| 36 class MenuRunner; | 33 class MenuRunner; |
| 37 class WebView; | 34 class WebView; |
| 38 } | 35 } |
| 39 | 36 |
| 40 namespace native_app_window { | 37 namespace native_app_window { |
| 41 | 38 |
| 39 class AppWindowCreateParams; |
| 40 |
| 42 // A NativeAppWindow backed by a views::Widget. This class may be used alone | 41 // A NativeAppWindow backed by a views::Widget. This class may be used alone |
| 43 // as a stub or subclassed (for example, ChromeNativeAppWindowViews). | 42 // as a stub or subclassed (for example, ChromeNativeAppWindowViews). |
| 44 class NativeAppWindowViews : public extensions::NativeAppWindow, | 43 class NATIVE_APP_WINDOW_VIEWS_EXPORT NativeAppWindowViews |
| 45 public content::WebContentsObserver, | 44 : public NativeAppWindow, |
| 46 public views::WidgetDelegateView, | 45 public content::WebContentsObserver, |
| 47 public views::WidgetObserver { | 46 public views::WidgetDelegateView, |
| 47 public views::WidgetObserver { |
| 48 public: | 48 public: |
| 49 NativeAppWindowViews(); | 49 NativeAppWindowViews(); |
| 50 virtual ~NativeAppWindowViews(); | 50 virtual ~NativeAppWindowViews(); |
| 51 void Init(extensions::AppWindow* app_window, | 51 void Init(NativeAppWindowDelegate* app_window, |
| 52 const extensions::AppWindow::CreateParams& create_params); | 52 const AppWindowCreateParams& create_params); |
| 53 | 53 |
| 54 // Signal that CanHaveTransparentBackground has changed. | 54 // Signal that CanHaveTransparentBackground has changed. |
| 55 void OnCanHaveAlphaEnabledChanged(); | 55 void OnCanHaveAlphaEnabledChanged(); |
| 56 | 56 |
| 57 views::Widget* widget() { return widget_; } | 57 views::Widget* widget() { return widget_; } |
| 58 | 58 |
| 59 void set_window_for_testing(views::Widget* window) { widget_ = window; } | 59 void set_window_for_testing(views::Widget* window) { widget_ = window; } |
| 60 void set_web_view_for_testing(views::WebView* view) { web_view_ = view; } | 60 void set_web_view_for_testing(views::WebView* view) { web_view_ = view; } |
| 61 | 61 |
| 62 protected: | 62 protected: |
| 63 extensions::AppWindow* app_window() { return app_window_; } | 63 NativeAppWindowDelegate* app_window() { return app_window_; } |
| 64 const extensions::AppWindow* app_window() const { return app_window_; } | 64 const NativeAppWindowDelegate* app_window() const { return app_window_; } |
| 65 | 65 |
| 66 const views::Widget* widget() const { return widget_; } | 66 const views::Widget* widget() const { return widget_; } |
| 67 | 67 |
| 68 views::WebView* web_view() { return web_view_; } | 68 views::WebView* web_view() { return web_view_; } |
| 69 | 69 |
| 70 // Initializes |widget_| for |app_window|. | 70 // Initializes |widget_| for |app_window|. |
| 71 virtual void InitializeWindow( | 71 virtual void InitializeWindow(NativeAppWindowDelegate* app_window, |
| 72 extensions::AppWindow* app_window, | 72 const AppWindowCreateParams& create_params); |
| 73 const extensions::AppWindow::CreateParams& create_params); | |
| 74 | 73 |
| 75 // ui::BaseWindow implementation. | 74 // ui::BaseWindow implementation. |
| 76 virtual bool IsActive() const OVERRIDE; | 75 virtual bool IsActive() const OVERRIDE; |
| 77 virtual bool IsMaximized() const OVERRIDE; | 76 virtual bool IsMaximized() const OVERRIDE; |
| 78 virtual bool IsMinimized() const OVERRIDE; | 77 virtual bool IsMinimized() const OVERRIDE; |
| 79 virtual bool IsFullscreen() const OVERRIDE; | 78 virtual bool IsFullscreen() const OVERRIDE; |
| 80 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; | 79 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; |
| 81 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; | 80 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; |
| 82 virtual ui::WindowShowState GetRestoredState() const OVERRIDE; | 81 virtual ui::WindowShowState GetRestoredState() const OVERRIDE; |
| 83 virtual gfx::Rect GetBounds() const OVERRIDE; | 82 virtual gfx::Rect GetBounds() const OVERRIDE; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 virtual gfx::Size GetMaximumSize() const OVERRIDE; | 134 virtual gfx::Size GetMaximumSize() const OVERRIDE; |
| 136 virtual void OnFocus() OVERRIDE; | 135 virtual void OnFocus() OVERRIDE; |
| 137 | 136 |
| 138 // NativeAppWindow implementation. | 137 // NativeAppWindow implementation. |
| 139 virtual void SetFullscreen(int fullscreen_types) OVERRIDE; | 138 virtual void SetFullscreen(int fullscreen_types) OVERRIDE; |
| 140 virtual bool IsFullscreenOrPending() const OVERRIDE; | 139 virtual bool IsFullscreenOrPending() const OVERRIDE; |
| 141 virtual void UpdateWindowIcon() OVERRIDE; | 140 virtual void UpdateWindowIcon() OVERRIDE; |
| 142 virtual void UpdateWindowTitle() OVERRIDE; | 141 virtual void UpdateWindowTitle() OVERRIDE; |
| 143 virtual void UpdateBadgeIcon() OVERRIDE; | 142 virtual void UpdateBadgeIcon() OVERRIDE; |
| 144 virtual void UpdateDraggableRegions( | 143 virtual void UpdateDraggableRegions( |
| 145 const std::vector<extensions::DraggableRegion>& regions) OVERRIDE; | 144 const std::vector<DraggableRegion>& regions) OVERRIDE; |
| 146 virtual SkRegion* GetDraggableRegion() OVERRIDE; | 145 virtual SkRegion* GetDraggableRegion() OVERRIDE; |
| 147 virtual void UpdateShape(scoped_ptr<SkRegion> region) OVERRIDE; | 146 virtual void UpdateShape(scoped_ptr<SkRegion> region) OVERRIDE; |
| 148 virtual void HandleKeyboardEvent( | 147 virtual void HandleKeyboardEvent( |
| 149 const content::NativeWebKeyboardEvent& event) OVERRIDE; | 148 const content::NativeWebKeyboardEvent& event) OVERRIDE; |
| 150 virtual bool IsFrameless() const OVERRIDE; | 149 virtual bool IsFrameless() const OVERRIDE; |
| 151 virtual bool HasFrameColor() const OVERRIDE; | 150 virtual bool HasFrameColor() const OVERRIDE; |
| 152 virtual SkColor ActiveFrameColor() const OVERRIDE; | 151 virtual SkColor ActiveFrameColor() const OVERRIDE; |
| 153 virtual SkColor InactiveFrameColor() const OVERRIDE; | 152 virtual SkColor InactiveFrameColor() const OVERRIDE; |
| 154 virtual gfx::Insets GetFrameInsets() const OVERRIDE; | 153 virtual gfx::Insets GetFrameInsets() const OVERRIDE; |
| 155 virtual void HideWithApp() OVERRIDE; | 154 virtual void HideWithApp() OVERRIDE; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 168 virtual gfx::Size GetMaximumDialogSize() OVERRIDE; | 167 virtual gfx::Size GetMaximumDialogSize() OVERRIDE; |
| 169 virtual void AddObserver( | 168 virtual void AddObserver( |
| 170 web_modal::ModalDialogHostObserver* observer) OVERRIDE; | 169 web_modal::ModalDialogHostObserver* observer) OVERRIDE; |
| 171 virtual void RemoveObserver( | 170 virtual void RemoveObserver( |
| 172 web_modal::ModalDialogHostObserver* observer) OVERRIDE; | 171 web_modal::ModalDialogHostObserver* observer) OVERRIDE; |
| 173 | 172 |
| 174 private: | 173 private: |
| 175 // Informs modal dialogs that they need to update their positions. | 174 // Informs modal dialogs that they need to update their positions. |
| 176 void OnViewWasResized(); | 175 void OnViewWasResized(); |
| 177 | 176 |
| 178 extensions::AppWindow* app_window_; // Not owned. | 177 NativeAppWindowDelegate* app_window_; // Not owned. |
| 179 views::WebView* web_view_; | 178 views::WebView* web_view_; |
| 180 views::Widget* widget_; | 179 views::Widget* widget_; |
| 181 | 180 |
| 182 scoped_ptr<SkRegion> draggable_region_; | 181 scoped_ptr<SkRegion> draggable_region_; |
| 183 | 182 |
| 184 bool frameless_; | 183 bool frameless_; |
| 185 bool resizable_; | 184 bool resizable_; |
| 186 extensions::SizeConstraints size_constraints_; | 185 SizeConstraints size_constraints_; |
| 187 | 186 |
| 188 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; | 187 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; |
| 189 | 188 |
| 190 ObserverList<web_modal::ModalDialogHostObserver> observer_list_; | 189 ObserverList<web_modal::ModalDialogHostObserver> observer_list_; |
| 191 | 190 |
| 192 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowViews); | 191 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowViews); |
| 193 }; | 192 }; |
| 194 | 193 |
| 195 } // namespace native_app_window | 194 } // namespace native_app_window |
| 196 | 195 |
| 197 #endif // COMPONENTS_NATIVE_APP_WINDOW_NATIVE_APP_WINDOW_VIEWS_H_ | 196 #endif // COMPONENTS_NATIVE_APP_WINDOW_NATIVE_APP_WINDOW_VIEWS_H_ |
| OLD | NEW |