| 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/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" |
| 11 #include "extensions/browser/guest_view/guest_view_event.h" |
| 11 #include "extensions/browser/guest_view/web_view/web_view_constants.h" | 12 #include "extensions/browser/guest_view/web_view/web_view_constants.h" |
| 12 #include "extensions/browser/guest_view/web_view/web_view_guest.h" | 13 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
| 13 #include "extensions/browser/guest_view/web_view/web_view_permission_helper_dele
gate.h" | 14 #include "extensions/browser/guest_view/web_view/web_view_permission_helper_dele
gate.h" |
| 14 #include "extensions/browser/guest_view/web_view/web_view_permission_types.h" | 15 #include "extensions/browser/guest_view/web_view/web_view_permission_types.h" |
| 15 | 16 |
| 16 using content::BrowserPluginGuestDelegate; | 17 using content::BrowserPluginGuestDelegate; |
| 17 using content::RenderViewHost; | 18 using content::RenderViewHost; |
| 18 | 19 |
| 19 namespace extensions { | 20 namespace extensions { |
| 20 | 21 |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 } | 324 } |
| 324 | 325 |
| 325 int request_id = next_permission_request_id_++; | 326 int request_id = next_permission_request_id_++; |
| 326 pending_permission_requests_[request_id] = | 327 pending_permission_requests_[request_id] = |
| 327 PermissionResponseInfo(callback, permission_type, allowed_by_default); | 328 PermissionResponseInfo(callback, permission_type, allowed_by_default); |
| 328 scoped_ptr<base::DictionaryValue> args(request_info.DeepCopy()); | 329 scoped_ptr<base::DictionaryValue> args(request_info.DeepCopy()); |
| 329 args->SetInteger(webview::kRequestId, request_id); | 330 args->SetInteger(webview::kRequestId, request_id); |
| 330 switch (permission_type) { | 331 switch (permission_type) { |
| 331 case WEB_VIEW_PERMISSION_TYPE_NEW_WINDOW: { | 332 case WEB_VIEW_PERMISSION_TYPE_NEW_WINDOW: { |
| 332 web_view_guest_->DispatchEventToView( | 333 web_view_guest_->DispatchEventToView( |
| 333 new GuestViewBase::Event(webview::kEventNewWindow, args.Pass())); | 334 new GuestViewEvent(web_view_guest_, |
| 335 webview::kEventNewWindow, |
| 336 args.Pass())); |
| 334 break; | 337 break; |
| 335 } | 338 } |
| 336 case WEB_VIEW_PERMISSION_TYPE_JAVASCRIPT_DIALOG: { | 339 case WEB_VIEW_PERMISSION_TYPE_JAVASCRIPT_DIALOG: { |
| 337 web_view_guest_->DispatchEventToView( | 340 web_view_guest_->DispatchEventToView( |
| 338 new GuestViewBase::Event(webview::kEventDialog, args.Pass())); | 341 new GuestViewEvent(web_view_guest_, |
| 342 webview::kEventDialog, |
| 343 args.Pass())); |
| 339 break; | 344 break; |
| 340 } | 345 } |
| 341 default: { | 346 default: { |
| 342 args->SetString(webview::kPermission, | 347 args->SetString(webview::kPermission, |
| 343 PermissionTypeToString(permission_type)); | 348 PermissionTypeToString(permission_type)); |
| 344 web_view_guest_->DispatchEventToView(new GuestViewBase::Event( | 349 web_view_guest_->DispatchEventToView(new GuestViewEvent( |
| 345 webview::kEventPermissionRequest, args.Pass())); | 350 web_view_guest_, webview::kEventPermissionRequest, args.Pass())); |
| 346 break; | 351 break; |
| 347 } | 352 } |
| 348 } | 353 } |
| 349 return request_id; | 354 return request_id; |
| 350 } | 355 } |
| 351 | 356 |
| 352 WebViewPermissionHelper::SetPermissionResult | 357 WebViewPermissionHelper::SetPermissionResult |
| 353 WebViewPermissionHelper::SetPermission( | 358 WebViewPermissionHelper::SetPermission( |
| 354 int request_id, | 359 int request_id, |
| 355 PermissionResponseAction action, | 360 PermissionResponseAction action, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 bool allowed_by_default) | 401 bool allowed_by_default) |
| 397 : callback(callback), | 402 : callback(callback), |
| 398 permission_type(permission_type), | 403 permission_type(permission_type), |
| 399 allowed_by_default(allowed_by_default) { | 404 allowed_by_default(allowed_by_default) { |
| 400 } | 405 } |
| 401 | 406 |
| 402 WebViewPermissionHelper::PermissionResponseInfo::~PermissionResponseInfo() { | 407 WebViewPermissionHelper::PermissionResponseInfo::~PermissionResponseInfo() { |
| 403 } | 408 } |
| 404 | 409 |
| 405 } // namespace extensions | 410 } // namespace extensions |
| OLD | NEW |