Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: extensions/browser/guest_view/web_view/web_view_permission_helper.cc

Issue 574793003: Moving webview media permission request to extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switching to weak ptrs Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/web_view/web_view_permission_helper.h" 5 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h"
6 6
7 #include "content/public/browser/render_process_host.h" 7 #include "content/public/browser/render_process_host.h"
8 #include "content/public/browser/render_view_host.h" 8 #include "content/public/browser/render_view_host.h"
9 #include "content/public/browser/user_metrics.h" 9 #include "content/public/browser/user_metrics.h"
10 #include "extensions/browser/api/extensions_api_client.h" 10 #include "extensions/browser/api/extensions_api_client.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 bool WebViewPermissionHelper::OnMessageReceived(const IPC::Message& message) { 174 bool WebViewPermissionHelper::OnMessageReceived(const IPC::Message& message) {
175 return web_view_permission_helper_delegate_->OnMessageReceived(message); 175 return web_view_permission_helper_delegate_->OnMessageReceived(message);
176 } 176 }
177 #endif // defined(ENABLE_PLUGINS) 177 #endif // defined(ENABLE_PLUGINS)
178 178
179 void WebViewPermissionHelper::RequestMediaAccessPermission( 179 void WebViewPermissionHelper::RequestMediaAccessPermission(
180 content::WebContents* source, 180 content::WebContents* source,
181 const content::MediaStreamRequest& request, 181 const content::MediaStreamRequest& request,
182 const content::MediaResponseCallback& callback) { 182 const content::MediaResponseCallback& callback) {
183 web_view_permission_helper_delegate_->RequestMediaAccessPermission( 183 base::DictionaryValue request_info;
184 source, request, callback); 184 request_info.SetString(guestview::kUrl, request.security_origin.spec());
185 RequestPermission(
186 WEB_VIEW_PERMISSION_TYPE_MEDIA,
187 request_info,
188 base::Bind(&WebViewPermissionHelper::OnMediaPermissionResponse,
189 weak_factory_.GetWeakPtr(),
190 request,
191 callback),
192 false /* allowed_by_default */);
185 } 193 }
186 194
187 bool WebViewPermissionHelper::CheckMediaAccessPermission( 195 bool WebViewPermissionHelper::CheckMediaAccessPermission(
188 content::WebContents* source, 196 content::WebContents* source,
189 const GURL& security_origin, 197 const GURL& security_origin,
190 content::MediaStreamType type) { 198 content::MediaStreamType type) {
191 return web_view_permission_helper_delegate_->CheckMediaAccessPermission( 199 return web_view_guest()
192 source, security_origin, type); 200 ->embedder_web_contents()
201 ->GetDelegate()
202 ->CheckMediaAccessPermission(
203 web_view_guest()->embedder_web_contents(), security_origin, type);
204 }
205
206 void WebViewPermissionHelper::OnMediaPermissionResponse(
207 const content::MediaStreamRequest& request,
208 const content::MediaResponseCallback& callback,
209 bool allow,
210 const std::string& user_input) {
211 if (!allow || !web_view_guest()->attached()) {
212 // Deny the request.
213 callback.Run(content::MediaStreamDevices(),
214 content::MEDIA_DEVICE_INVALID_STATE,
215 scoped_ptr<content::MediaStreamUI>());
216 return;
217 }
218 if (!web_view_guest()->embedder_web_contents()->GetDelegate())
219 return;
220
221 web_view_guest()
222 ->embedder_web_contents()
223 ->GetDelegate()
224 ->RequestMediaAccessPermission(
225 web_view_guest()->embedder_web_contents(), request, callback);
193 } 226 }
194 227
195 void WebViewPermissionHelper::CanDownload( 228 void WebViewPermissionHelper::CanDownload(
196 content::RenderViewHost* render_view_host, 229 content::RenderViewHost* render_view_host,
197 const GURL& url, 230 const GURL& url,
198 const std::string& request_method, 231 const std::string& request_method,
199 const base::Callback<void(bool)>& callback) { 232 const base::Callback<void(bool)>& callback) {
200 web_view_permission_helper_delegate_->CanDownload( 233 web_view_permission_helper_delegate_->CanDownload(
201 render_view_host, url, request_method, callback); 234 render_view_host, url, request_method, callback);
202 } 235 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 bool allowed_by_default) 379 bool allowed_by_default)
347 : callback(callback), 380 : callback(callback),
348 permission_type(permission_type), 381 permission_type(permission_type),
349 allowed_by_default(allowed_by_default) { 382 allowed_by_default(allowed_by_default) {
350 } 383 }
351 384
352 WebViewPermissionHelper::PermissionResponseInfo::~PermissionResponseInfo() { 385 WebViewPermissionHelper::PermissionResponseInfo::~PermissionResponseInfo() {
353 } 386 }
354 387
355 } // namespace extensions 388 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698