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

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

Issue 2360073002: [Extensions] Isolate ExtensionFunction results_ and error_ (Closed)
Patch Set: lazyboy's Created 4 years, 2 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/guid.h" 9 #include "base/guid.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 508
509 if (!params->instance_id) 509 if (!params->instance_id)
510 return RespondNow(Error(kViewInstanceIdError)); 510 return RespondNow(Error(kViewInstanceIdError));
511 511
512 GURL owner_base_url( 512 GURL owner_base_url(
513 render_frame_host()->GetSiteInstance()->GetSiteURL().GetWithEmptyPath()); 513 render_frame_host()->GetSiteInstance()->GetSiteURL().GetWithEmptyPath());
514 content::WebContents* sender_web_contents = GetSenderWebContents(); 514 content::WebContents* sender_web_contents = GetSenderWebContents();
515 HostID host_id = GenerateHostIDFromEmbedder(extension(), sender_web_contents); 515 HostID host_id = GenerateHostIDFromEmbedder(extension(), sender_web_contents);
516 bool incognito_enabled = browser_context()->IsOffTheRecord(); 516 bool incognito_enabled = browser_context()->IsOffTheRecord();
517 517
518 std::string error;
518 std::unique_ptr<UserScriptList> result = 519 std::unique_ptr<UserScriptList> result =
519 ParseContentScripts(params->content_script_list, extension(), host_id, 520 ParseContentScripts(params->content_script_list, extension(), host_id,
520 incognito_enabled, owner_base_url, &error_); 521 incognito_enabled, owner_base_url, &error);
521 if (!result) 522 if (!result)
522 return RespondNow(Error(error_)); 523 return RespondNow(Error(error));
523 524
524 WebViewContentScriptManager* manager = 525 WebViewContentScriptManager* manager =
525 WebViewContentScriptManager::Get(browser_context()); 526 WebViewContentScriptManager::Get(browser_context());
526 DCHECK(manager); 527 DCHECK(manager);
527 528
528 manager->AddContentScripts( 529 manager->AddContentScripts(
529 sender_web_contents->GetRenderProcessHost()->GetID(), render_frame_host(), 530 sender_web_contents->GetRenderProcessHost()->GetID(), render_frame_host(),
530 params->instance_id, host_id, std::move(result)); 531 params->instance_id, host_id, std::move(result));
531 532
532 return RespondNow(NoArguments()); 533 return RespondNow(NoArguments());
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 WebViewInternalLoadDataWithBaseUrlFunction::Run() { 776 WebViewInternalLoadDataWithBaseUrlFunction::Run() {
776 std::unique_ptr<web_view_internal::LoadDataWithBaseUrl::Params> params( 777 std::unique_ptr<web_view_internal::LoadDataWithBaseUrl::Params> params(
777 web_view_internal::LoadDataWithBaseUrl::Params::Create(*args_)); 778 web_view_internal::LoadDataWithBaseUrl::Params::Create(*args_));
778 EXTENSION_FUNCTION_VALIDATE(params.get()); 779 EXTENSION_FUNCTION_VALIDATE(params.get());
779 780
780 // If a virtual URL was provided, use it. Otherwise, the user will be shown 781 // If a virtual URL was provided, use it. Otherwise, the user will be shown
781 // the data URL. 782 // the data URL.
782 std::string virtual_url = 783 std::string virtual_url =
783 params->virtual_url ? *params->virtual_url : params->data_url; 784 params->virtual_url ? *params->virtual_url : params->data_url;
784 785
786 std::string error;
785 bool successful = guest_->LoadDataWithBaseURL( 787 bool successful = guest_->LoadDataWithBaseURL(
786 params->data_url, params->base_url, virtual_url, &error_); 788 params->data_url, params->base_url, virtual_url, &error);
787 if (successful) 789 if (successful)
788 return RespondNow(NoArguments()); 790 return RespondNow(NoArguments());
789 return RespondNow(Error(error_)); 791 return RespondNow(Error(error));
790 } 792 }
791 793
792 WebViewInternalGoFunction::WebViewInternalGoFunction() { 794 WebViewInternalGoFunction::WebViewInternalGoFunction() {
793 } 795 }
794 796
795 WebViewInternalGoFunction::~WebViewInternalGoFunction() { 797 WebViewInternalGoFunction::~WebViewInternalGoFunction() {
796 } 798 }
797 799
798 ExtensionFunction::ResponseAction WebViewInternalGoFunction::Run() { 800 ExtensionFunction::ResponseAction WebViewInternalGoFunction::Run() {
799 std::unique_ptr<web_view_internal::Go::Params> params( 801 std::unique_ptr<web_view_internal::Go::Params> params(
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 // Will finish asynchronously. 978 // Will finish asynchronously.
977 return true; 979 return true;
978 } 980 }
979 981
980 void WebViewInternalClearDataFunction::ClearDataDone() { 982 void WebViewInternalClearDataFunction::ClearDataDone() {
981 Release(); // Balanced in RunAsync(). 983 Release(); // Balanced in RunAsync().
982 SendResponse(true); 984 SendResponse(true);
983 } 985 }
984 986
985 } // namespace extensions 987 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/guest_view/web_view/web_view_internal_api.h ('k') | extensions/browser/api/hid/hid_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698