Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: apps/shell_window.h

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

Powered by Google App Engine
This is Rietveld 408576698