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

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

Issue 1909773002: Convert //extensions/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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 <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h"
9 #include "components/guest_view/browser/guest_view_event.h" 10 #include "components/guest_view/browser/guest_view_event.h"
10 #include "content/public/browser/render_process_host.h" 11 #include "content/public/browser/render_process_host.h"
11 #include "content/public/browser/render_view_host.h" 12 #include "content/public/browser/render_view_host.h"
12 #include "content/public/browser/user_metrics.h" 13 #include "content/public/browser/user_metrics.h"
13 #include "extensions/browser/api/extensions_api_client.h" 14 #include "extensions/browser/api/extensions_api_client.h"
14 #include "extensions/browser/guest_view/web_view/web_view_constants.h" 15 #include "extensions/browser/guest_view/web_view/web_view_constants.h"
15 #include "extensions/browser/guest_view/web_view/web_view_guest.h" 16 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
16 #include "extensions/browser/guest_view/web_view/web_view_permission_helper_dele gate.h" 17 #include "extensions/browser/guest_view/web_view/web_view_permission_helper_dele gate.h"
17 #include "extensions/browser/guest_view/web_view/web_view_permission_types.h" 18 #include "extensions/browser/guest_view/web_view/web_view_permission_types.h"
18 19
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 224 }
224 225
225 void WebViewPermissionHelper::OnMediaPermissionResponse( 226 void WebViewPermissionHelper::OnMediaPermissionResponse(
226 const content::MediaStreamRequest& request, 227 const content::MediaStreamRequest& request,
227 const content::MediaResponseCallback& callback, 228 const content::MediaResponseCallback& callback,
228 bool allow, 229 bool allow,
229 const std::string& user_input) { 230 const std::string& user_input) {
230 if (!allow) { 231 if (!allow) {
231 callback.Run(content::MediaStreamDevices(), 232 callback.Run(content::MediaStreamDevices(),
232 content::MEDIA_DEVICE_PERMISSION_DENIED, 233 content::MEDIA_DEVICE_PERMISSION_DENIED,
233 scoped_ptr<content::MediaStreamUI>()); 234 std::unique_ptr<content::MediaStreamUI>());
234 return; 235 return;
235 } 236 }
236 if (!web_view_guest()->attached() || 237 if (!web_view_guest()->attached() ||
237 !web_view_guest()->embedder_web_contents()->GetDelegate()) { 238 !web_view_guest()->embedder_web_contents()->GetDelegate()) {
238 callback.Run(content::MediaStreamDevices(), 239 callback.Run(content::MediaStreamDevices(),
239 content::MEDIA_DEVICE_INVALID_STATE, 240 content::MEDIA_DEVICE_INVALID_STATE,
240 scoped_ptr<content::MediaStreamUI>()); 241 std::unique_ptr<content::MediaStreamUI>());
241 return; 242 return;
242 } 243 }
243 244
244 web_view_guest() 245 web_view_guest()
245 ->embedder_web_contents() 246 ->embedder_web_contents()
246 ->GetDelegate() 247 ->GetDelegate()
247 ->RequestMediaAccessPermission( 248 ->RequestMediaAccessPermission(
248 web_view_guest()->embedder_web_contents(), request, callback); 249 web_view_guest()->embedder_web_contents(), request, callback);
249 } 250 }
250 251
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 base::Bind(&PermissionResponseCallback::Run, 322 base::Bind(&PermissionResponseCallback::Run,
322 base::Owned(new PermissionResponseCallback(callback)), 323 base::Owned(new PermissionResponseCallback(callback)),
323 allowed_by_default, 324 allowed_by_default,
324 std::string())); 325 std::string()));
325 return webview::kInvalidPermissionRequestID; 326 return webview::kInvalidPermissionRequestID;
326 } 327 }
327 328
328 int request_id = next_permission_request_id_++; 329 int request_id = next_permission_request_id_++;
329 pending_permission_requests_[request_id] = 330 pending_permission_requests_[request_id] =
330 PermissionResponseInfo(callback, permission_type, allowed_by_default); 331 PermissionResponseInfo(callback, permission_type, allowed_by_default);
331 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 332 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
332 args->Set(webview::kRequestInfo, request_info.DeepCopy()); 333 args->Set(webview::kRequestInfo, request_info.DeepCopy());
333 args->SetInteger(webview::kRequestId, request_id); 334 args->SetInteger(webview::kRequestId, request_id);
334 switch (permission_type) { 335 switch (permission_type) {
335 case WEB_VIEW_PERMISSION_TYPE_NEW_WINDOW: { 336 case WEB_VIEW_PERMISSION_TYPE_NEW_WINDOW: {
336 web_view_guest_->DispatchEventToView(make_scoped_ptr( 337 web_view_guest_->DispatchEventToView(base::WrapUnique(
337 new GuestViewEvent(webview::kEventNewWindow, std::move(args)))); 338 new GuestViewEvent(webview::kEventNewWindow, std::move(args))));
338 break; 339 break;
339 } 340 }
340 case WEB_VIEW_PERMISSION_TYPE_JAVASCRIPT_DIALOG: { 341 case WEB_VIEW_PERMISSION_TYPE_JAVASCRIPT_DIALOG: {
341 web_view_guest_->DispatchEventToView(make_scoped_ptr( 342 web_view_guest_->DispatchEventToView(base::WrapUnique(
342 new GuestViewEvent(webview::kEventDialog, std::move(args)))); 343 new GuestViewEvent(webview::kEventDialog, std::move(args))));
343 break; 344 break;
344 } 345 }
345 default: { 346 default: {
346 args->SetString(webview::kPermission, 347 args->SetString(webview::kPermission,
347 PermissionTypeToString(permission_type)); 348 PermissionTypeToString(permission_type));
348 web_view_guest_->DispatchEventToView(make_scoped_ptr(new GuestViewEvent( 349 web_view_guest_->DispatchEventToView(base::WrapUnique(new GuestViewEvent(
349 webview::kEventPermissionRequest, std::move(args)))); 350 webview::kEventPermissionRequest, std::move(args))));
350 break; 351 break;
351 } 352 }
352 } 353 }
353 return request_id; 354 return request_id;
354 } 355 }
355 356
356 WebViewPermissionHelper::SetPermissionResult 357 WebViewPermissionHelper::SetPermissionResult
357 WebViewPermissionHelper::SetPermission( 358 WebViewPermissionHelper::SetPermission(
358 int request_id, 359 int request_id,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 allowed_by_default(allowed_by_default) { 404 allowed_by_default(allowed_by_default) {
404 } 405 }
405 406
406 WebViewPermissionHelper::PermissionResponseInfo::PermissionResponseInfo( 407 WebViewPermissionHelper::PermissionResponseInfo::PermissionResponseInfo(
407 const PermissionResponseInfo& other) = default; 408 const PermissionResponseInfo& other) = default;
408 409
409 WebViewPermissionHelper::PermissionResponseInfo::~PermissionResponseInfo() { 410 WebViewPermissionHelper::PermissionResponseInfo::~PermissionResponseInfo() {
410 } 411 }
411 412
412 } // namespace extensions 413 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/guest_view/web_view/web_view_permission_helper.h ('k') | extensions/browser/image_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698