| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ | 5 #ifndef CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ |
| 6 #define CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ | 6 #define CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 9 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 10 #include "chrome/browser/extensions/extension_keybinding_registry.h" | 10 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 // ShellWindow is the type of window used by platform apps. Shell windows | 38 // ShellWindow is the type of window used by platform apps. Shell windows |
| 39 // have a WebContents but none of the chrome of normal browser windows. | 39 // have a WebContents but none of the chrome of normal browser windows. |
| 40 class ShellWindow : public content::NotificationObserver, | 40 class ShellWindow : public content::NotificationObserver, |
| 41 public content::WebContentsDelegate, | 41 public content::WebContentsDelegate, |
| 42 public content::WebContentsObserver, | 42 public content::WebContentsObserver, |
| 43 public ExtensionFunctionDispatcher::Delegate, | 43 public ExtensionFunctionDispatcher::Delegate, |
| 44 public ImageLoadingTracker::Observer, | 44 public ImageLoadingTracker::Observer, |
| 45 public extensions::ExtensionKeybindingRegistry::Delegate { | 45 public extensions::ExtensionKeybindingRegistry::Delegate { |
| 46 public: | 46 public: |
| 47 enum WindowType { |
| 48 WINDOW_TYPE_DEFAULT, // Default shell window |
| 49 WINDOW_TYPE_PANEL, // OS controlled panel window (Ash only) |
| 50 }; |
| 51 |
| 52 enum Frame { |
| 53 FRAME_CHROME, // Chrome-style window frame. |
| 54 FRAME_NONE, // Frameless window. |
| 55 }; |
| 56 |
| 47 struct CreateParams { | 57 struct CreateParams { |
| 48 enum Frame { | |
| 49 FRAME_CHROME, // Chrome-style window frame. | |
| 50 FRAME_NONE, // Frameless window. | |
| 51 }; | |
| 52 | |
| 53 CreateParams(); | 58 CreateParams(); |
| 54 ~CreateParams(); | 59 ~CreateParams(); |
| 55 | 60 |
| 61 WindowType window_type; |
| 56 Frame frame; | 62 Frame frame; |
| 63 |
| 57 // Specify the initial bounds of the window. INT_MIN designates | 64 // Specify the initial bounds of the window. INT_MIN designates |
| 58 // 'unspecified' for any coordinate, and should be replaced with a default | 65 // 'unspecified' for any coordinate, and should be replaced with a default |
| 59 // value. | 66 // value. |
| 60 gfx::Rect bounds; | 67 gfx::Rect bounds; |
| 61 | 68 |
| 62 gfx::Size minimum_size; | 69 gfx::Size minimum_size; |
| 63 gfx::Size maximum_size; | 70 gfx::Size maximum_size; |
| 64 | 71 |
| 65 std::string window_key; | 72 std::string window_key; |
| 66 | 73 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 78 | 85 |
| 79 // Convert draggable regions in raw format to SkRegion format. Caller is | 86 // Convert draggable regions in raw format to SkRegion format. Caller is |
| 80 // responsible for deleting the returned SkRegion instance. | 87 // responsible for deleting the returned SkRegion instance. |
| 81 static SkRegion* RawDraggableRegionsToSkRegion( | 88 static SkRegion* RawDraggableRegionsToSkRegion( |
| 82 const std::vector<extensions::DraggableRegion>& regions); | 89 const std::vector<extensions::DraggableRegion>& regions); |
| 83 | 90 |
| 84 const std::string& window_key() const { return window_key_; } | 91 const std::string& window_key() const { return window_key_; } |
| 85 const SessionID& session_id() const { return session_id_; } | 92 const SessionID& session_id() const { return session_id_; } |
| 86 const extensions::Extension* extension() const { return extension_; } | 93 const extensions::Extension* extension() const { return extension_; } |
| 87 content::WebContents* web_contents() const { return web_contents_.get(); } | 94 content::WebContents* web_contents() const { return web_contents_.get(); } |
| 95 WindowType window_type() const { return window_type_; } |
| 88 Profile* profile() const { return profile_; } | 96 Profile* profile() const { return profile_; } |
| 89 const gfx::Image& app_icon() const { return app_icon_; } | 97 const gfx::Image& app_icon() const { return app_icon_; } |
| 90 | 98 |
| 91 BaseWindow* GetBaseWindow(); | 99 BaseWindow* GetBaseWindow(); |
| 92 gfx::NativeWindow GetNativeWindow() { | 100 gfx::NativeWindow GetNativeWindow() { |
| 93 return GetBaseWindow()->GetNativeWindow(); | 101 return GetBaseWindow()->GetNativeWindow(); |
| 94 } | 102 } |
| 95 | 103 |
| 96 // NativeShellWindows should call this to determine what the window's title | 104 // NativeShellWindows should call this to determine what the window's title |
| 97 // is on startup and from within UpdateWindowTitle(). | 105 // is on startup and from within UpdateWindowTitle(). |
| 98 virtual string16 GetTitle() const; | 106 virtual string16 GetTitle() const; |
| 99 | 107 |
| 100 // Call to notify ShellRegistry and delete the window. Subclasses should | 108 // Call to notify ShellRegistry and delete the window. Subclasses should |
| 101 // invoke this method instead of using "delete this". | 109 // invoke this method instead of using "delete this". |
| 102 void OnNativeClose(); | 110 void OnNativeClose(); |
| 103 | 111 |
| 104 // Should be called by native implementations when the window size/position | 112 // Should be called by native implementations when the window size/position |
| 105 // has changed. | 113 // has changed. |
| 106 void SaveWindowPosition(); | 114 void SaveWindowPosition(); |
| 107 | 115 |
| 108 protected: | 116 protected: |
| 109 ShellWindow(Profile* profile, | 117 ShellWindow(WindowType window_type, |
| 118 Profile* profile, |
| 110 const extensions::Extension* extension); | 119 const extensions::Extension* extension); |
| 111 virtual ~ShellWindow(); | 120 virtual ~ShellWindow(); |
| 112 | 121 |
| 113 private: | 122 private: |
| 114 // PlatformAppBrowserTest needs access to web_contents() | 123 // PlatformAppBrowserTest needs access to web_contents() |
| 115 friend class extensions::PlatformAppBrowserTest; | 124 friend class extensions::PlatformAppBrowserTest; |
| 116 | 125 |
| 117 // Instantiates a platform-specific ShellWindow subclass (one implementation | 126 // Instantiates a platform-specific ShellWindow subclass (one implementation |
| 118 // per platform). Public users of ShellWindow should use ShellWindow::Create. | 127 // per platform). Public users of ShellWindow should use ShellWindow::Create. |
| 119 void Init(const GURL& url, const CreateParams& params); | 128 void Init(const GURL& url, const CreateParams& params); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 Profile* profile_; // weak pointer - owned by ProfileManager. | 204 Profile* profile_; // weak pointer - owned by ProfileManager. |
| 196 // weak pointer - owned by ExtensionService. | 205 // weak pointer - owned by ExtensionService. |
| 197 const extensions::Extension* extension_; | 206 const extensions::Extension* extension_; |
| 198 | 207 |
| 199 // Identifier that is used when saving and restoring geometry for this | 208 // Identifier that is used when saving and restoring geometry for this |
| 200 // window. | 209 // window. |
| 201 std::string window_key_; | 210 std::string window_key_; |
| 202 | 211 |
| 203 const SessionID session_id_; | 212 const SessionID session_id_; |
| 204 scoped_ptr<content::WebContents> web_contents_; | 213 scoped_ptr<content::WebContents> web_contents_; |
| 214 WindowType window_type_; |
| 205 content::NotificationRegistrar registrar_; | 215 content::NotificationRegistrar registrar_; |
| 206 ExtensionFunctionDispatcher extension_function_dispatcher_; | 216 ExtensionFunctionDispatcher extension_function_dispatcher_; |
| 207 | 217 |
| 208 // Icon showed in the task bar. | 218 // Icon showed in the task bar. |
| 209 gfx::Image app_icon_; | 219 gfx::Image app_icon_; |
| 210 | 220 |
| 211 // Used for loading app_icon_. | 221 // Used for loading app_icon_. |
| 212 scoped_ptr<ImageLoadingTracker> app_icon_loader_; | 222 scoped_ptr<ImageLoadingTracker> app_icon_loader_; |
| 213 | 223 |
| 214 scoped_ptr<NativeShellWindow> native_window_; | 224 scoped_ptr<NativeShellWindow> native_window_; |
| 215 | 225 |
| 216 DISALLOW_COPY_AND_ASSIGN(ShellWindow); | 226 DISALLOW_COPY_AND_ASSIGN(ShellWindow); |
| 217 }; | 227 }; |
| 218 | 228 |
| 219 #endif // CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ | 229 #endif // CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ |
| OLD | NEW |