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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 // 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 |
182 // with navigation. | 182 // with navigation. |
183 // | 183 // |
184 // But different frames can have different URLs, and the extension might | 184 // But different frames can have different URLs, and the extension might |
185 // 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 |
186 // immediately send an error and stop because the browser process | 186 // immediately send an error and stop because the browser process |
187 // considers that an error too. | 187 // considers that an error too. |
188 // | 188 // |
189 // 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 |
190 // to and carry on. | 190 // to and carry on. |
191 if (!params.is_web_view && | 191 |
192 !PermissionsData::CanExecuteScriptOnPage(extension, | 192 bool can_execute_script = |
193 child_frame->document().url(), | 193 PermissionsData::CanExecuteScriptOnPage(extension, |
194 top_url, | 194 child_frame->document().url(), |
195 extension_helper->tab_id(), | 195 top_url, |
196 NULL, | 196 extension_helper->tab_id(), |
197 -1, | 197 NULL, |
198 NULL)) { | 198 -1, |
| 199 NULL); |
| 200 if ((!params.is_web_view && !can_execute_script) || |
| 201 (params.is_web_view && |
| 202 child_frame->document().url() != params.webview_src)) { |
199 if (child_frame->parent()) { | 203 if (child_frame->parent()) { |
200 continue; | 204 continue; |
201 } else { | 205 } else { |
202 error = ErrorUtils::FormatErrorMessage( | 206 error = ErrorUtils::FormatErrorMessage( |
203 manifest_errors::kCannotAccessPage, | 207 manifest_errors::kCannotAccessPage, |
204 child_frame->document().url().spec()); | 208 child_frame->document().url().spec()); |
205 break; | 209 break; |
206 } | 210 } |
207 } | 211 } |
208 | 212 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 272 |
269 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; | 273 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; |
270 child_frame = child_frame->nextSibling()) { | 274 child_frame = child_frame->nextSibling()) { |
271 frames_vector->push_back(child_frame); | 275 frames_vector->push_back(child_frame); |
272 GetAllChildFrames(child_frame, frames_vector); | 276 GetAllChildFrames(child_frame, frames_vector); |
273 } | 277 } |
274 return true; | 278 return true; |
275 } | 279 } |
276 | 280 |
277 } // namespace extensions | 281 } // namespace extensions |
OLD | NEW |