| 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; |
| 24 class SkRegion; | 25 class SkRegion; |
| 25 | 26 |
| 26 namespace base { | 27 namespace base { |
| 27 class DictionaryValue; | 28 class DictionaryValue; |
| 28 } | 29 } |
| 29 | 30 |
| 30 namespace content { | 31 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(content::BrowserContext* context, | 61 virtual void Initialize(Profile* profile, const GURL& url) = 0; |
| 62 const GURL& url) = 0; | |
| 63 | 62 |
| 64 // Called to load the contents, after the app window is created. | 63 // Called to load the contents, after the app window is created. |
| 65 virtual void LoadContents(int32 creator_process_id) = 0; | 64 virtual void LoadContents(int32 creator_process_id) = 0; |
| 66 | 65 |
| 67 // Called when the native window changes. | 66 // Called when the native window changes. |
| 68 virtual void NativeWindowChanged(NativeAppWindow* native_app_window) = 0; | 67 virtual void NativeWindowChanged(NativeAppWindow* native_app_window) = 0; |
| 69 | 68 |
| 70 // Called when the native window closes. | 69 // Called when the native window closes. |
| 71 virtual void NativeWindowClosed() = 0; | 70 virtual void NativeWindowClosed() = 0; |
| 72 | 71 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 virtual ~Delegate(); | 194 virtual ~Delegate(); |
| 196 | 195 |
| 197 // General initialization. | 196 // General initialization. |
| 198 virtual void InitWebContents(content::WebContents* web_contents) = 0; | 197 virtual void InitWebContents(content::WebContents* web_contents) = 0; |
| 199 virtual NativeAppWindow* CreateNativeAppWindow( | 198 virtual NativeAppWindow* CreateNativeAppWindow( |
| 200 ShellWindow* window, | 199 ShellWindow* window, |
| 201 const CreateParams& params) = 0; | 200 const CreateParams& params) = 0; |
| 202 | 201 |
| 203 // Link handling. | 202 // Link handling. |
| 204 virtual content::WebContents* OpenURLFromTab( | 203 virtual content::WebContents* OpenURLFromTab( |
| 205 content::BrowserContext* context, | 204 Profile* profile, |
| 206 content::WebContents* source, | 205 content::WebContents* source, |
| 207 const content::OpenURLParams& params) = 0; | 206 const content::OpenURLParams& params) = 0; |
| 208 virtual void AddNewContents(content::BrowserContext* context, | 207 virtual void AddNewContents(Profile* profile, |
| 209 content::WebContents* new_contents, | 208 content::WebContents* new_contents, |
| 210 WindowOpenDisposition disposition, | 209 WindowOpenDisposition disposition, |
| 211 const gfx::Rect& initial_pos, | 210 const gfx::Rect& initial_pos, |
| 212 bool user_gesture, | 211 bool user_gesture, |
| 213 bool* was_blocked) = 0; | 212 bool* was_blocked) = 0; |
| 214 | 213 |
| 215 // Feature support. | 214 // Feature support. |
| 216 virtual content::ColorChooser* ShowColorChooser( | 215 virtual content::ColorChooser* ShowColorChooser( |
| 217 content::WebContents* web_contents, | 216 content::WebContents* web_contents, |
| 218 SkColor initial_color) = 0; | 217 SkColor initial_color) = 0; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 233 | 232 |
| 234 // Convert draggable regions in raw format to SkRegion format. Caller is | 233 // Convert draggable regions in raw format to SkRegion format. Caller is |
| 235 // responsible for deleting the returned SkRegion instance. | 234 // responsible for deleting the returned SkRegion instance. |
| 236 static SkRegion* RawDraggableRegionsToSkRegion( | 235 static SkRegion* RawDraggableRegionsToSkRegion( |
| 237 const std::vector<extensions::DraggableRegion>& regions); | 236 const std::vector<extensions::DraggableRegion>& regions); |
| 238 | 237 |
| 239 // The constructor and Init methods are public for constructing a ShellWindow | 238 // The constructor and Init methods are public for constructing a ShellWindow |
| 240 // with a non-standard render interface (e.g. v1 apps using Ash Panels). | 239 // with a non-standard render interface (e.g. v1 apps using Ash Panels). |
| 241 // Normally ShellWindow::Create should be used. | 240 // Normally ShellWindow::Create should be used. |
| 242 // The constructed shell window takes ownership of |delegate|. | 241 // The constructed shell window takes ownership of |delegate|. |
| 243 ShellWindow(content::BrowserContext* context, | 242 ShellWindow(Profile* profile, |
| 244 Delegate* delegate, | 243 Delegate* delegate, |
| 245 const extensions::Extension* extension); | 244 const extensions::Extension* extension); |
| 246 | 245 |
| 247 // Initializes the render interface, web contents, and native window. | 246 // Initializes the render interface, web contents, and native window. |
| 248 // |shell_window_contents| will become owned by ShellWindow. | 247 // |shell_window_contents| will become owned by ShellWindow. |
| 249 void Init(const GURL& url, | 248 void Init(const GURL& url, |
| 250 ShellWindowContents* shell_window_contents, | 249 ShellWindowContents* shell_window_contents, |
| 251 const CreateParams& params); | 250 const CreateParams& params); |
| 252 | 251 |
| 253 | 252 |
| 254 const std::string& window_key() const { return window_key_; } | 253 const std::string& window_key() const { return window_key_; } |
| 255 const SessionID& session_id() const { return session_id_; } | 254 const SessionID& session_id() const { return session_id_; } |
| 256 const extensions::Extension* extension() const { return extension_; } | 255 const extensions::Extension* extension() const { return extension_; } |
| 257 const std::string& extension_id() const { return extension_id_; } | 256 const std::string& extension_id() const { return extension_id_; } |
| 258 content::WebContents* web_contents() const; | 257 content::WebContents* web_contents() const; |
| 259 WindowType window_type() const { return window_type_; } | 258 WindowType window_type() const { return window_type_; } |
| 260 bool window_type_is_panel() const { | 259 bool window_type_is_panel() const { |
| 261 return (window_type_ == WINDOW_TYPE_PANEL || | 260 return (window_type_ == WINDOW_TYPE_PANEL || |
| 262 window_type_ == WINDOW_TYPE_V1_PANEL); | 261 window_type_ == WINDOW_TYPE_V1_PANEL); |
| 263 } | 262 } |
| 264 content::BrowserContext* browser_context() const { return browser_context_; } | 263 Profile* profile() const { return profile_; } |
| 265 const gfx::Image& app_icon() const { return app_icon_; } | 264 const gfx::Image& app_icon() const { return app_icon_; } |
| 266 const GURL& app_icon_url() const { return app_icon_url_; } | 265 const GURL& app_icon_url() const { return app_icon_url_; } |
| 267 const gfx::Image& badge_icon() const { return badge_icon_; } | 266 const gfx::Image& badge_icon() const { return badge_icon_; } |
| 268 const GURL& badge_icon_url() const { return badge_icon_url_; } | 267 const GURL& badge_icon_url() const { return badge_icon_url_; } |
| 269 | 268 |
| 270 NativeAppWindow* GetBaseWindow(); | 269 NativeAppWindow* GetBaseWindow(); |
| 271 gfx::NativeWindow GetNativeWindow(); | 270 gfx::NativeWindow GetNativeWindow(); |
| 272 | 271 |
| 273 // Returns the bounds that should be reported to the renderer. | 272 // Returns the bounds that should be reported to the renderer. |
| 274 gfx::Rect GetClientBounds() const; | 273 gfx::Rect GetClientBounds() const; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 void DidDownloadFavicon(int id, | 481 void DidDownloadFavicon(int id, |
| 483 int http_status_code, | 482 int http_status_code, |
| 484 const GURL& image_url, | 483 const GURL& image_url, |
| 485 const std::vector<SkBitmap>& bitmaps, | 484 const std::vector<SkBitmap>& bitmaps, |
| 486 const std::vector<gfx::Size>& original_bitmap_sizes); | 485 const std::vector<gfx::Size>& original_bitmap_sizes); |
| 487 | 486 |
| 488 // extensions::IconImage::Observer implementation. | 487 // extensions::IconImage::Observer implementation. |
| 489 virtual void OnExtensionIconImageChanged( | 488 virtual void OnExtensionIconImageChanged( |
| 490 extensions::IconImage* image) OVERRIDE; | 489 extensions::IconImage* image) OVERRIDE; |
| 491 | 490 |
| 492 // The browser context with which this window is associated. ShellWindow does | 491 Profile* profile_; // weak pointer - owned by ProfileManager. |
| 493 // not own this object. | |
| 494 content::BrowserContext* browser_context_; | |
| 495 | |
| 496 // weak pointer - owned by ExtensionService. | 492 // weak pointer - owned by ExtensionService. |
| 497 const extensions::Extension* extension_; | 493 const extensions::Extension* extension_; |
| 498 const std::string extension_id_; | 494 const std::string extension_id_; |
| 499 | 495 |
| 500 // Identifier that is used when saving and restoring geometry for this | 496 // Identifier that is used when saving and restoring geometry for this |
| 501 // window. | 497 // window. |
| 502 std::string window_key_; | 498 std::string window_key_; |
| 503 | 499 |
| 504 const SessionID session_id_; | 500 const SessionID session_id_; |
| 505 WindowType window_type_; | 501 WindowType window_type_; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 // reinstated when the window exits fullscreen and moves away from the | 548 // reinstated when the window exits fullscreen and moves away from the |
| 553 // taskbar. | 549 // taskbar. |
| 554 bool cached_always_on_top_; | 550 bool cached_always_on_top_; |
| 555 | 551 |
| 556 DISALLOW_COPY_AND_ASSIGN(ShellWindow); | 552 DISALLOW_COPY_AND_ASSIGN(ShellWindow); |
| 557 }; | 553 }; |
| 558 | 554 |
| 559 } // namespace apps | 555 } // namespace apps |
| 560 | 556 |
| 561 #endif // APPS_SHELL_WINDOW_H_ | 557 #endif // APPS_SHELL_WINDOW_H_ |
| OLD | NEW |