| 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/guest_view/app_view/app_view_guest_delegate.h" | 10 #include "extensions/browser/guest_view/app_view/app_view_guest_delegate.h" |
| 11 | 11 |
| 12 namespace extensions { | 12 namespace extensions { |
| 13 class Extension; | 13 class Extension; |
| 14 class ExtensionHost; | 14 class ExtensionHost; |
| 15 | 15 |
| 16 // An AppViewGuest provides the browser-side implementation of <appview> API. | 16 // An AppViewGuest provides the browser-side implementation of <appview> API. |
| 17 // 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 |
| 18 // associated with a particular embedder WebContents. This happens on calls to | 18 // associated with a particular embedder WebContents. This happens on calls to |
| 19 // the connect API. | 19 // the connect API. |
| 20 class AppViewGuest : public guest_view::GuestView<AppViewGuest> { | 20 class AppViewGuest : public guest_view::GuestView<AppViewGuest> { |
| 21 public: | 21 public: |
| 22 static const char Type[]; | 22 static const char Type[]; |
| 23 | 23 |
| 24 // Completes the creation of a WebContents associated with the provided | 24 // Completes the creation of a WebContents associated with the provided |
| 25 // |guest_extensions_id|. | 25 // |guest_extension_id| and |guest_instance_id| for the given |
| 26 // |browser_context|. |
| 27 // |guest_render_process_host| is the RenderProcessHost and |url| is the |
| 28 // resource GURL of the extension instance making this request. If there is |
| 29 // any mismatch between the expected |guest_instance_id| and |
| 30 // |guest_extension_id| provided and the recorded copies from when the the |
| 31 // <appview> was created, the RenderProcessHost of the extension instance |
| 32 // behind this request will be killed. |
| 26 static bool CompletePendingRequest( | 33 static bool CompletePendingRequest( |
| 27 content::BrowserContext* browser_context, | 34 content::BrowserContext* browser_context, |
| 28 const GURL& url, | 35 const GURL& url, |
| 29 int guest_instance_id, | 36 int guest_instance_id, |
| 30 const std::string& guest_extension_id); | 37 const std::string& guest_extension_id, |
| 38 content::RenderProcessHost* guest_render_process_host); |
| 31 | 39 |
| 32 static GuestViewBase* Create(content::WebContents* owner_web_contents); | 40 static GuestViewBase* Create(content::WebContents* owner_web_contents); |
| 33 | 41 |
| 42 static std::vector<int> GetAllRegisteredInstanceIdsForTesting(); |
| 43 |
| 34 // content::WebContentsDelegate implementation. | 44 // content::WebContentsDelegate implementation. |
| 35 bool HandleContextMenu(const content::ContextMenuParams& params) override; | 45 bool HandleContextMenu(const content::ContextMenuParams& params) override; |
| 36 void RequestMediaAccessPermission( | 46 void RequestMediaAccessPermission( |
| 37 content::WebContents* web_contents, | 47 content::WebContents* web_contents, |
| 38 const content::MediaStreamRequest& request, | 48 const content::MediaStreamRequest& request, |
| 39 const content::MediaResponseCallback& callback) override; | 49 const content::MediaResponseCallback& callback) override; |
| 40 bool CheckMediaAccessPermission(content::WebContents* web_contents, | 50 bool CheckMediaAccessPermission(content::WebContents* web_contents, |
| 41 const GURL& security_origin, | 51 const GURL& security_origin, |
| 42 content::MediaStreamType type) override; | 52 content::MediaStreamType type) override; |
| 43 | 53 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 73 // This is used to ensure pending tasks will not fire after this object is | 83 // This is used to ensure pending tasks will not fire after this object is |
| 74 // destroyed. | 84 // destroyed. |
| 75 base::WeakPtrFactory<AppViewGuest> weak_ptr_factory_; | 85 base::WeakPtrFactory<AppViewGuest> weak_ptr_factory_; |
| 76 | 86 |
| 77 DISALLOW_COPY_AND_ASSIGN(AppViewGuest); | 87 DISALLOW_COPY_AND_ASSIGN(AppViewGuest); |
| 78 }; | 88 }; |
| 79 | 89 |
| 80 } // namespace extensions | 90 } // namespace extensions |
| 81 | 91 |
| 82 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_APP_VIEW_APP_VIEW_GUEST_H_ | 92 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_APP_VIEW_APP_VIEW_GUEST_H_ |
| OLD | NEW |