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_BROWSER_GUEST_VIEW_APP_VIEW_APP_VIEW_GUEST_H_ | 5 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_APP_VIEW_APP_VIEW_GUEST_H_ |
6 #define EXTENSIONS_BROWSER_GUEST_VIEW_APP_VIEW_APP_VIEW_GUEST_H_ | 6 #define EXTENSIONS_BROWSER_GUEST_VIEW_APP_VIEW_APP_VIEW_GUEST_H_ |
7 | 7 |
8 #include "base/id_map.h" | 8 #include "base/id_map.h" |
9 #include "components/guest_view/browser/guest_view.h" | 9 #include "components/guest_view/browser/guest_view.h" |
10 #include "extensions/browser/extension_function_dispatcher.h" | |
11 #include "extensions/browser/guest_view/app_view/app_view_guest_delegate.h" | 10 #include "extensions/browser/guest_view/app_view/app_view_guest_delegate.h" |
12 | 11 |
13 namespace extensions { | 12 namespace extensions { |
14 class Extension; | 13 class Extension; |
15 class ExtensionHost; | 14 class ExtensionHost; |
16 | 15 |
17 // An AppViewGuest provides the browser-side implementation of <appview> API. | 16 // An AppViewGuest provides the browser-side implementation of <appview> API. |
18 // AppViewGuest is created on attachment. That is, when a guest WebContents is | 17 // AppViewGuest is created on attachment. That is, when a guest WebContents is |
19 // associated with a particular embedder WebContents. This happens on calls to | 18 // associated with a particular embedder WebContents. This happens on calls to |
20 // the connect API. | 19 // the connect API. |
21 class AppViewGuest : public guest_view::GuestView<AppViewGuest>, | 20 class AppViewGuest : public guest_view::GuestView<AppViewGuest> { |
22 public ExtensionFunctionDispatcher::Delegate { | |
23 public: | 21 public: |
24 static const char Type[]; | 22 static const char Type[]; |
25 | 23 |
26 // Completes the creation of a WebContents associated with the provided | 24 // Completes the creation of a WebContents associated with the provided |
27 // |guest_extensions_id|. | 25 // |guest_extensions_id|. |
28 static bool CompletePendingRequest( | 26 static bool CompletePendingRequest( |
29 content::BrowserContext* browser_context, | 27 content::BrowserContext* browser_context, |
30 const GURL& url, | 28 const GURL& url, |
31 int guest_instance_id, | 29 int guest_instance_id, |
32 const std::string& guest_extension_id); | 30 const std::string& guest_extension_id); |
33 | 31 |
34 static GuestViewBase* Create(content::WebContents* owner_web_contents); | 32 static GuestViewBase* Create(content::WebContents* owner_web_contents); |
35 | 33 |
36 // ExtensionFunctionDispatcher::Delegate implementation. | |
37 WindowController* GetExtensionWindowController() const override; | |
38 content::WebContents* GetAssociatedWebContents() const override; | |
39 | |
40 // content::WebContentsObserver implementation. | |
41 bool OnMessageReceived(const IPC::Message& message) override; | |
42 | |
43 // content::WebContentsDelegate implementation. | 34 // content::WebContentsDelegate implementation. |
44 bool HandleContextMenu(const content::ContextMenuParams& params) override; | 35 bool HandleContextMenu(const content::ContextMenuParams& params) override; |
45 void RequestMediaAccessPermission( | 36 void RequestMediaAccessPermission( |
46 content::WebContents* web_contents, | 37 content::WebContents* web_contents, |
47 const content::MediaStreamRequest& request, | 38 const content::MediaStreamRequest& request, |
48 const content::MediaResponseCallback& callback) override; | 39 const content::MediaResponseCallback& callback) override; |
49 bool CheckMediaAccessPermission(content::WebContents* web_contents, | 40 bool CheckMediaAccessPermission(content::WebContents* web_contents, |
50 const GURL& security_origin, | 41 const GURL& security_origin, |
51 content::MediaStreamType type) override; | 42 content::MediaStreamType type) override; |
52 | 43 |
53 // GuestViewBase implementation. | 44 // GuestViewBase implementation. |
54 bool CanRunInDetachedState() const override; | 45 bool CanRunInDetachedState() const override; |
55 void CreateWebContents(const base::DictionaryValue& create_params, | 46 void CreateWebContents(const base::DictionaryValue& create_params, |
56 const WebContentsCreatedCallback& callback) override; | 47 const WebContentsCreatedCallback& callback) override; |
57 void DidInitialize(const base::DictionaryValue& create_params) override; | 48 void DidInitialize(const base::DictionaryValue& create_params) override; |
58 const char* GetAPINamespace() const override; | 49 const char* GetAPINamespace() const override; |
59 int GetTaskPrefix() const override; | 50 int GetTaskPrefix() const override; |
60 | 51 |
61 // Sets the AppDelegate for this guest. | 52 // Sets the AppDelegate for this guest. |
62 void SetAppDelegateForTest(AppDelegate* delegate); | 53 void SetAppDelegateForTest(AppDelegate* delegate); |
63 | 54 |
64 private: | 55 private: |
65 explicit AppViewGuest(content::WebContents* owner_web_contents); | 56 explicit AppViewGuest(content::WebContents* owner_web_contents); |
66 | 57 |
67 ~AppViewGuest() override; | 58 ~AppViewGuest() override; |
68 | 59 |
69 void OnRequest(const ExtensionHostMsg_Request_Params& params); | |
70 | |
71 void CompleteCreateWebContents(const GURL& url, | 60 void CompleteCreateWebContents(const GURL& url, |
72 const Extension* guest_extension, | 61 const Extension* guest_extension, |
73 const WebContentsCreatedCallback& callback); | 62 const WebContentsCreatedCallback& callback); |
74 | 63 |
75 void LaunchAppAndFireEvent(scoped_ptr<base::DictionaryValue> data, | 64 void LaunchAppAndFireEvent(scoped_ptr<base::DictionaryValue> data, |
76 const WebContentsCreatedCallback& callback, | 65 const WebContentsCreatedCallback& callback, |
77 ExtensionHost* extension_host); | 66 ExtensionHost* extension_host); |
78 | 67 |
79 GURL url_; | 68 GURL url_; |
80 std::string guest_extension_id_; | 69 std::string guest_extension_id_; |
81 scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_; | |
82 scoped_ptr<AppViewGuestDelegate> app_view_guest_delegate_; | 70 scoped_ptr<AppViewGuestDelegate> app_view_guest_delegate_; |
83 scoped_ptr<AppDelegate> app_delegate_; | 71 scoped_ptr<AppDelegate> app_delegate_; |
84 | 72 |
85 // This is used to ensure pending tasks will not fire after this object is | 73 // This is used to ensure pending tasks will not fire after this object is |
86 // destroyed. | 74 // destroyed. |
87 base::WeakPtrFactory<AppViewGuest> weak_ptr_factory_; | 75 base::WeakPtrFactory<AppViewGuest> weak_ptr_factory_; |
88 | 76 |
89 DISALLOW_COPY_AND_ASSIGN(AppViewGuest); | 77 DISALLOW_COPY_AND_ASSIGN(AppViewGuest); |
90 }; | 78 }; |
91 | 79 |
92 } // namespace extensions | 80 } // namespace extensions |
93 | 81 |
94 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_APP_VIEW_APP_VIEW_GUEST_H_ | 82 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_APP_VIEW_APP_VIEW_GUEST_H_ |
OLD | NEW |