OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SHELL_WINDOW_H_ | 5 #ifndef APPS_SHELL_WINDOW_H_ |
6 #define APPS_SHELL_WINDOW_H_ | 6 #define APPS_SHELL_WINDOW_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "chrome/browser/extensions/extension_icon_image.h" | 10 #include "chrome/browser/extensions/extension_icon_image.h" |
11 #include "chrome/browser/extensions/extension_keybinding_registry.h" | 11 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
12 #include "chrome/browser/sessions/session_id.h" | 12 #include "chrome/browser/sessions/session_id.h" |
13 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" | 13 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
16 #include "content/public/browser/web_contents_delegate.h" | 16 #include "content/public/browser/web_contents_delegate.h" |
17 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
18 #include "content/public/common/console_message_level.h" | 18 #include "content/public/common/console_message_level.h" |
19 #include "ui/base/ui_base_types.h" // WindowShowState | 19 #include "ui/base/ui_base_types.h" // WindowShowState |
20 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
21 #include "ui/gfx/rect.h" | 21 #include "ui/gfx/rect.h" |
22 | 22 |
23 class GURL; | 23 class GURL; |
24 class Profile; | |
25 class SkRegion; | 24 class SkRegion; |
26 | 25 |
27 namespace base { | 26 namespace base { |
28 class DictionaryValue; | 27 class DictionaryValue; |
29 } | 28 } |
30 | 29 |
31 namespace content { | 30 namespace content { |
| 31 class BrowserContext; |
32 class WebContents; | 32 class WebContents; |
33 } | 33 } |
34 | 34 |
35 namespace extensions { | 35 namespace extensions { |
36 class Extension; | 36 class Extension; |
37 class PlatformAppBrowserTest; | 37 class PlatformAppBrowserTest; |
38 class WindowController; | 38 class WindowController; |
39 | 39 |
40 struct DraggableRegion; | 40 struct DraggableRegion; |
41 } | 41 } |
42 | 42 |
43 namespace ui { | 43 namespace ui { |
44 class BaseWindow; | 44 class BaseWindow; |
45 } | 45 } |
46 | 46 |
47 namespace apps { | 47 namespace apps { |
48 | 48 |
49 class NativeAppWindow; | 49 class NativeAppWindow; |
50 | 50 |
51 // Manages the web contents for Shell Windows. The implementation for this | 51 // Manages the web contents for Shell Windows. The implementation for this |
52 // class should create and maintain the WebContents for the window, and handle | 52 // class should create and maintain the WebContents for the window, and handle |
53 // any message passing between the web contents and the extension system or | 53 // any message passing between the web contents and the extension system or |
54 // native window. | 54 // native window. |
55 class ShellWindowContents { | 55 class ShellWindowContents { |
56 public: | 56 public: |
57 ShellWindowContents() {} | 57 ShellWindowContents() {} |
58 virtual ~ShellWindowContents() {} | 58 virtual ~ShellWindowContents() {} |
59 | 59 |
60 // Called to initialize the WebContents, before the app window is created. | 60 // Called to initialize the WebContents, before the app window is created. |
61 virtual void Initialize(Profile* profile, const GURL& url) = 0; | 61 virtual void Initialize(content::BrowserContext* context, |
| 62 const GURL& url) = 0; |
62 | 63 |
63 // Called to load the contents, after the app window is created. | 64 // Called to load the contents, after the app window is created. |
64 virtual void LoadContents(int32 creator_process_id) = 0; | 65 virtual void LoadContents(int32 creator_process_id) = 0; |
65 | 66 |
66 // Called when the native window changes. | 67 // Called when the native window changes. |
67 virtual void NativeWindowChanged(NativeAppWindow* native_app_window) = 0; | 68 virtual void NativeWindowChanged(NativeAppWindow* native_app_window) = 0; |
68 | 69 |
69 // Called when the native window closes. | 70 // Called when the native window closes. |
70 virtual void NativeWindowClosed() = 0; | 71 virtual void NativeWindowClosed() = 0; |
71 | 72 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 virtual ~Delegate(); | 195 virtual ~Delegate(); |
195 | 196 |
196 // General initialization. | 197 // General initialization. |
197 virtual void InitWebContents(content::WebContents* web_contents) = 0; | 198 virtual void InitWebContents(content::WebContents* web_contents) = 0; |
198 virtual NativeAppWindow* CreateNativeAppWindow( | 199 virtual NativeAppWindow* CreateNativeAppWindow( |
199 ShellWindow* window, | 200 ShellWindow* window, |
200 const CreateParams& params) = 0; | 201 const CreateParams& params) = 0; |
201 | 202 |
202 // Link handling. | 203 // Link handling. |
203 virtual content::WebContents* OpenURLFromTab( | 204 virtual content::WebContents* OpenURLFromTab( |
204 Profile* profile, | 205 content::BrowserContext* context, |
205 content::WebContents* source, | 206 content::WebContents* source, |
206 const content::OpenURLParams& params) = 0; | 207 const content::OpenURLParams& params) = 0; |
207 virtual void AddNewContents(Profile* profile, | 208 virtual void AddNewContents(content::BrowserContext* context, |
208 content::WebContents* new_contents, | 209 content::WebContents* new_contents, |
209 WindowOpenDisposition disposition, | 210 WindowOpenDisposition disposition, |
210 const gfx::Rect& initial_pos, | 211 const gfx::Rect& initial_pos, |
211 bool user_gesture, | 212 bool user_gesture, |
212 bool* was_blocked) = 0; | 213 bool* was_blocked) = 0; |
213 | 214 |
214 // Feature support. | 215 // Feature support. |
215 virtual content::ColorChooser* ShowColorChooser( | 216 virtual content::ColorChooser* ShowColorChooser( |
216 content::WebContents* web_contents, | 217 content::WebContents* web_contents, |
217 SkColor initial_color) = 0; | 218 SkColor initial_color) = 0; |
(...skipping 14 matching lines...) Expand all Loading... |
232 | 233 |
233 // Convert draggable regions in raw format to SkRegion format. Caller is | 234 // Convert draggable regions in raw format to SkRegion format. Caller is |
234 // responsible for deleting the returned SkRegion instance. | 235 // responsible for deleting the returned SkRegion instance. |
235 static SkRegion* RawDraggableRegionsToSkRegion( | 236 static SkRegion* RawDraggableRegionsToSkRegion( |
236 const std::vector<extensions::DraggableRegion>& regions); | 237 const std::vector<extensions::DraggableRegion>& regions); |
237 | 238 |
238 // The constructor and Init methods are public for constructing a ShellWindow | 239 // The constructor and Init methods are public for constructing a ShellWindow |
239 // with a non-standard render interface (e.g. v1 apps using Ash Panels). | 240 // with a non-standard render interface (e.g. v1 apps using Ash Panels). |
240 // Normally ShellWindow::Create should be used. | 241 // Normally ShellWindow::Create should be used. |
241 // The constructed shell window takes ownership of |delegate|. | 242 // The constructed shell window takes ownership of |delegate|. |
242 ShellWindow(Profile* profile, | 243 ShellWindow(content::BrowserContext* context, |
243 Delegate* delegate, | 244 Delegate* delegate, |
244 const extensions::Extension* extension); | 245 const extensions::Extension* extension); |
245 | 246 |
246 // Initializes the render interface, web contents, and native window. | 247 // Initializes the render interface, web contents, and native window. |
247 // |shell_window_contents| will become owned by ShellWindow. | 248 // |shell_window_contents| will become owned by ShellWindow. |
248 void Init(const GURL& url, | 249 void Init(const GURL& url, |
249 ShellWindowContents* shell_window_contents, | 250 ShellWindowContents* shell_window_contents, |
250 const CreateParams& params); | 251 const CreateParams& params); |
251 | 252 |
252 | 253 |
253 const std::string& window_key() const { return window_key_; } | 254 const std::string& window_key() const { return window_key_; } |
254 const SessionID& session_id() const { return session_id_; } | 255 const SessionID& session_id() const { return session_id_; } |
255 const extensions::Extension* extension() const { return extension_; } | 256 const extensions::Extension* extension() const { return extension_; } |
256 const std::string& extension_id() const { return extension_id_; } | 257 const std::string& extension_id() const { return extension_id_; } |
257 content::WebContents* web_contents() const; | 258 content::WebContents* web_contents() const; |
258 WindowType window_type() const { return window_type_; } | 259 WindowType window_type() const { return window_type_; } |
259 bool window_type_is_panel() const { | 260 bool window_type_is_panel() const { |
260 return (window_type_ == WINDOW_TYPE_PANEL || | 261 return (window_type_ == WINDOW_TYPE_PANEL || |
261 window_type_ == WINDOW_TYPE_V1_PANEL); | 262 window_type_ == WINDOW_TYPE_V1_PANEL); |
262 } | 263 } |
263 Profile* profile() const { return profile_; } | 264 content::BrowserContext* browser_context() const { return browser_context_; } |
264 const gfx::Image& app_icon() const { return app_icon_; } | 265 const gfx::Image& app_icon() const { return app_icon_; } |
265 const GURL& app_icon_url() const { return app_icon_url_; } | 266 const GURL& app_icon_url() const { return app_icon_url_; } |
266 const gfx::Image& badge_icon() const { return badge_icon_; } | 267 const gfx::Image& badge_icon() const { return badge_icon_; } |
267 const GURL& badge_icon_url() const { return badge_icon_url_; } | 268 const GURL& badge_icon_url() const { return badge_icon_url_; } |
268 | 269 |
269 NativeAppWindow* GetBaseWindow(); | 270 NativeAppWindow* GetBaseWindow(); |
270 gfx::NativeWindow GetNativeWindow(); | 271 gfx::NativeWindow GetNativeWindow(); |
271 | 272 |
272 // Returns the bounds that should be reported to the renderer. | 273 // Returns the bounds that should be reported to the renderer. |
273 gfx::Rect GetClientBounds() const; | 274 gfx::Rect GetClientBounds() const; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 void DidDownloadFavicon(int id, | 482 void DidDownloadFavicon(int id, |
482 int http_status_code, | 483 int http_status_code, |
483 const GURL& image_url, | 484 const GURL& image_url, |
484 const std::vector<SkBitmap>& bitmaps, | 485 const std::vector<SkBitmap>& bitmaps, |
485 const std::vector<gfx::Size>& original_bitmap_sizes); | 486 const std::vector<gfx::Size>& original_bitmap_sizes); |
486 | 487 |
487 // extensions::IconImage::Observer implementation. | 488 // extensions::IconImage::Observer implementation. |
488 virtual void OnExtensionIconImageChanged( | 489 virtual void OnExtensionIconImageChanged( |
489 extensions::IconImage* image) OVERRIDE; | 490 extensions::IconImage* image) OVERRIDE; |
490 | 491 |
491 Profile* profile_; // weak pointer - owned by ProfileManager. | 492 // The browser context with which this window is associated. ShellWindow does |
| 493 // not own this object. |
| 494 content::BrowserContext* browser_context_; |
| 495 |
492 // weak pointer - owned by ExtensionService. | 496 // weak pointer - owned by ExtensionService. |
493 const extensions::Extension* extension_; | 497 const extensions::Extension* extension_; |
494 const std::string extension_id_; | 498 const std::string extension_id_; |
495 | 499 |
496 // Identifier that is used when saving and restoring geometry for this | 500 // Identifier that is used when saving and restoring geometry for this |
497 // window. | 501 // window. |
498 std::string window_key_; | 502 std::string window_key_; |
499 | 503 |
500 const SessionID session_id_; | 504 const SessionID session_id_; |
501 WindowType window_type_; | 505 WindowType window_type_; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 // reinstated when the window exits fullscreen and moves away from the | 552 // reinstated when the window exits fullscreen and moves away from the |
549 // taskbar. | 553 // taskbar. |
550 bool cached_always_on_top_; | 554 bool cached_always_on_top_; |
551 | 555 |
552 DISALLOW_COPY_AND_ASSIGN(ShellWindow); | 556 DISALLOW_COPY_AND_ASSIGN(ShellWindow); |
553 }; | 557 }; |
554 | 558 |
555 } // namespace apps | 559 } // namespace apps |
556 | 560 |
557 #endif // APPS_SHELL_WINDOW_H_ | 561 #endif // APPS_SHELL_WINDOW_H_ |
OLD | NEW |