Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/webview/webview_api.h" | 5 #include "chrome/browser/extensions/api/webview/webview_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/webview.h" | 14 #include "chrome/common/extensions/api/webview.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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 } | 497 } |
| 497 | 498 |
| 498 WebviewSetPermissionFunction::~WebviewSetPermissionFunction() { | 499 WebviewSetPermissionFunction::~WebviewSetPermissionFunction() { |
| 499 } | 500 } |
| 500 | 501 |
| 501 bool WebviewSetPermissionFunction::RunAsyncSafe(WebViewGuest* guest) { | 502 bool WebviewSetPermissionFunction::RunAsyncSafe(WebViewGuest* guest) { |
| 502 scoped_ptr<webview::SetPermission::Params> params( | 503 scoped_ptr<webview::SetPermission::Params> params( |
| 503 webview::SetPermission::Params::Create(*args_)); | 504 webview::SetPermission::Params::Create(*args_)); |
| 504 EXTENSION_FUNCTION_VALIDATE(params.get()); | 505 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 505 | 506 |
| 506 WebViewGuest::PermissionResponseAction action = WebViewGuest::DEFAULT; | 507 WebViewPermissionHelper::PermissionResponseAction action = |
| 508 WebViewPermissionHelper::DEFAULT; | |
| 507 switch (params->action) { | 509 switch (params->action) { |
| 508 case Params::ACTION_ALLOW: | 510 case Params::ACTION_ALLOW: |
| 509 action = WebViewGuest::ALLOW; | 511 action = WebViewPermissionHelper::ALLOW; |
| 510 break; | 512 break; |
| 511 case Params::ACTION_DENY: | 513 case Params::ACTION_DENY: |
| 512 action = WebViewGuest::DENY; | 514 action = WebViewPermissionHelper::DENY; |
| 513 break; | 515 break; |
| 514 case Params::ACTION_DEFAULT: | 516 case Params::ACTION_DEFAULT: |
| 515 break; | 517 break; |
| 516 default: | 518 default: |
| 517 NOTREACHED(); | 519 NOTREACHED(); |
| 518 } | 520 } |
| 519 | 521 |
| 520 std::string user_input; | 522 std::string user_input; |
| 521 if (params->user_input) | 523 if (params->user_input) |
| 522 user_input = *params->user_input; | 524 user_input = *params->user_input; |
| 523 | 525 |
| 524 WebViewGuest::SetPermissionResult result = | 526 WebViewPermissionHelper::SetPermissionResult result = |
| 525 guest->SetPermission(params->request_id, action, user_input); | 527 guest->SetPermission(params->request_id, action, user_input); |
| 526 | 528 |
| 527 EXTENSION_FUNCTION_VALIDATE(result != WebViewGuest::SET_PERMISSION_INVALID); | 529 EXTENSION_FUNCTION_VALIDATE(result != |
| 530 WebViewPermissionHelper::SET_PERMISSION_INVALID); | |
|
Fady Samuel
2014/06/20 22:54:33
This is more readable:
EXTENSION_FUNCTION_VALIDAT
Xi Han
2014/06/24 13:55:32
Done.
| |
| 528 | 531 |
| 529 SetResult(base::Value::CreateBooleanValue( | 532 SetResult(base::Value::CreateBooleanValue( |
| 530 result == WebViewGuest::SET_PERMISSION_ALLOWED)); | 533 result == WebViewPermissionHelper::SET_PERMISSION_ALLOWED)); |
| 531 SendResponse(true); | 534 SendResponse(true); |
| 532 return true; | 535 return true; |
| 533 } | 536 } |
| 534 | 537 |
| 535 WebviewShowContextMenuFunction::WebviewShowContextMenuFunction() { | 538 WebviewShowContextMenuFunction::WebviewShowContextMenuFunction() { |
| 536 } | 539 } |
| 537 | 540 |
| 538 WebviewShowContextMenuFunction::~WebviewShowContextMenuFunction() { | 541 WebviewShowContextMenuFunction::~WebviewShowContextMenuFunction() { |
| 539 } | 542 } |
| 540 | 543 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 582 | 585 |
| 583 WebviewTerminateFunction::~WebviewTerminateFunction() { | 586 WebviewTerminateFunction::~WebviewTerminateFunction() { |
| 584 } | 587 } |
| 585 | 588 |
| 586 bool WebviewTerminateFunction::RunAsyncSafe(WebViewGuest* guest) { | 589 bool WebviewTerminateFunction::RunAsyncSafe(WebViewGuest* guest) { |
| 587 guest->Terminate(); | 590 guest->Terminate(); |
| 588 return true; | 591 return true; |
| 589 } | 592 } |
| 590 | 593 |
| 591 } // namespace extensions | 594 } // namespace extensions |
| OLD | NEW |