OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_BROWSER_SHELL_APP_WINDOW_H_ | 5 #ifndef EXTENSIONS_SHELL_BROWSER_SHELL_APP_WINDOW_H_ |
6 #define APPS_SHELL_BROWSER_SHELL_APP_WINDOW_H_ | 6 #define EXTENSIONS_SHELL_BROWSER_SHELL_APP_WINDOW_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "content/public/browser/web_contents_observer.h" | 10 #include "content/public/browser/web_contents_observer.h" |
11 #include "extensions/browser/extension_function_dispatcher.h" | 11 #include "extensions/browser/extension_function_dispatcher.h" |
12 | 12 |
13 struct ExtensionHostMsg_Request_Params; | 13 struct ExtensionHostMsg_Request_Params; |
14 class GURL; | 14 class GURL; |
15 | 15 |
16 namespace aura { | 16 namespace aura { |
17 class Window; | 17 class Window; |
18 } | 18 } |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 class BrowserContext; | 21 class BrowserContext; |
22 class WebContents; | 22 class WebContents; |
23 } | 23 } |
24 | 24 |
25 namespace extensions { | |
26 class ExtensionFunctionDispatcher; | |
27 } | |
28 | |
29 namespace gfx { | 25 namespace gfx { |
30 class Size; | 26 class Size; |
31 } | 27 } |
32 | 28 |
33 namespace apps { | 29 namespace extensions { |
| 30 |
| 31 class ExtensionFunctionDispatcher; |
34 | 32 |
35 // A simplified app window created by chrome.app.window.create(). Manages the | 33 // A simplified app window created by chrome.app.window.create(). Manages the |
36 // primary web contents for the app. | 34 // primary web contents for the app. |
37 class ShellAppWindow | 35 class ShellAppWindow : public content::WebContentsObserver, |
38 : public content::WebContentsObserver, | 36 public ExtensionFunctionDispatcher::Delegate { |
39 public extensions::ExtensionFunctionDispatcher::Delegate { | |
40 public: | 37 public: |
41 ShellAppWindow(); | 38 ShellAppWindow(); |
42 virtual ~ShellAppWindow(); | 39 virtual ~ShellAppWindow(); |
43 | 40 |
44 // Creates the web contents and attaches extension-specific helpers. | 41 // Creates the web contents and attaches extension-specific helpers. |
45 // Passing a valid |initial_size| to avoid a web contents resize. | 42 // Passing a valid |initial_size| to avoid a web contents resize. |
46 void Init(content::BrowserContext* context, gfx::Size initial_size); | 43 void Init(content::BrowserContext* context, gfx::Size initial_size); |
47 | 44 |
48 // Starts loading |url| which must be an extension URL. | 45 // Starts loading |url| which must be an extension URL. |
49 void LoadURL(const GURL& url); | 46 void LoadURL(const GURL& url); |
50 | 47 |
51 // Returns the window hosting the web contents. | 48 // Returns the window hosting the web contents. |
52 aura::Window* GetNativeWindow(); | 49 aura::Window* GetNativeWindow(); |
53 | 50 |
54 // Returns the routing ID of the render view host of |web_contents_|. | 51 // Returns the routing ID of the render view host of |web_contents_|. |
55 int GetRenderViewRoutingID(); | 52 int GetRenderViewRoutingID(); |
56 | 53 |
57 // content::WebContentsObserver implementation | 54 // content::WebContentsObserver implementation |
58 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 55 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
59 | 56 |
60 // extensions::ExtensionFunctionDispatcher::Delegate implementation | 57 // ExtensionFunctionDispatcher::Delegate implementation |
61 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; | 58 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; |
62 | 59 |
63 private: | 60 private: |
64 // IPC handler. | 61 // IPC handler. |
65 void OnRequest(const ExtensionHostMsg_Request_Params& params); | 62 void OnRequest(const ExtensionHostMsg_Request_Params& params); |
66 | 63 |
67 scoped_ptr<content::WebContents> web_contents_; | 64 scoped_ptr<content::WebContents> web_contents_; |
68 scoped_ptr<extensions::ExtensionFunctionDispatcher> | 65 scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_; |
69 extension_function_dispatcher_; | |
70 | 66 |
71 DISALLOW_COPY_AND_ASSIGN(ShellAppWindow); | 67 DISALLOW_COPY_AND_ASSIGN(ShellAppWindow); |
72 }; | 68 }; |
73 | 69 |
74 } // namespace apps | 70 } // namespace extensions |
75 | 71 |
76 #endif // APPS_SHELL_BROWSER_SHELL_APP_WINDOW_H_ | 72 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_APP_WINDOW_H_ |
OLD | NEW |