OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/extensions/user_script_scheduler.h" | 5 #include "chrome/renderer/extensions/user_script_scheduler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "chrome/renderer/chrome_render_process_observer.h" | 10 #include "chrome/renderer/chrome_render_process_observer.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 frame_vector.push_back(frame_); | 164 frame_vector.push_back(frame_); |
165 if (params.all_frames) | 165 if (params.all_frames) |
166 GetAllChildFrames(frame_, &frame_vector); | 166 GetAllChildFrames(frame_, &frame_vector); |
167 | 167 |
168 std::string error; | 168 std::string error; |
169 | 169 |
170 scoped_ptr<blink::WebScopedUserGesture> gesture; | 170 scoped_ptr<blink::WebScopedUserGesture> gesture; |
171 if (params.user_gesture) | 171 if (params.user_gesture) |
172 gesture.reset(new blink::WebScopedUserGesture); | 172 gesture.reset(new blink::WebScopedUserGesture); |
173 | 173 |
| 174 GURL top_url = frame_->document().url(); |
| 175 |
174 for (std::vector<WebFrame*>::iterator frame_it = frame_vector.begin(); | 176 for (std::vector<WebFrame*>::iterator frame_it = frame_vector.begin(); |
175 frame_it != frame_vector.end(); ++frame_it) { | 177 frame_it != frame_vector.end(); ++frame_it) { |
176 WebFrame* child_frame = *frame_it; | 178 WebFrame* child_frame = *frame_it; |
| 179 CHECK(child_frame) << top_url; |
| 180 |
177 // We recheck access here in the renderer for extra safety against races | 181 // We recheck access here in the renderer for extra safety against races |
178 // with navigation. | 182 // with navigation. |
179 // | 183 // |
180 // But different frames can have different URLs, and the extension might | 184 // But different frames can have different URLs, and the extension might |
181 // only have access to a subset of them. For the top frame, we can | 185 // only have access to a subset of them. For the top frame, we can |
182 // immediately send an error and stop because the browser process | 186 // immediately send an error and stop because the browser process |
183 // considers that an error too. | 187 // considers that an error too. |
184 // | 188 // |
185 // For child frames, we just skip ones the extension doesn't have access | 189 // For child frames, we just skip ones the extension doesn't have access |
186 // to and carry on. | 190 // to and carry on. |
187 if (!params.is_web_view && | 191 if (!params.is_web_view && |
188 !PermissionsData::CanExecuteScriptOnPage(extension, | 192 !PermissionsData::CanExecuteScriptOnPage(extension, |
189 child_frame->document().url(), | 193 child_frame->document().url(), |
190 frame_->document().url(), | 194 top_url, |
191 extension_helper->tab_id(), | 195 extension_helper->tab_id(), |
192 NULL, | 196 NULL, |
193 -1, | 197 -1, |
194 NULL)) { | 198 NULL)) { |
195 if (child_frame->parent()) { | 199 if (child_frame->parent()) { |
196 continue; | 200 continue; |
197 } else { | 201 } else { |
198 error = ErrorUtils::FormatErrorMessage( | 202 error = ErrorUtils::FormatErrorMessage( |
199 manifest_errors::kCannotAccessPage, | 203 manifest_errors::kCannotAccessPage, |
200 child_frame->document().url().spec()); | 204 child_frame->document().url().spec()); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 268 |
265 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; | 269 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; |
266 child_frame = child_frame->nextSibling()) { | 270 child_frame = child_frame->nextSibling()) { |
267 frames_vector->push_back(child_frame); | 271 frames_vector->push_back(child_frame); |
268 GetAllChildFrames(child_frame, frames_vector); | 272 GetAllChildFrames(child_frame, frames_vector); |
269 } | 273 } |
270 return true; | 274 return true; |
271 } | 275 } |
272 | 276 |
273 } // namespace extensions | 277 } // namespace extensions |
OLD | NEW |