| 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 APPS_UI_VIEWS_BASE_NATIVE_APP_WINDOW_VIEWS_H_ | 5 #ifndef APPS_UI_VIEWS_NATIVE_APP_WINDOW_VIEWS_H_ |
| 6 #define APPS_UI_VIEWS_BASE_NATIVE_APP_WINDOW_VIEWS_H_ | 6 #define APPS_UI_VIEWS_NATIVE_APP_WINDOW_VIEWS_H_ |
| 7 | 7 |
| 8 #include "apps/ui/native_app_window.h" | 8 #include "apps/ui/native_app_window.h" |
| 9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
| 10 #include "content/public/browser/web_contents_observer.h" | 10 #include "content/public/browser/web_contents_observer.h" |
| 11 #include "ui/gfx/rect.h" | 11 #include "ui/gfx/rect.h" |
| 12 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" | 12 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" |
| 13 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
| 14 #include "ui/views/widget/widget_delegate.h" | 14 #include "ui/views/widget/widget_delegate.h" |
| 15 #include "ui/views/widget/widget_observer.h" | 15 #include "ui/views/widget/widget_observer.h" |
| 16 | 16 |
| 17 class SkRegion; | 17 class SkRegion; |
| 18 | 18 |
| 19 namespace apps { | |
| 20 class AppWindowFrameView; | |
| 21 } | |
| 22 | |
| 23 namespace content { | 19 namespace content { |
| 24 class BrowserContext; | 20 class BrowserContext; |
| 25 class RenderViewHost; | 21 class RenderViewHost; |
| 26 class WebContents; | 22 class WebContents; |
| 27 } | 23 } |
| 28 | 24 |
| 29 namespace extensions { | 25 namespace extensions { |
| 30 class Extension; | 26 class Extension; |
| 31 } | 27 } |
| 32 | 28 |
| 33 namespace ui { | 29 namespace ui { |
| 34 class MenuModel; | 30 class MenuModel; |
| 35 } | 31 } |
| 36 | 32 |
| 37 namespace views { | 33 namespace views { |
| 38 class MenuRunner; | 34 class MenuRunner; |
| 39 class WebView; | 35 class WebView; |
| 40 } | 36 } |
| 41 | 37 |
| 38 namespace apps { |
| 39 |
| 40 class AppWindowFrameView; |
| 41 |
| 42 // A NativeAppWindow backed by a views::Widget. This class may be used alone | 42 // A NativeAppWindow backed by a views::Widget. This class may be used alone |
| 43 // as a stub or subclassed (for example, NativeAppWindowViews in Chrome). | 43 // as a stub or subclassed (for example, ChromeNativeAppWindowViews). |
| 44 class BaseNativeAppWindowViews : public apps::NativeAppWindow, | 44 class NativeAppWindowViews : public NativeAppWindow, |
| 45 public content::WebContentsObserver, | 45 public content::WebContentsObserver, |
| 46 public views::WidgetDelegateView, | 46 public views::WidgetDelegateView, |
| 47 public views::WidgetObserver { | 47 public views::WidgetObserver { |
| 48 public: | 48 public: |
| 49 BaseNativeAppWindowViews(); | 49 NativeAppWindowViews(); |
| 50 virtual ~BaseNativeAppWindowViews(); | 50 virtual ~NativeAppWindowViews(); |
| 51 void Init(apps::AppWindow* app_window, | 51 void Init(AppWindow* app_window, |
| 52 const apps::AppWindow::CreateParams& create_params); | 52 const AppWindow::CreateParams& create_params); |
| 53 | 53 |
| 54 void set_window_for_testing(views::Widget* window) { window_ = window; } | 54 void set_window_for_testing(views::Widget* window) { window_ = window; } |
| 55 void set_web_view_for_testing(views::WebView* view) { web_view_ = view; } | 55 void set_web_view_for_testing(views::WebView* view) { web_view_ = view; } |
| 56 | 56 |
| 57 protected: | 57 protected: |
| 58 apps::AppWindow* app_window() { return app_window_; } | 58 AppWindow* app_window() { return app_window_; } |
| 59 const apps::AppWindow* app_window() const { return app_window_; } | 59 const AppWindow* app_window() const { return app_window_; } |
| 60 | 60 |
| 61 views::Widget* window() { return window_; } | 61 views::Widget* window() { return window_; } |
| 62 const views::Widget* window() const { return window_; } | 62 const views::Widget* window() const { return window_; } |
| 63 | 63 |
| 64 views::WebView* web_view() { return web_view_; } | 64 views::WebView* web_view() { return web_view_; } |
| 65 | 65 |
| 66 // Initializes |window_| for |app_window|. | 66 // Initializes |window_| for |app_window|. |
| 67 virtual void InitializeWindow( | 67 virtual void InitializeWindow(AppWindow* app_window, |
| 68 apps::AppWindow* app_window, | 68 const AppWindow::CreateParams& create_params); |
| 69 const apps::AppWindow::CreateParams& create_params); | |
| 70 | 69 |
| 71 // ui::BaseWindow implementation. | 70 // ui::BaseWindow implementation. |
| 72 virtual bool IsActive() const OVERRIDE; | 71 virtual bool IsActive() const OVERRIDE; |
| 73 virtual bool IsMaximized() const OVERRIDE; | 72 virtual bool IsMaximized() const OVERRIDE; |
| 74 virtual bool IsMinimized() const OVERRIDE; | 73 virtual bool IsMinimized() const OVERRIDE; |
| 75 virtual bool IsFullscreen() const OVERRIDE; | 74 virtual bool IsFullscreen() const OVERRIDE; |
| 76 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; | 75 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; |
| 77 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; | 76 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; |
| 78 virtual ui::WindowShowState GetRestoredState() const OVERRIDE; | 77 virtual ui::WindowShowState GetRestoredState() const OVERRIDE; |
| 79 virtual gfx::Rect GetBounds() const OVERRIDE; | 78 virtual gfx::Rect GetBounds() const OVERRIDE; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 virtual gfx::Size GetMaximumDialogSize() OVERRIDE; | 157 virtual gfx::Size GetMaximumDialogSize() OVERRIDE; |
| 159 virtual void AddObserver( | 158 virtual void AddObserver( |
| 160 web_modal::ModalDialogHostObserver* observer) OVERRIDE; | 159 web_modal::ModalDialogHostObserver* observer) OVERRIDE; |
| 161 virtual void RemoveObserver( | 160 virtual void RemoveObserver( |
| 162 web_modal::ModalDialogHostObserver* observer) OVERRIDE; | 161 web_modal::ModalDialogHostObserver* observer) OVERRIDE; |
| 163 | 162 |
| 164 private: | 163 private: |
| 165 // Informs modal dialogs that they need to update their positions. | 164 // Informs modal dialogs that they need to update their positions. |
| 166 void OnViewWasResized(); | 165 void OnViewWasResized(); |
| 167 | 166 |
| 168 apps::AppWindow* app_window_; // Not owned. | 167 AppWindow* app_window_; // Not owned. |
| 169 views::WebView* web_view_; | 168 views::WebView* web_view_; |
| 170 views::Widget* window_; | 169 views::Widget* window_; |
| 171 | 170 |
| 172 scoped_ptr<SkRegion> draggable_region_; | 171 scoped_ptr<SkRegion> draggable_region_; |
| 173 | 172 |
| 174 bool frameless_; | 173 bool frameless_; |
| 175 bool transparent_background_; | 174 bool transparent_background_; |
| 176 bool resizable_; | 175 bool resizable_; |
| 177 | 176 |
| 178 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; | 177 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; |
| 179 | 178 |
| 180 ObserverList<web_modal::ModalDialogHostObserver> observer_list_; | 179 ObserverList<web_modal::ModalDialogHostObserver> observer_list_; |
| 181 | 180 |
| 182 DISALLOW_COPY_AND_ASSIGN(BaseNativeAppWindowViews); | 181 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowViews); |
| 183 }; | 182 }; |
| 184 | 183 |
| 185 #endif // APPS_UI_VIEWS_BASE_NATIVE_APP_WINDOW_VIEWS_H_ | 184 } // namespace apps |
| 185 |
| 186 #endif // APPS_UI_VIEWS_NATIVE_APP_WINDOW_VIEWS_H_ |
| OLD | NEW |