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

Side by Side Diff: extensions/renderer/programmatic_script_injector.cc

Issue 945743003: Improve error message for failing code insertion on about:-URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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/renderer/programmatic_script_injector.h" 5 #include "extensions/renderer/programmatic_script_injector.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "content/public/common/url_constants.h"
10 #include "content/public/renderer/render_view.h" 11 #include "content/public/renderer/render_view.h"
11 #include "extensions/common/error_utils.h" 12 #include "extensions/common/error_utils.h"
12 #include "extensions/common/extension_messages.h" 13 #include "extensions/common/extension_messages.h"
13 #include "extensions/common/manifest_constants.h" 14 #include "extensions/common/manifest_constants.h"
14 #include "extensions/common/permissions/permissions_data.h" 15 #include "extensions/common/permissions/permissions_data.h"
15 #include "extensions/renderer/injection_host.h" 16 #include "extensions/renderer/injection_host.h"
16 #include "extensions/renderer/script_context.h" 17 #include "extensions/renderer/script_context.h"
17 #include "third_party/WebKit/public/platform/WebString.h" 18 #include "third_party/WebKit/public/platform/WebString.h"
18 #include "third_party/WebKit/public/web/WebDocument.h" 19 #include "third_party/WebKit/public/web/WebDocument.h"
19 #include "third_party/WebKit/public/web/WebFrame.h" 20 #include "third_party/WebKit/public/web/WebFrame.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 ScriptsRunInfo* scripts_run_info, 112 ScriptsRunInfo* scripts_run_info,
112 UserScript::RunLocation run_location) { 113 UserScript::RunLocation run_location) {
113 results_ = execution_results.Pass(); 114 results_ = execution_results.Pass();
114 Finish(std::string()); 115 Finish(std::string());
115 } 116 }
116 117
117 void ProgrammaticScriptInjector::OnWillNotInject(InjectFailureReason reason) { 118 void ProgrammaticScriptInjector::OnWillNotInject(InjectFailureReason reason) {
118 std::string error; 119 std::string error;
119 switch (reason) { 120 switch (reason) {
120 case NOT_ALLOWED: 121 case NOT_ALLOWED:
121 error = ErrorUtils::FormatErrorMessage(manifest_errors::kCannotAccessPage, 122 if (url_.SchemeIs(url::kAboutScheme)) {
122 url_.spec()); 123 error = ErrorUtils::FormatErrorMessage(
124 manifest_errors::kCannotAccessAboutUrl, url_.spec());
125 } else {
126 error = ErrorUtils::FormatErrorMessage(
127 manifest_errors::kCannotAccessPage, url_.spec());
128 }
123 break; 129 break;
124 case EXTENSION_REMOVED: // no special error here. 130 case EXTENSION_REMOVED: // no special error here.
125 case WONT_INJECT: 131 case WONT_INJECT:
126 break; 132 break;
127 } 133 }
128 Finish(error); 134 Finish(error);
129 } 135 }
130 136
131 UserScript::RunLocation ProgrammaticScriptInjector::GetRunLocation() const { 137 UserScript::RunLocation ProgrammaticScriptInjector::GetRunLocation() const {
132 return static_cast<UserScript::RunLocation>(params_->run_at); 138 return static_cast<UserScript::RunLocation>(params_->run_at);
133 } 139 }
134 140
135 void ProgrammaticScriptInjector::Finish(const std::string& error) { 141 void ProgrammaticScriptInjector::Finish(const std::string& error) {
136 DCHECK(!finished_); 142 DCHECK(!finished_);
137 finished_ = true; 143 finished_ = true;
138 144
139 render_view_->Send(new ExtensionHostMsg_ExecuteCodeFinished( 145 render_view_->Send(new ExtensionHostMsg_ExecuteCodeFinished(
140 render_view_->GetRoutingID(), 146 render_view_->GetRoutingID(),
141 params_->request_id, 147 params_->request_id,
142 error, 148 error,
143 url_, 149 url_,
144 *results_)); 150 *results_));
145 } 151 }
146 152
147 } // namespace extensions 153 } // namespace extensions
OLDNEW
« extensions/common/manifest_constants.cc ('K') | « extensions/common/manifest_constants.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698