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

Side by Side Diff: extensions/browser/script_executor.cc

Issue 2978953002: [Extensions] Don't allow content scripts on the New Tab Page (Closed)
Patch Set: Karan's Created 3 years, 5 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/script_executor.h" 5 #include "extensions/browser/script_executor.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 int request_id, 128 int request_id,
129 const std::string& error, 129 const std::string& error,
130 const GURL& on_url, 130 const GURL& on_url,
131 const base::ListValue& result_list) { 131 const base::ListValue& result_list) {
132 DCHECK_EQ(request_id_, request_id); 132 DCHECK_EQ(request_id_, request_id);
133 DCHECK(!pending_render_frames_.empty()); 133 DCHECK(!pending_render_frames_.empty());
134 bool erased = pending_render_frames_.erase(render_frame_host) == 1; 134 bool erased = pending_render_frames_.erase(render_frame_host) == 1;
135 DCHECK(erased); 135 DCHECK(erased);
136 bool is_root_frame = root_rfh_ == render_frame_host; 136 bool is_root_frame = root_rfh_ == render_frame_host;
137 137
138 LOG(WARNING) << "Done: " << error << ", " << on_url;
karandeepb 2017/07/18 21:06:26 Remove logging in this file as well.
Devlin 2017/07/18 21:12:49 D'oh. Don't know how I missed so many on this CL.
139
138 // Set the result, if there is one. 140 // Set the result, if there is one.
139 const base::Value* script_value = nullptr; 141 const base::Value* script_value = nullptr;
140 if (result_list.Get(0u, &script_value)) { 142 if (result_list.Get(0u, &script_value)) {
141 // If this is the main result, we put it at index 0. Otherwise, we just 143 // If this is the main result, we put it at index 0. Otherwise, we just
142 // append it at the end. 144 // append it at the end.
143 if (is_root_frame && !results_.empty()) 145 if (is_root_frame && !results_.empty())
144 CHECK(results_.Insert(0u, script_value->CreateDeepCopy())); 146 CHECK(results_.Insert(0u, script_value->CreateDeepCopy()));
145 else 147 else
146 results_.Append(script_value->CreateDeepCopy()); 148 results_.Append(script_value->CreateDeepCopy());
147 } 149 }
148 150
149 if (is_root_frame) { // Only use the root frame's error and url. 151 if (is_root_frame) { // Only use the root frame's error and url.
150 root_frame_error_ = error; 152 root_frame_error_ = error;
151 root_frame_url_ = on_url; 153 root_frame_url_ = on_url;
152 } 154 }
153 155
154 // Wait until the final request finishes before reporting back. 156 // Wait until the final request finishes before reporting back.
155 if (pending_render_frames_.empty()) 157 if (pending_render_frames_.empty())
156 Finish(); 158 Finish();
157 } 159 }
158 160
159 void Finish() { 161 void Finish() {
160 if (root_frame_url_.is_empty()) { 162 if (root_frame_url_.is_empty()) {
163 LOG(WARNING) << "Failed: " << root_frame_error_;
161 // We never finished the root frame injection. 164 // We never finished the root frame injection.
162 root_frame_error_ = 165 root_frame_error_ =
163 root_is_main_frame_ ? kRendererDestroyed : kFrameRemoved; 166 root_is_main_frame_ ? kRendererDestroyed : kFrameRemoved;
167 LOG(WARNING) << "New: " << root_frame_error_;
164 results_.Clear(); 168 results_.Clear();
165 } 169 }
166 170
167 if (script_observers_.get() && root_frame_error_.empty() && 171 if (script_observers_.get() && root_frame_error_.empty() &&
168 host_id_.type() == HostID::EXTENSIONS) { 172 host_id_.type() == HostID::EXTENSIONS) {
169 ScriptExecutionObserver::ExecutingScriptsMap id_map; 173 ScriptExecutionObserver::ExecutingScriptsMap id_map;
170 id_map[host_id_.id()] = std::set<std::string>(); 174 id_map[host_id_.id()] = std::set<std::string>();
171 for (auto& observer : *script_observers_) 175 for (auto& observer : *script_observers_)
172 observer.OnScriptsExecuted(web_contents(), id_map, root_frame_url_); 176 observer.OnScriptsExecuted(web_contents(), id_map, root_frame_url_);
173 } 177 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 params.file_url = file_url; 272 params.file_url = file_url;
269 params.wants_result = (result_type == JSON_SERIALIZED_RESULT); 273 params.wants_result = (result_type == JSON_SERIALIZED_RESULT);
270 params.user_gesture = user_gesture; 274 params.user_gesture = user_gesture;
271 275
272 // Handler handles IPCs and deletes itself on completion. 276 // Handler handles IPCs and deletes itself on completion.
273 new Handler(script_observers_, web_contents_, params, frame_scope, frame_id, 277 new Handler(script_observers_, web_contents_, params, frame_scope, frame_id,
274 callback); 278 callback);
275 } 279 }
276 280
277 } // namespace extensions 281 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/content_scripts/ntp/script.js ('k') | extensions/common/manifest_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698