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 { |
| 25 class SiteInstance; |
23 class WebContents; | 26 class WebContents; |
24 } | 27 } |
25 | 28 |
26 class ShellWindow : public content::NotificationObserver, | 29 class ShellWindow : public content::NotificationObserver, |
| 30 public content::WebContentsDelegate, |
| 31 public content::WebContentsObserver, |
| 32 public ExtensionFunctionDispatcher::Delegate, |
27 public BaseWindow { | 33 public BaseWindow { |
28 public: | 34 public: |
29 // TODO(mihaip): Switch from hardcoded defaults to passing in the window | 35 // TODO(mihaip): Switch from hardcoded defaults to passing in the window |
30 // creation parameters to ShellWindow::Create. | 36 // creation parameters to ShellWindow::Create. |
31 static const int kDefaultWidth = 512; | 37 static const int kDefaultWidth = 512; |
32 static const int kDefaultHeight = 384; | 38 static const int kDefaultHeight = 384; |
33 | 39 |
34 content::WebContents* web_contents() const { return host_->host_contents(); } | 40 content::WebContents* web_contents() const { return web_contents_.get(); } |
35 const SessionID& session_id() const { return session_id_; } | 41 const SessionID& session_id() const { return session_id_; } |
36 const ExtensionWindowController* extension_window_controller() const { | 42 const ExtensionWindowController* extension_window_controller() const { |
37 return extension_window_controller_.get(); | 43 return extension_window_controller_.get(); |
38 } | 44 } |
39 | 45 |
40 static ShellWindow* Create(Profile* profile, | 46 static ShellWindow* Create(Profile* profile, |
41 const Extension* extension, | 47 const Extension* extension, |
42 const GURL& url); | 48 const GURL& url); |
43 | 49 |
| 50 // ExtensionFunctionDispatcher::Delegate |
| 51 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; |
| 52 |
| 53 // content::WebContentsObserver |
| 54 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 55 |
| 56 // content::WebContentsDelegate |
| 57 virtual void CloseContents(content::WebContents* contents) OVERRIDE; |
| 58 virtual bool ShouldSuppressDialogs() OVERRIDE; |
| 59 |
44 // content::NotificationObserver implementation. | 60 // content::NotificationObserver implementation. |
45 virtual void Observe(int type, | 61 virtual void Observe(int type, |
46 const content::NotificationSource& source, | 62 const content::NotificationSource& source, |
47 const content::NotificationDetails& details) OVERRIDE; | 63 const content::NotificationDetails& details) OVERRIDE; |
48 | 64 |
49 protected: | 65 protected: |
50 explicit ShellWindow(ExtensionHost* host_); | 66 ShellWindow(Profile* profile, |
| 67 const Extension* extension, |
| 68 const GURL& url); |
51 virtual ~ShellWindow(); | 69 virtual ~ShellWindow(); |
52 | 70 |
53 // Instantiates a platform-specific ShellWindow subclass (one implementation | 71 // Instantiates a platform-specific ShellWindow subclass (one implementation |
54 // per platform). Public users of ShellWindow should use ShellWindow::Create. | 72 // per platform). Public users of ShellWindow should use ShellWindow::Create. |
55 static ShellWindow* CreateShellWindow(ExtensionHost* host); | 73 static ShellWindow* CreateShellWindow(Profile* profile, |
| 74 const Extension* extension, |
| 75 const GURL& url); |
56 | 76 |
| 77 // ExtensionFunctionDispatcher::Delegate |
| 78 virtual Browser* GetBrowser() OVERRIDE; |
| 79 |
| 80 // Message handlers. |
| 81 void OnRequest(const ExtensionHostMsg_Request_Params& params); |
| 82 |
| 83 Profile* profile_; // weak pointer - owned by ProfileManager. |
57 const SessionID session_id_; | 84 const SessionID session_id_; |
58 scoped_ptr<ExtensionHost> host_; | 85 const Extension* extension_; // weak pointer - owned by ExtensionService. |
59 content::NotificationRegistrar registrar_; | 86 content::NotificationRegistrar registrar_; |
60 scoped_ptr<ExtensionWindowController> extension_window_controller_; | 87 scoped_ptr<ExtensionWindowController> extension_window_controller_; |
| 88 scoped_ptr<content::WebContents> web_contents_; |
61 | 89 |
| 90 ExtensionFunctionDispatcher extension_function_dispatcher_; |
| 91 |
| 92 scoped_refptr<content::SiteInstance> site_instance_; |
62 private: | 93 private: |
63 DISALLOW_COPY_AND_ASSIGN(ShellWindow); | 94 DISALLOW_COPY_AND_ASSIGN(ShellWindow); |
64 }; | 95 }; |
65 | 96 |
66 #endif // CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ | 97 #endif // CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ |
OLD | NEW |