| 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 "chrome/browser/extensions/api/web_view/web_view_internal_api.h" | 5 #include "chrome/browser/extensions/api/web_view/web_view_internal_api.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h" | 8 #include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h" |
| 9 #include "chrome/browser/extensions/api/context_menus/context_menus_api.h" | 9 #include "chrome/browser/extensions/api/context_menus/context_menus_api.h" |
| 10 #include "chrome/browser/extensions/api/context_menus/context_menus_api_helpers.
h" | 10 #include "chrome/browser/extensions/api/context_menus/context_menus_api_helpers.
h" |
| 11 #include "chrome/browser/extensions/tab_helper.h" | 11 #include "chrome/browser/extensions/tab_helper.h" |
| 12 #include "chrome/browser/guest_view/web_view/web_view_permission_helper.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/common/extensions/api/web_view_internal.h" | 14 #include "chrome/common/extensions/api/web_view_internal.h" |
| 14 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
| 15 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
| 16 #include "content/public/browser/storage_partition.h" | 17 #include "content/public/browser/storage_partition.h" |
| 17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/common/stop_find_action.h" | 19 #include "content/public/common/stop_find_action.h" |
| 19 #include "extensions/common/error_utils.h" | 20 #include "extensions/common/error_utils.h" |
| 20 #include "third_party/WebKit/public/web/WebFindOptions.h" | 21 #include "third_party/WebKit/public/web/WebFindOptions.h" |
| 21 | 22 |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 } | 499 } |
| 499 | 500 |
| 500 WebViewInternalSetPermissionFunction::~WebViewInternalSetPermissionFunction() { | 501 WebViewInternalSetPermissionFunction::~WebViewInternalSetPermissionFunction() { |
| 501 } | 502 } |
| 502 | 503 |
| 503 bool WebViewInternalSetPermissionFunction::RunAsyncSafe(WebViewGuest* guest) { | 504 bool WebViewInternalSetPermissionFunction::RunAsyncSafe(WebViewGuest* guest) { |
| 504 scoped_ptr<webview::SetPermission::Params> params( | 505 scoped_ptr<webview::SetPermission::Params> params( |
| 505 webview::SetPermission::Params::Create(*args_)); | 506 webview::SetPermission::Params::Create(*args_)); |
| 506 EXTENSION_FUNCTION_VALIDATE(params.get()); | 507 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 507 | 508 |
| 508 WebViewGuest::PermissionResponseAction action = WebViewGuest::DEFAULT; | 509 WebViewPermissionHelper::PermissionResponseAction action = |
| 510 WebViewPermissionHelper::DEFAULT; |
| 509 switch (params->action) { | 511 switch (params->action) { |
| 510 case Params::ACTION_ALLOW: | 512 case Params::ACTION_ALLOW: |
| 511 action = WebViewGuest::ALLOW; | 513 action = WebViewPermissionHelper::ALLOW; |
| 512 break; | 514 break; |
| 513 case Params::ACTION_DENY: | 515 case Params::ACTION_DENY: |
| 514 action = WebViewGuest::DENY; | 516 action = WebViewPermissionHelper::DENY; |
| 515 break; | 517 break; |
| 516 case Params::ACTION_DEFAULT: | 518 case Params::ACTION_DEFAULT: |
| 517 break; | 519 break; |
| 518 default: | 520 default: |
| 519 NOTREACHED(); | 521 NOTREACHED(); |
| 520 } | 522 } |
| 521 | 523 |
| 522 std::string user_input; | 524 std::string user_input; |
| 523 if (params->user_input) | 525 if (params->user_input) |
| 524 user_input = *params->user_input; | 526 user_input = *params->user_input; |
| 525 | 527 |
| 526 WebViewGuest::SetPermissionResult result = | 528 WebViewPermissionHelper* web_view_permission_helper = |
| 527 guest->SetPermission(params->request_id, action, user_input); | 529 WebViewPermissionHelper:: FromWebContents(guest->guest_web_contents()); |
| 528 | 530 |
| 529 EXTENSION_FUNCTION_VALIDATE(result != WebViewGuest::SET_PERMISSION_INVALID); | 531 WebViewPermissionHelper::SetPermissionResult result = |
| 532 web_view_permission_helper->SetPermission( |
| 533 params->request_id, action, user_input); |
| 534 |
| 535 EXTENSION_FUNCTION_VALIDATE( |
| 536 result != WebViewPermissionHelper::SET_PERMISSION_INVALID); |
| 530 | 537 |
| 531 SetResult(base::Value::CreateBooleanValue( | 538 SetResult(base::Value::CreateBooleanValue( |
| 532 result == WebViewGuest::SET_PERMISSION_ALLOWED)); | 539 result == WebViewPermissionHelper::SET_PERMISSION_ALLOWED)); |
| 533 SendResponse(true); | 540 SendResponse(true); |
| 534 return true; | 541 return true; |
| 535 } | 542 } |
| 536 | 543 |
| 537 WebViewInternalShowContextMenuFunction:: | 544 WebViewInternalShowContextMenuFunction:: |
| 538 WebViewInternalShowContextMenuFunction() { | 545 WebViewInternalShowContextMenuFunction() { |
| 539 } | 546 } |
| 540 | 547 |
| 541 WebViewInternalShowContextMenuFunction:: | 548 WebViewInternalShowContextMenuFunction:: |
| 542 ~WebViewInternalShowContextMenuFunction() { | 549 ~WebViewInternalShowContextMenuFunction() { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 | 596 |
| 590 WebViewInternalTerminateFunction::~WebViewInternalTerminateFunction() { | 597 WebViewInternalTerminateFunction::~WebViewInternalTerminateFunction() { |
| 591 } | 598 } |
| 592 | 599 |
| 593 bool WebViewInternalTerminateFunction::RunAsyncSafe(WebViewGuest* guest) { | 600 bool WebViewInternalTerminateFunction::RunAsyncSafe(WebViewGuest* guest) { |
| 594 guest->Terminate(); | 601 guest->Terminate(); |
| 595 return true; | 602 return true; |
| 596 } | 603 } |
| 597 | 604 |
| 598 } // namespace extensions | 605 } // namespace extensions |
| OLD | NEW |