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 }; | |
jeremya
2012/11/15 01:09:25
Either this should go inside CreateParams or the F
stevenjb
2012/11/16 23:42:40
Done.
| |
51 | |
47 struct CreateParams { | 52 struct CreateParams { |
48 enum Frame { | 53 enum Frame { |
49 FRAME_CHROME, // Chrome-style window frame. | 54 FRAME_CHROME, // Chrome-style window frame. |
50 FRAME_NONE, // Frameless window. | 55 FRAME_NONE, // Frameless window. |
51 }; | 56 }; |
52 | 57 |
53 CreateParams(); | 58 CreateParams(); |
54 ~CreateParams(); | 59 ~CreateParams(); |
55 | 60 |
61 WindowType window_type; | |
56 Frame frame; | 62 Frame frame; |
57 // Specify the initial bounds of the window. INT_MIN designates | 63 // Specify the initial bounds of the window. INT_MIN designates |
58 // 'unspecified' for any coordinate, and should be replaced with a default | 64 // 'unspecified' for any coordinate, and should be replaced with a default |
59 // value. | 65 // value. |
60 gfx::Rect bounds; | 66 gfx::Rect bounds; |
61 // Specify if bounds should be restored from a previous time. | 67 // Specify if bounds should be restored from a previous time. |
62 bool restore_position; | 68 bool restore_position; |
63 bool restore_size; | 69 bool restore_size; |
64 | 70 |
65 gfx::Size minimum_size; | 71 gfx::Size minimum_size; |
(...skipping 15 matching lines...) Expand all Loading... | |
81 | 87 |
82 // Convert draggable regions in raw format to SkRegion format. Caller is | 88 // Convert draggable regions in raw format to SkRegion format. Caller is |
83 // responsible for deleting the returned SkRegion instance. | 89 // responsible for deleting the returned SkRegion instance. |
84 static SkRegion* RawDraggableRegionsToSkRegion( | 90 static SkRegion* RawDraggableRegionsToSkRegion( |
85 const std::vector<extensions::DraggableRegion>& regions); | 91 const std::vector<extensions::DraggableRegion>& regions); |
86 | 92 |
87 const std::string& window_key() const { return window_key_; } | 93 const std::string& window_key() const { return window_key_; } |
88 const SessionID& session_id() const { return session_id_; } | 94 const SessionID& session_id() const { return session_id_; } |
89 const extensions::Extension* extension() const { return extension_; } | 95 const extensions::Extension* extension() const { return extension_; } |
90 content::WebContents* web_contents() const { return web_contents_.get(); } | 96 content::WebContents* web_contents() const { return web_contents_.get(); } |
97 WindowType window_type() const { return window_type_; } | |
91 Profile* profile() const { return profile_; } | 98 Profile* profile() const { return profile_; } |
92 const gfx::Image& app_icon() const { return app_icon_; } | 99 const gfx::Image& app_icon() const { return app_icon_; } |
93 | 100 |
94 BaseWindow* GetBaseWindow(); | 101 BaseWindow* GetBaseWindow(); |
95 gfx::NativeWindow GetNativeWindow() { | 102 gfx::NativeWindow GetNativeWindow() { |
96 return GetBaseWindow()->GetNativeWindow(); | 103 return GetBaseWindow()->GetNativeWindow(); |
97 } | 104 } |
98 | 105 |
99 // NativeShellWindows should call this to determine what the window's title | 106 // NativeShellWindows should call this to determine what the window's title |
100 // is on startup and from within UpdateWindowTitle(). | 107 // is on startup and from within UpdateWindowTitle(). |
101 virtual string16 GetTitle() const; | 108 virtual string16 GetTitle() const; |
102 | 109 |
103 // Call to notify ShellRegistry and delete the window. Subclasses should | 110 // Call to notify ShellRegistry and delete the window. Subclasses should |
104 // invoke this method instead of using "delete this". | 111 // invoke this method instead of using "delete this". |
105 void OnNativeClose(); | 112 void OnNativeClose(); |
106 | 113 |
107 // Should be called by native implementations when the window size/position | 114 // Should be called by native implementations when the window size/position |
108 // has changed. | 115 // has changed. |
109 void SaveWindowPosition(); | 116 void SaveWindowPosition(); |
110 | 117 |
111 protected: | 118 protected: |
112 ShellWindow(Profile* profile, | 119 ShellWindow(WindowType window_type, |
120 Profile* profile, | |
113 const extensions::Extension* extension); | 121 const extensions::Extension* extension); |
114 virtual ~ShellWindow(); | 122 virtual ~ShellWindow(); |
115 | 123 |
116 private: | 124 private: |
117 // PlatformAppBrowserTest needs access to web_contents() | 125 // PlatformAppBrowserTest needs access to web_contents() |
118 friend class extensions::PlatformAppBrowserTest; | 126 friend class extensions::PlatformAppBrowserTest; |
119 | 127 |
120 // Instantiates a platform-specific ShellWindow subclass (one implementation | 128 // Instantiates a platform-specific ShellWindow subclass (one implementation |
121 // per platform). Public users of ShellWindow should use ShellWindow::Create. | 129 // per platform). Public users of ShellWindow should use ShellWindow::Create. |
122 void Init(const GURL& url, const CreateParams& params); | 130 void Init(const GURL& url, const CreateParams& params); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 Profile* profile_; // weak pointer - owned by ProfileManager. | 206 Profile* profile_; // weak pointer - owned by ProfileManager. |
199 // weak pointer - owned by ExtensionService. | 207 // weak pointer - owned by ExtensionService. |
200 const extensions::Extension* extension_; | 208 const extensions::Extension* extension_; |
201 | 209 |
202 // Identifier that is used when saving and restoring geometry for this | 210 // Identifier that is used when saving and restoring geometry for this |
203 // window. | 211 // window. |
204 std::string window_key_; | 212 std::string window_key_; |
205 | 213 |
206 const SessionID session_id_; | 214 const SessionID session_id_; |
207 scoped_ptr<content::WebContents> web_contents_; | 215 scoped_ptr<content::WebContents> web_contents_; |
216 WindowType window_type_; | |
208 content::NotificationRegistrar registrar_; | 217 content::NotificationRegistrar registrar_; |
209 ExtensionFunctionDispatcher extension_function_dispatcher_; | 218 ExtensionFunctionDispatcher extension_function_dispatcher_; |
210 | 219 |
211 // Icon showed in the task bar. | 220 // Icon showed in the task bar. |
212 gfx::Image app_icon_; | 221 gfx::Image app_icon_; |
213 | 222 |
214 // Used for loading app_icon_. | 223 // Used for loading app_icon_. |
215 scoped_ptr<ImageLoadingTracker> app_icon_loader_; | 224 scoped_ptr<ImageLoadingTracker> app_icon_loader_; |
216 | 225 |
217 scoped_ptr<NativeShellWindow> native_window_; | 226 scoped_ptr<NativeShellWindow> native_window_; |
218 | 227 |
219 DISALLOW_COPY_AND_ASSIGN(ShellWindow); | 228 DISALLOW_COPY_AND_ASSIGN(ShellWindow); |
220 }; | 229 }; |
221 | 230 |
222 #endif // CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ | 231 #endif // CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ |
OLD | NEW |