| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_NATIVE_APP_WINDOW_VIEWS_H_ | |
| 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_NATIVE_APP_WINDOW_VIEWS_H_ | |
| 7 | |
| 8 #include "apps/shell_window.h" | |
| 9 #include "base/observer_list.h" | |
| 10 #include "chrome/browser/ui/extensions/native_app_window.h" | |
| 11 #include "content/public/browser/web_contents_observer.h" | |
| 12 #include "third_party/skia/include/core/SkRegion.h" | |
| 13 #include "ui/gfx/image/image_skia.h" | |
| 14 #include "ui/gfx/rect.h" | |
| 15 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" | |
| 16 #include "ui/views/widget/widget_delegate.h" | |
| 17 #include "ui/views/widget/widget_observer.h" | |
| 18 | |
| 19 #if defined(OS_WIN) | |
| 20 #include "chrome/browser/shell_integration.h" | |
| 21 #endif | |
| 22 | |
| 23 class ExtensionKeybindingRegistryViews; | |
| 24 class Profile; | |
| 25 | |
| 26 namespace content { | |
| 27 class RenderViewHost; | |
| 28 class WebContents; | |
| 29 } | |
| 30 | |
| 31 namespace extensions { | |
| 32 class Extension; | |
| 33 } | |
| 34 | |
| 35 namespace views { | |
| 36 class WebView; | |
| 37 } | |
| 38 | |
| 39 class NativeAppWindowViews : public NativeAppWindow, | |
| 40 public views::WidgetDelegateView, | |
| 41 public views::WidgetObserver, | |
| 42 public content::WebContentsObserver { | |
| 43 public: | |
| 44 NativeAppWindowViews(apps::ShellWindow* shell_window, | |
| 45 const apps::ShellWindow::CreateParams& params); | |
| 46 virtual ~NativeAppWindowViews(); | |
| 47 | |
| 48 bool frameless() const { return frameless_; } | |
| 49 SkRegion* draggable_region() { return draggable_region_.get(); } | |
| 50 | |
| 51 private: | |
| 52 void InitializeDefaultWindow( | |
| 53 const apps::ShellWindow::CreateParams& create_params); | |
| 54 void InitializePanelWindow( | |
| 55 const apps::ShellWindow::CreateParams& create_params); | |
| 56 void OnViewWasResized(); | |
| 57 | |
| 58 bool ShouldUseChromeStyleFrame() const; | |
| 59 | |
| 60 #if defined(OS_WIN) | |
| 61 void OnShortcutInfoLoaded( | |
| 62 const ShellIntegration::ShortcutInfo& shortcut_info); | |
| 63 HWND GetNativeAppWindowHWND() const; | |
| 64 #endif | |
| 65 | |
| 66 // ui::BaseWindow implementation. | |
| 67 virtual bool IsActive() const OVERRIDE; | |
| 68 virtual bool IsMaximized() const OVERRIDE; | |
| 69 virtual bool IsMinimized() const OVERRIDE; | |
| 70 virtual bool IsFullscreen() const OVERRIDE; | |
| 71 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; | |
| 72 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; | |
| 73 virtual ui::WindowShowState GetRestoredState() const OVERRIDE; | |
| 74 virtual gfx::Rect GetBounds() const OVERRIDE; | |
| 75 virtual void Show() OVERRIDE; | |
| 76 virtual void ShowInactive() OVERRIDE; | |
| 77 virtual void Hide() OVERRIDE; | |
| 78 virtual void Close() OVERRIDE; | |
| 79 virtual void Activate() OVERRIDE; | |
| 80 virtual void Deactivate() OVERRIDE; | |
| 81 virtual void Maximize() OVERRIDE; | |
| 82 virtual void Minimize() OVERRIDE; | |
| 83 virtual void Restore() OVERRIDE; | |
| 84 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | |
| 85 virtual void FlashFrame(bool flash) OVERRIDE; | |
| 86 virtual bool IsAlwaysOnTop() const OVERRIDE; | |
| 87 | |
| 88 // WidgetDelegate implementation. | |
| 89 virtual void OnWidgetMove() OVERRIDE; | |
| 90 virtual views::View* GetInitiallyFocusedView() OVERRIDE; | |
| 91 virtual bool CanResize() const OVERRIDE; | |
| 92 virtual bool CanMaximize() const OVERRIDE; | |
| 93 virtual string16 GetWindowTitle() const OVERRIDE; | |
| 94 virtual bool ShouldShowWindowTitle() const OVERRIDE; | |
| 95 virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE; | |
| 96 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE; | |
| 97 virtual bool ShouldShowWindowIcon() const OVERRIDE; | |
| 98 virtual void SaveWindowPlacement(const gfx::Rect& bounds, | |
| 99 ui::WindowShowState show_state) OVERRIDE; | |
| 100 virtual void DeleteDelegate() OVERRIDE; | |
| 101 virtual views::Widget* GetWidget() OVERRIDE; | |
| 102 virtual const views::Widget* GetWidget() const OVERRIDE; | |
| 103 virtual views::View* GetContentsView() OVERRIDE; | |
| 104 virtual views::NonClientFrameView* CreateNonClientFrameView( | |
| 105 views::Widget* widget) OVERRIDE; | |
| 106 virtual bool ShouldDescendIntoChildForEventHandling( | |
| 107 gfx::NativeView child, | |
| 108 const gfx::Point& location) OVERRIDE; | |
| 109 | |
| 110 // WidgetObserver implementation. | |
| 111 virtual void OnWidgetVisibilityChanged(views::Widget* widget, | |
| 112 bool visible) OVERRIDE; | |
| 113 virtual void OnWidgetActivationChanged(views::Widget* widget, | |
| 114 bool active) OVERRIDE; | |
| 115 | |
| 116 // WebContentsObserver implementation. | |
| 117 virtual void RenderViewCreated( | |
| 118 content::RenderViewHost* render_view_host) OVERRIDE; | |
| 119 | |
| 120 // views::View implementation. | |
| 121 virtual void Layout() OVERRIDE; | |
| 122 virtual void ViewHierarchyChanged( | |
| 123 const ViewHierarchyChangedDetails& details) OVERRIDE; | |
| 124 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
| 125 virtual gfx::Size GetMinimumSize() OVERRIDE; | |
| 126 virtual gfx::Size GetMaximumSize() OVERRIDE; | |
| 127 virtual void OnFocus() OVERRIDE; | |
| 128 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | |
| 129 | |
| 130 // NativeAppWindow implementation. | |
| 131 virtual void SetFullscreen(bool fullscreen) OVERRIDE; | |
| 132 virtual bool IsFullscreenOrPending() const OVERRIDE; | |
| 133 virtual bool IsDetached() const OVERRIDE; | |
| 134 virtual void UpdateWindowIcon() OVERRIDE; | |
| 135 virtual void UpdateWindowTitle() OVERRIDE; | |
| 136 virtual void UpdateDraggableRegions( | |
| 137 const std::vector<extensions::DraggableRegion>& regions) OVERRIDE; | |
| 138 virtual void HandleKeyboardEvent( | |
| 139 const content::NativeWebKeyboardEvent& event) OVERRIDE; | |
| 140 virtual void RenderViewHostChanged() OVERRIDE; | |
| 141 virtual gfx::Insets GetFrameInsets() const OVERRIDE; | |
| 142 | |
| 143 // web_modal::WebContentsModalDialogHost implementation. | |
| 144 virtual gfx::NativeView GetHostView() const OVERRIDE; | |
| 145 virtual gfx::Point GetDialogPosition(const gfx::Size& size) OVERRIDE; | |
| 146 virtual void AddObserver( | |
| 147 web_modal::WebContentsModalDialogHostObserver* observer) OVERRIDE; | |
| 148 virtual void RemoveObserver( | |
| 149 web_modal::WebContentsModalDialogHostObserver* observer) OVERRIDE; | |
| 150 | |
| 151 Profile* profile() { return shell_window_->profile(); } | |
| 152 content::WebContents* web_contents() { | |
| 153 return shell_window_->web_contents(); | |
| 154 } | |
| 155 const extensions::Extension* extension() { | |
| 156 return shell_window_->extension(); | |
| 157 } | |
| 158 | |
| 159 apps::ShellWindow* shell_window_; // weak - ShellWindow owns NativeAppWindow. | |
| 160 views::WebView* web_view_; | |
| 161 views::Widget* window_; | |
| 162 bool is_fullscreen_; | |
| 163 | |
| 164 scoped_ptr<SkRegion> draggable_region_; | |
| 165 | |
| 166 const bool frameless_; | |
| 167 const bool transparent_background_; | |
| 168 gfx::Size minimum_size_; | |
| 169 gfx::Size maximum_size_; | |
| 170 gfx::Size preferred_size_; | |
| 171 bool resizable_; | |
| 172 | |
| 173 // The class that registers for keyboard shortcuts for extension commands. | |
| 174 scoped_ptr<ExtensionKeybindingRegistryViews> extension_keybinding_registry_; | |
| 175 | |
| 176 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; | |
| 177 | |
| 178 base::WeakPtrFactory<NativeAppWindowViews> weak_ptr_factory_; | |
| 179 | |
| 180 ObserverList<web_modal::WebContentsModalDialogHostObserver> observer_list_; | |
| 181 | |
| 182 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowViews); | |
| 183 }; | |
| 184 | |
| 185 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_NATIVE_APP_WINDOW_VIEWS_H_ | |
| OLD | NEW |