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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/extensions/extension_function_dispatcher.h" | |
10 #include "chrome/browser/sessions/session_id.h" | 11 #include "chrome/browser/sessions/session_id.h" |
11 #include "chrome/browser/extensions/extension_host.h" | |
12 #include "chrome/browser/ui/base_window.h" | 12 #include "chrome/browser/ui/base_window.h" |
13 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
15 #include "content/public/browser/web_contents_delegate.h" | |
16 #include "content/public/browser/web_contents_observer.h" | |
15 | 17 |
18 class Browser; | |
16 class Extension; | 19 class Extension; |
17 class ExtensionHost; | |
18 class ExtensionWindowController; | 20 class ExtensionWindowController; |
19 class GURL; | 21 class GURL; |
20 class Profile; | 22 class Profile; |
21 | 23 |
22 namespace content { | 24 namespace content { |
23 class WebContents; | 25 class WebContents; |
24 } | 26 } |
25 | 27 |
26 class ShellWindow : public content::NotificationObserver, | 28 class ShellWindow : public content::NotificationObserver, |
29 public content::WebContentsDelegate, | |
30 public content::WebContentsObserver, | |
31 public ExtensionFunctionDispatcher::Delegate, | |
27 public BaseWindow { | 32 public BaseWindow { |
28 public: | 33 public: |
29 // TODO(mihaip): Switch from hardcoded defaults to passing in the window | 34 // TODO(mihaip): Switch from hardcoded defaults to passing in the window |
30 // creation parameters to ShellWindow::Create. | 35 // creation parameters to ShellWindow::Create. |
31 static const int kDefaultWidth = 512; | 36 static const int kDefaultWidth = 512; |
32 static const int kDefaultHeight = 384; | 37 static const int kDefaultHeight = 384; |
33 | 38 |
34 content::WebContents* web_contents() const { return host_->host_contents(); } | 39 content::WebContents* web_contents() const { return web_contents_.get(); } |
35 const SessionID& session_id() const { return session_id_; } | 40 const SessionID& session_id() const { return session_id_; } |
36 const ExtensionWindowController* extension_window_controller() const { | 41 const ExtensionWindowController* extension_window_controller() const { |
37 return extension_window_controller_.get(); | 42 return extension_window_controller_.get(); |
38 } | 43 } |
39 | 44 |
40 static ShellWindow* Create(Profile* profile, | 45 static ShellWindow* Create(Profile* profile, |
41 const Extension* extension, | 46 const Extension* extension, |
42 const GURL& url); | 47 const GURL& url); |
43 | 48 |
49 // ExtensionFunctionDispatcher::Delegate | |
Aaron Boodman
2012/04/27 16:20:31
None of these implemented interfaces need to be pu
benwells
2012/05/03 09:22:40
Done. I didn't even realize you could do this ...
| |
50 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; | |
51 | |
52 // content::WebContentsObserver | |
53 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
54 | |
55 // content::WebContentsDelegate | |
56 virtual void CloseContents(content::WebContents* contents) OVERRIDE; | |
57 virtual bool ShouldSuppressDialogs() OVERRIDE; | |
58 | |
44 // content::NotificationObserver implementation. | 59 // content::NotificationObserver implementation. |
45 virtual void Observe(int type, | 60 virtual void Observe(int type, |
46 const content::NotificationSource& source, | 61 const content::NotificationSource& source, |
47 const content::NotificationDetails& details) OVERRIDE; | 62 const content::NotificationDetails& details) OVERRIDE; |
48 | 63 |
49 protected: | 64 protected: |
50 explicit ShellWindow(ExtensionHost* host_); | 65 ShellWindow(Profile* profile, |
66 const Extension* extension, | |
67 const GURL& url); | |
51 virtual ~ShellWindow(); | 68 virtual ~ShellWindow(); |
52 | 69 |
53 // Instantiates a platform-specific ShellWindow subclass (one implementation | 70 // Instantiates a platform-specific ShellWindow subclass (one implementation |
54 // per platform). Public users of ShellWindow should use ShellWindow::Create. | 71 // per platform). Public users of ShellWindow should use ShellWindow::Create. |
Aaron Boodman
2012/04/27 16:20:31
Name this CreateImpl()?
benwells
2012/05/03 09:22:40
Done.
| |
55 static ShellWindow* CreateShellWindow(ExtensionHost* host); | 72 static ShellWindow* CreateShellWindow(Profile* profile, |
Aaron Boodman
2012/04/27 16:20:31
Does all of this really need to be accessible to s
benwells
2012/05/03 09:22:40
Agreed. I moved other stuff in this class to be as
| |
73 const Extension* extension, | |
74 const GURL& url); | |
56 | 75 |
76 // ExtensionFunctionDispatcher::Delegate | |
77 virtual Browser* GetBrowser() OVERRIDE; | |
78 | |
79 // Message handlers. | |
80 void OnRequest(const ExtensionHostMsg_Request_Params& params); | |
81 | |
82 Profile* profile_; // weak pointer - owned by ProfileManager. | |
57 const SessionID session_id_; | 83 const SessionID session_id_; |
58 scoped_ptr<ExtensionHost> host_; | 84 const Extension* extension_; // weak pointer - owned by ExtensionService. |
59 content::NotificationRegistrar registrar_; | 85 content::NotificationRegistrar registrar_; |
60 scoped_ptr<ExtensionWindowController> extension_window_controller_; | 86 scoped_ptr<ExtensionWindowController> extension_window_controller_; |
87 scoped_ptr<content::WebContents> web_contents_; | |
61 | 88 |
89 ExtensionFunctionDispatcher extension_function_dispatcher_; | |
62 private: | 90 private: |
63 DISALLOW_COPY_AND_ASSIGN(ShellWindow); | 91 DISALLOW_COPY_AND_ASSIGN(ShellWindow); |
64 }; | 92 }; |
65 | 93 |
66 #endif // CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ | 94 #endif // CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ |
OLD | NEW |