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 #include "extensions/browser/guest_view/app_view/app_view_guest.h" | 5 #include "extensions/browser/guest_view/app_view/app_view_guest.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "components/guest_view/browser/guest_view_manager.h" | 8 #include "components/guest_view/browser/guest_view_manager.h" |
9 #include "content/public/browser/render_process_host.h" | 9 #include "content/public/browser/render_process_host.h" |
10 #include "content/public/common/renderer_preferences.h" | 10 #include "content/public/common/renderer_preferences.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 app_view_guest_delegate_(ExtensionsAPIClient::Get() | 105 app_view_guest_delegate_(ExtensionsAPIClient::Get() |
106 ->CreateAppViewGuestDelegate()), | 106 ->CreateAppViewGuestDelegate()), |
107 weak_ptr_factory_(this) { | 107 weak_ptr_factory_(this) { |
108 if (app_view_guest_delegate_) | 108 if (app_view_guest_delegate_) |
109 app_delegate_.reset(app_view_guest_delegate_->CreateAppDelegate()); | 109 app_delegate_.reset(app_view_guest_delegate_->CreateAppDelegate()); |
110 } | 110 } |
111 | 111 |
112 AppViewGuest::~AppViewGuest() { | 112 AppViewGuest::~AppViewGuest() { |
113 } | 113 } |
114 | 114 |
115 bool AppViewGuest::HandleContextMenu(const content::ContextMenuParams& params) { | |
116 if (app_view_guest_delegate_) { | |
117 return app_view_guest_delegate_->HandleContextMenu(web_contents(), params); | |
118 } | |
119 return false; | |
120 } | |
121 | |
122 void AppViewGuest::RequestMediaAccessPermission( | |
123 WebContents* web_contents, | |
124 const content::MediaStreamRequest& request, | |
125 const content::MediaResponseCallback& callback) { | |
126 if (!app_delegate_) { | |
127 WebContentsDelegate::RequestMediaAccessPermission(web_contents, request, | |
128 callback); | |
129 return; | |
130 } | |
131 const ExtensionSet& enabled_extensions = | |
132 ExtensionRegistry::Get(browser_context())->enabled_extensions(); | |
133 const Extension* guest_extension = | |
134 enabled_extensions.GetByID(guest_extension_id_); | |
135 | |
136 app_delegate_->RequestMediaAccessPermission(web_contents, request, callback, | |
137 guest_extension); | |
138 } | |
139 | |
140 bool AppViewGuest::CheckMediaAccessPermission(WebContents* web_contents, | |
141 const GURL& security_origin, | |
142 content::MediaStreamType type) { | |
143 if (!app_delegate_) { | |
144 return WebContentsDelegate::CheckMediaAccessPermission( | |
145 web_contents, security_origin, type); | |
146 } | |
147 const ExtensionSet& enabled_extensions = | |
148 ExtensionRegistry::Get(browser_context())->enabled_extensions(); | |
149 const Extension* guest_extension = | |
150 enabled_extensions.GetByID(guest_extension_id_); | |
151 | |
152 return app_delegate_->CheckMediaAccessPermission( | |
153 web_contents, security_origin, type, guest_extension); | |
154 } | |
155 | 115 |
156 bool AppViewGuest::CanRunInDetachedState() const { | 116 bool AppViewGuest::CanRunInDetachedState() const { |
157 return true; | 117 return true; |
158 } | 118 } |
159 | 119 |
160 void AppViewGuest::CreateWebContents( | 120 void AppViewGuest::CreateWebContents( |
161 const base::DictionaryValue& create_params, | 121 const base::DictionaryValue& create_params, |
162 const WebContentsCreatedCallback& callback) { | 122 const WebContentsCreatedCallback& callback) { |
163 std::string app_id; | 123 std::string app_id; |
164 if (!create_params.GetString(appview::kAppID, &app_id)) { | 124 if (!create_params.GetString(appview::kAppID, &app_id)) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 } | 186 } |
227 | 187 |
228 const char* AppViewGuest::GetAPINamespace() const { | 188 const char* AppViewGuest::GetAPINamespace() const { |
229 return appview::kEmbedderAPINamespace; | 189 return appview::kEmbedderAPINamespace; |
230 } | 190 } |
231 | 191 |
232 int AppViewGuest::GetTaskPrefix() const { | 192 int AppViewGuest::GetTaskPrefix() const { |
233 return IDS_EXTENSION_TASK_MANAGER_APPVIEW_TAG_PREFIX; | 193 return IDS_EXTENSION_TASK_MANAGER_APPVIEW_TAG_PREFIX; |
234 } | 194 } |
235 | 195 |
| 196 bool AppViewGuest::HandleContextMenu(const content::ContextMenuParams& params) { |
| 197 if (app_view_guest_delegate_) { |
| 198 return app_view_guest_delegate_->HandleContextMenu(web_contents(), params); |
| 199 } |
| 200 return false; |
| 201 } |
| 202 |
| 203 void AppViewGuest::RequestMediaAccessPermission( |
| 204 WebContents* web_contents, |
| 205 const content::MediaStreamRequest& request, |
| 206 const content::MediaResponseCallback& callback) { |
| 207 if (!app_delegate_) { |
| 208 WebContentsDelegate::RequestMediaAccessPermission(web_contents, request, |
| 209 callback); |
| 210 return; |
| 211 } |
| 212 const ExtensionSet& enabled_extensions = |
| 213 ExtensionRegistry::Get(browser_context())->enabled_extensions(); |
| 214 const Extension* guest_extension = |
| 215 enabled_extensions.GetByID(guest_extension_id_); |
| 216 |
| 217 app_delegate_->RequestMediaAccessPermission(web_contents, request, callback, |
| 218 guest_extension); |
| 219 } |
| 220 |
| 221 bool AppViewGuest::CheckMediaAccessPermission(WebContents* web_contents, |
| 222 const GURL& security_origin, |
| 223 content::MediaStreamType type) { |
| 224 if (!app_delegate_) { |
| 225 return WebContentsDelegate::CheckMediaAccessPermission( |
| 226 web_contents, security_origin, type); |
| 227 } |
| 228 const ExtensionSet& enabled_extensions = |
| 229 ExtensionRegistry::Get(browser_context())->enabled_extensions(); |
| 230 const Extension* guest_extension = |
| 231 enabled_extensions.GetByID(guest_extension_id_); |
| 232 |
| 233 return app_delegate_->CheckMediaAccessPermission( |
| 234 web_contents, security_origin, type, guest_extension); |
| 235 } |
| 236 |
236 void AppViewGuest::CompleteCreateWebContents( | 237 void AppViewGuest::CompleteCreateWebContents( |
237 const GURL& url, | 238 const GURL& url, |
238 const Extension* guest_extension, | 239 const Extension* guest_extension, |
239 const WebContentsCreatedCallback& callback) { | 240 const WebContentsCreatedCallback& callback) { |
240 if (!url.is_valid()) { | 241 if (!url.is_valid()) { |
241 callback.Run(nullptr); | 242 callback.Run(nullptr); |
242 return; | 243 return; |
243 } | 244 } |
244 url_ = url; | 245 url_ = url; |
245 guest_extension_id_ = guest_extension->id(); | 246 guest_extension_id_ = guest_extension->id(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 280 |
280 std::vector<int> AppViewGuest::GetAllRegisteredInstanceIdsForTesting() { | 281 std::vector<int> AppViewGuest::GetAllRegisteredInstanceIdsForTesting() { |
281 std::vector<int> instances; | 282 std::vector<int> instances; |
282 for (const auto& key_value : pending_response_map.Get()) { | 283 for (const auto& key_value : pending_response_map.Get()) { |
283 instances.push_back(key_value.first); | 284 instances.push_back(key_value.first); |
284 } | 285 } |
285 return instances; | 286 return instances; |
286 } | 287 } |
287 | 288 |
288 } // namespace extensions | 289 } // namespace extensions |
OLD | NEW |