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 EXTENSIONS_SHELL_BROWSER_SHELL_APP_WINDOW_H_ | 5 #ifndef EXTENSIONS_SHELL_BROWSER_SHELL_APP_WINDOW_H_ |
6 #define EXTENSIONS_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_delegate.h" | |
10 #include "content/public/browser/web_contents_observer.h" | 11 #include "content/public/browser/web_contents_observer.h" |
11 #include "extensions/browser/extension_function_dispatcher.h" | 12 #include "extensions/browser/extension_function_dispatcher.h" |
12 | 13 |
13 struct ExtensionHostMsg_Request_Params; | 14 struct ExtensionHostMsg_Request_Params; |
14 class GURL; | 15 class GURL; |
15 | 16 |
16 namespace aura { | 17 namespace aura { |
17 class Window; | 18 class Window; |
18 } | 19 } |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 class BrowserContext; | 22 class BrowserContext; |
22 class WebContents; | 23 class WebContents; |
23 } | 24 } |
24 | 25 |
25 namespace gfx { | 26 namespace gfx { |
26 class Size; | 27 class Size; |
27 } | 28 } |
28 | 29 |
29 namespace extensions { | 30 namespace extensions { |
30 | 31 |
31 class ExtensionFunctionDispatcher; | 32 class ExtensionFunctionDispatcher; |
33 class ShellWebContentsDelegate; | |
32 | 34 |
33 // A simplified app window created by chrome.app.window.create(). Manages the | 35 // A simplified app window created by chrome.app.window.create(). Manages the |
34 // primary web contents for the app. | 36 // primary web contents for the app. |
35 class ShellAppWindow : public content::WebContentsObserver, | 37 class ShellAppWindow : public content::WebContentsDelegate, |
38 public content::WebContentsObserver, | |
36 public ExtensionFunctionDispatcher::Delegate { | 39 public ExtensionFunctionDispatcher::Delegate { |
37 public: | 40 public: |
38 ShellAppWindow(); | 41 ShellAppWindow(); |
39 virtual ~ShellAppWindow(); | 42 virtual ~ShellAppWindow(); |
40 | 43 |
41 // Creates the web contents and attaches extension-specific helpers. | 44 // Creates the web contents and attaches extension-specific helpers. |
42 // Passing a valid |initial_size| to avoid a web contents resize. | 45 // Passing a valid |initial_size| to avoid a web contents resize. |
43 void Init(content::BrowserContext* context, gfx::Size initial_size); | 46 void Init(content::BrowserContext* context, |
47 const Extension* extension, | |
48 gfx::Size initial_size); | |
Daniel Erat
2014/08/22 17:09:55
nit: const ref, maybe
| |
44 | 49 |
45 // Starts loading |url| which must be an extension URL. | 50 // Starts loading |url| which must be an extension URL. |
46 void LoadURL(const GURL& url); | 51 void LoadURL(const GURL& url); |
47 | 52 |
48 // Returns the window hosting the web contents. | 53 // Returns the window hosting the web contents. |
49 aura::Window* GetNativeWindow(); | 54 aura::Window* GetNativeWindow(); |
50 | 55 |
51 // Returns the routing ID of the render view host of |web_contents_|. | 56 // Returns the routing ID of the render view host of |web_contents_|. |
52 int GetRenderViewRoutingID(); | 57 int GetRenderViewRoutingID(); |
53 | 58 |
54 // content::WebContentsObserver implementation | 59 // content::WebContentsDelegate overrides: |
60 virtual void RequestMediaAccessPermission( | |
61 content::WebContents* web_contents, | |
62 const content::MediaStreamRequest& request, | |
63 const content::MediaResponseCallback& callback) OVERRIDE; | |
64 | |
65 // content::WebContentsObserver overrides: | |
55 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 66 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
56 | 67 |
57 // ExtensionFunctionDispatcher::Delegate implementation | 68 // ExtensionFunctionDispatcher::Delegate overrides: |
58 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; | 69 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; |
59 | 70 |
60 private: | 71 private: |
61 // IPC handler. | 72 // IPC handler. |
62 void OnRequest(const ExtensionHostMsg_Request_Params& params); | 73 void OnRequest(const ExtensionHostMsg_Request_Params& params); |
63 | 74 |
75 // The extension that spawned this window. Not owned. | |
76 const Extension* extension_; | |
77 | |
64 scoped_ptr<content::WebContents> web_contents_; | 78 scoped_ptr<content::WebContents> web_contents_; |
65 scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_; | 79 scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_; |
66 | 80 |
67 DISALLOW_COPY_AND_ASSIGN(ShellAppWindow); | 81 DISALLOW_COPY_AND_ASSIGN(ShellAppWindow); |
68 }; | 82 }; |
69 | 83 |
70 } // namespace extensions | 84 } // namespace extensions |
71 | 85 |
72 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_APP_WINDOW_H_ | 86 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_APP_WINDOW_H_ |
OLD | NEW |