| OLD | NEW |
| 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/user_script_scheduler.h" | 5 #include "extensions/renderer/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 "content/public/renderer/render_view.h" | 10 #include "content/public/renderer/render_view.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // with navigation. | 181 // with navigation. |
| 182 // | 182 // |
| 183 // But different frames can have different URLs, and the extension might | 183 // But different frames can have different URLs, and the extension might |
| 184 // only have access to a subset of them. For the top frame, we can | 184 // only have access to a subset of them. For the top frame, we can |
| 185 // immediately send an error and stop because the browser process | 185 // immediately send an error and stop because the browser process |
| 186 // considers that an error too. | 186 // considers that an error too. |
| 187 // | 187 // |
| 188 // For child frames, we just skip ones the extension doesn't have access | 188 // For child frames, we just skip ones the extension doesn't have access |
| 189 // to and carry on. | 189 // to and carry on. |
| 190 | 190 |
| 191 GURL document_url = ScriptContext::GetEffectiveDocumentURL( |
| 192 child_frame, child_frame->document().url(), params.match_about_blank); |
| 191 bool can_execute_script = | 193 bool can_execute_script = |
| 192 PermissionsData::CanExecuteScriptOnPage(extension, | 194 PermissionsData::CanExecuteScriptOnPage(extension, |
| 193 child_frame->document().url(), | 195 document_url, |
| 194 top_url, | 196 top_url, |
| 195 extension_helper->tab_id(), | 197 extension_helper->tab_id(), |
| 196 NULL, | 198 NULL, |
| 197 -1, | 199 -1, |
| 198 NULL); | 200 NULL); |
| 199 if ((!params.is_web_view && !can_execute_script) || | 201 if ((!params.is_web_view && !can_execute_script) || |
| 200 (params.is_web_view && | 202 (params.is_web_view && document_url != params.webview_src)) { |
| 201 child_frame->document().url() != params.webview_src)) { | |
| 202 if (child_frame->parent()) { | 203 if (child_frame->parent()) { |
| 203 continue; | 204 continue; |
| 204 } else { | 205 } else { |
| 205 error = ErrorUtils::FormatErrorMessage( | 206 error = ErrorUtils::FormatErrorMessage( |
| 206 manifest_errors::kCannotAccessPage, | 207 manifest_errors::kCannotAccessPage, document_url.spec()); |
| 207 child_frame->document().url().spec()); | |
| 208 break; | 208 break; |
| 209 } | 209 } |
| 210 } | 210 } |
| 211 | 211 |
| 212 if (params.is_javascript) { | 212 if (params.is_javascript) { |
| 213 WebScriptSource source(WebString::fromUTF8(params.code), params.file_url); | 213 WebScriptSource source(WebString::fromUTF8(params.code), params.file_url); |
| 214 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 214 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 215 | 215 |
| 216 scoped_ptr<content::V8ValueConverter> v8_converter( | 216 scoped_ptr<content::V8ValueConverter> v8_converter( |
| 217 content::V8ValueConverter::create()); | 217 content::V8ValueConverter::create()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 271 |
| 272 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; | 272 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; |
| 273 child_frame = child_frame->nextSibling()) { | 273 child_frame = child_frame->nextSibling()) { |
| 274 frames_vector->push_back(child_frame); | 274 frames_vector->push_back(child_frame); |
| 275 GetAllChildFrames(child_frame, frames_vector); | 275 GetAllChildFrames(child_frame, frames_vector); |
| 276 } | 276 } |
| 277 return true; | 277 return true; |
| 278 } | 278 } |
| 279 | 279 |
| 280 } // namespace extensions | 280 } // namespace extensions |
| OLD | NEW |