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

Side by Side Diff: extensions/browser/api/guest_view/web_view/web_view_internal_api.cc

Issue 1991083002: Remove ExtensionFunction::SetResult(T*) overload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: IWYU Created 4 years, 7 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/api/guest_view/web_view/web_view_internal_api.h" 5 #include "extensions/browser/api/guest_view/web_view/web_view_internal_api.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h"
9 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "content/public/browser/browser_context.h" 13 #include "content/public/browser/browser_context.h"
13 #include "content/public/browser/render_frame_host.h" 14 #include "content/public/browser/render_frame_host.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/web_contents.h" 17 #include "content/public/browser/web_contents.h"
17 #include "content/public/common/stop_find_action.h" 18 #include "content/public/common/stop_find_action.h"
18 #include "content/public/common/url_fetcher.h" 19 #include "content/public/common/url_fetcher.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 294 }
294 295
295 void WebViewInternalCaptureVisibleRegionFunction::OnCaptureSuccess( 296 void WebViewInternalCaptureVisibleRegionFunction::OnCaptureSuccess(
296 const SkBitmap& bitmap) { 297 const SkBitmap& bitmap) {
297 std::string base64_result; 298 std::string base64_result;
298 if (!EncodeBitmap(bitmap, &base64_result)) { 299 if (!EncodeBitmap(bitmap, &base64_result)) {
299 OnCaptureFailure(FAILURE_REASON_ENCODING_FAILED); 300 OnCaptureFailure(FAILURE_REASON_ENCODING_FAILED);
300 return; 301 return;
301 } 302 }
302 303
303 SetResult(new base::StringValue(base64_result)); 304 SetResult(base::MakeUnique<base::StringValue>(base64_result));
304 SendResponse(true); 305 SendResponse(true);
305 } 306 }
306 307
307 void WebViewInternalCaptureVisibleRegionFunction::OnCaptureFailure( 308 void WebViewInternalCaptureVisibleRegionFunction::OnCaptureFailure(
308 FailureReason reason) { 309 FailureReason reason) {
309 const char* reason_description = "internal error"; 310 const char* reason_description = "internal error";
310 switch (reason) { 311 switch (reason) {
311 case FAILURE_REASON_UNKNOWN: 312 case FAILURE_REASON_UNKNOWN:
312 reason_description = "unknown error"; 313 reason_description = "unknown error";
313 break; 314 break;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 } 448 }
448 449
449 WebViewInternalExecuteScriptFunction::WebViewInternalExecuteScriptFunction() { 450 WebViewInternalExecuteScriptFunction::WebViewInternalExecuteScriptFunction() {
450 } 451 }
451 452
452 void WebViewInternalExecuteScriptFunction::OnExecuteCodeFinished( 453 void WebViewInternalExecuteScriptFunction::OnExecuteCodeFinished(
453 const std::string& error, 454 const std::string& error,
454 const GURL& on_url, 455 const GURL& on_url,
455 const base::ListValue& result) { 456 const base::ListValue& result) {
456 if (error.empty()) 457 if (error.empty())
457 SetResult(result.DeepCopy()); 458 SetResult(result.CreateDeepCopy());
458 WebViewInternalExecuteCodeFunction::OnExecuteCodeFinished( 459 WebViewInternalExecuteCodeFunction::OnExecuteCodeFinished(
459 error, on_url, result); 460 error, on_url, result);
460 } 461 }
461 462
462 WebViewInternalInsertCSSFunction::WebViewInternalInsertCSSFunction() { 463 WebViewInternalInsertCSSFunction::WebViewInternalInsertCSSFunction() {
463 } 464 }
464 465
465 bool WebViewInternalInsertCSSFunction::ShouldInsertCSS() const { 466 bool WebViewInternalInsertCSSFunction::ShouldInsertCSS() const {
466 return true; 467 return true;
467 } 468 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 611
611 WebViewInternalGetZoomFunction::~WebViewInternalGetZoomFunction() { 612 WebViewInternalGetZoomFunction::~WebViewInternalGetZoomFunction() {
612 } 613 }
613 614
614 bool WebViewInternalGetZoomFunction::RunAsyncSafe(WebViewGuest* guest) { 615 bool WebViewInternalGetZoomFunction::RunAsyncSafe(WebViewGuest* guest) {
615 std::unique_ptr<web_view_internal::GetZoom::Params> params( 616 std::unique_ptr<web_view_internal::GetZoom::Params> params(
616 web_view_internal::GetZoom::Params::Create(*args_)); 617 web_view_internal::GetZoom::Params::Create(*args_));
617 EXTENSION_FUNCTION_VALIDATE(params.get()); 618 EXTENSION_FUNCTION_VALIDATE(params.get());
618 619
619 double zoom_factor = guest->GetZoom(); 620 double zoom_factor = guest->GetZoom();
620 SetResult(new base::FundamentalValue(zoom_factor)); 621 SetResult(base::MakeUnique<base::FundamentalValue>(zoom_factor));
621 SendResponse(true); 622 SendResponse(true);
622 return true; 623 return true;
623 } 624 }
624 625
625 WebViewInternalSetZoomModeFunction::WebViewInternalSetZoomModeFunction() { 626 WebViewInternalSetZoomModeFunction::WebViewInternalSetZoomModeFunction() {
626 } 627 }
627 628
628 WebViewInternalSetZoomModeFunction::~WebViewInternalSetZoomModeFunction() { 629 WebViewInternalSetZoomModeFunction::~WebViewInternalSetZoomModeFunction() {
629 } 630 }
630 631
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 case ZoomController::ZOOM_MODE_ISOLATED: 674 case ZoomController::ZOOM_MODE_ISOLATED:
674 zoom_mode = web_view_internal::ZOOM_MODE_PER_VIEW; 675 zoom_mode = web_view_internal::ZOOM_MODE_PER_VIEW;
675 break; 676 break;
676 case ZoomController::ZOOM_MODE_DISABLED: 677 case ZoomController::ZOOM_MODE_DISABLED:
677 zoom_mode = web_view_internal::ZOOM_MODE_DISABLED; 678 zoom_mode = web_view_internal::ZOOM_MODE_DISABLED;
678 break; 679 break;
679 default: 680 default:
680 NOTREACHED(); 681 NOTREACHED();
681 } 682 }
682 683
683 SetResult(new base::StringValue(web_view_internal::ToString(zoom_mode))); 684 SetResult(base::MakeUnique<base::StringValue>(
685 web_view_internal::ToString(zoom_mode)));
684 SendResponse(true); 686 SendResponse(true);
685 return true; 687 return true;
686 } 688 }
687 689
688 WebViewInternalFindFunction::WebViewInternalFindFunction() { 690 WebViewInternalFindFunction::WebViewInternalFindFunction() {
689 } 691 }
690 692
691 WebViewInternalFindFunction::~WebViewInternalFindFunction() { 693 WebViewInternalFindFunction::~WebViewInternalFindFunction() {
692 } 694 }
693 695
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 777
776 WebViewInternalGoFunction::~WebViewInternalGoFunction() { 778 WebViewInternalGoFunction::~WebViewInternalGoFunction() {
777 } 779 }
778 780
779 bool WebViewInternalGoFunction::RunAsyncSafe(WebViewGuest* guest) { 781 bool WebViewInternalGoFunction::RunAsyncSafe(WebViewGuest* guest) {
780 std::unique_ptr<web_view_internal::Go::Params> params( 782 std::unique_ptr<web_view_internal::Go::Params> params(
781 web_view_internal::Go::Params::Create(*args_)); 783 web_view_internal::Go::Params::Create(*args_));
782 EXTENSION_FUNCTION_VALIDATE(params.get()); 784 EXTENSION_FUNCTION_VALIDATE(params.get());
783 785
784 bool successful = guest->Go(params->relative_index); 786 bool successful = guest->Go(params->relative_index);
785 SetResult(new base::FundamentalValue(successful)); 787 SetResult(base::MakeUnique<base::FundamentalValue>(successful));
786 SendResponse(true); 788 SendResponse(true);
787 return true; 789 return true;
788 } 790 }
789 791
790 WebViewInternalReloadFunction::WebViewInternalReloadFunction() { 792 WebViewInternalReloadFunction::WebViewInternalReloadFunction() {
791 } 793 }
792 794
793 WebViewInternalReloadFunction::~WebViewInternalReloadFunction() { 795 WebViewInternalReloadFunction::~WebViewInternalReloadFunction() {
794 } 796 }
795 797
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 WebViewPermissionHelper* web_view_permission_helper = 833 WebViewPermissionHelper* web_view_permission_helper =
832 WebViewPermissionHelper::FromWebContents(guest->web_contents()); 834 WebViewPermissionHelper::FromWebContents(guest->web_contents());
833 835
834 WebViewPermissionHelper::SetPermissionResult result = 836 WebViewPermissionHelper::SetPermissionResult result =
835 web_view_permission_helper->SetPermission( 837 web_view_permission_helper->SetPermission(
836 params->request_id, action, user_input); 838 params->request_id, action, user_input);
837 839
838 EXTENSION_FUNCTION_VALIDATE(result != 840 EXTENSION_FUNCTION_VALIDATE(result !=
839 WebViewPermissionHelper::SET_PERMISSION_INVALID); 841 WebViewPermissionHelper::SET_PERMISSION_INVALID);
840 842
841 SetResult(new base::FundamentalValue( 843 SetResult(base::MakeUnique<base::FundamentalValue>(
842 result == WebViewPermissionHelper::SET_PERMISSION_ALLOWED)); 844 result == WebViewPermissionHelper::SET_PERMISSION_ALLOWED));
843 SendResponse(true); 845 SendResponse(true);
844 return true; 846 return true;
845 } 847 }
846 848
847 WebViewInternalOverrideUserAgentFunction:: 849 WebViewInternalOverrideUserAgentFunction::
848 WebViewInternalOverrideUserAgentFunction() { 850 WebViewInternalOverrideUserAgentFunction() {
849 } 851 }
850 852
851 WebViewInternalOverrideUserAgentFunction:: 853 WebViewInternalOverrideUserAgentFunction::
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 // Will finish asynchronously. 962 // Will finish asynchronously.
961 return true; 963 return true;
962 } 964 }
963 965
964 void WebViewInternalClearDataFunction::ClearDataDone() { 966 void WebViewInternalClearDataFunction::ClearDataDone() {
965 Release(); // Balanced in RunAsync(). 967 Release(); // Balanced in RunAsync().
966 SendResponse(true); 968 SendResponse(true);
967 } 969 }
968 970
969 } // namespace extensions 971 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698