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/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "chrome/common/extensions/extension_error_utils.h" | |
10 #include "chrome/common/extensions/extension_manifest_constants.h" | 9 #include "chrome/common/extensions/extension_manifest_constants.h" |
11 #include "chrome/common/extensions/extension_messages.h" | 10 #include "chrome/common/extensions/extension_messages.h" |
12 #include "chrome/renderer/extensions/dispatcher.h" | 11 #include "chrome/renderer/extensions/dispatcher.h" |
13 #include "chrome/renderer/extensions/extension_groups.h" | 12 #include "chrome/renderer/extensions/extension_groups.h" |
14 #include "chrome/renderer/extensions/extension_helper.h" | 13 #include "chrome/renderer/extensions/extension_helper.h" |
15 #include "chrome/renderer/extensions/user_script_slave.h" | 14 #include "chrome/renderer/extensions/user_script_slave.h" |
16 #include "content/public/renderer/render_view.h" | 15 #include "content/public/renderer/render_view.h" |
17 #include "content/public/renderer/v8_value_converter.h" | 16 #include "content/public/renderer/v8_value_converter.h" |
| 17 #include "extensions/common/extension_error_utils.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
23 #include "v8/include/v8.h" | 23 #include "v8/include/v8.h" |
24 | 24 |
25 namespace { | 25 namespace { |
26 // The length of time to wait after the DOM is complete to try and run user | 26 // The length of time to wait after the DOM is complete to try and run user |
27 // scripts. | 27 // scripts. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // For child frames, we just skip ones the extension doesn't have access | 176 // For child frames, we just skip ones the extension doesn't have access |
177 // to and carry on. | 177 // to and carry on. |
178 if (!extension->CanExecuteScriptOnPage(child_frame->document().url(), | 178 if (!extension->CanExecuteScriptOnPage(child_frame->document().url(), |
179 frame_->document().url(), | 179 frame_->document().url(), |
180 extension_helper->tab_id(), | 180 extension_helper->tab_id(), |
181 NULL, | 181 NULL, |
182 NULL)) { | 182 NULL)) { |
183 if (child_frame->parent()) { | 183 if (child_frame->parent()) { |
184 continue; | 184 continue; |
185 } else { | 185 } else { |
186 error = ExtensionErrorUtils::FormatErrorMessage( | 186 error = ErrorUtils::FormatErrorMessage( |
187 extension_manifest_errors::kCannotAccessPage, | 187 extension_manifest_errors::kCannotAccessPage, |
188 child_frame->document().url().spec()); | 188 child_frame->document().url().spec()); |
189 break; | 189 break; |
190 } | 190 } |
191 } | 191 } |
192 | 192 |
193 WebScriptSource source(WebString::fromUTF8(params.code)); | 193 WebScriptSource source(WebString::fromUTF8(params.code)); |
194 v8::HandleScope scope; | 194 v8::HandleScope scope; |
195 v8::Persistent<v8::Context> persistent_context = v8::Context::New(); | 195 v8::Persistent<v8::Context> persistent_context = v8::Context::New(); |
196 v8::Local<v8::Context> context = | 196 v8::Local<v8::Context> context = |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 249 |
250 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; | 250 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; |
251 child_frame = child_frame->nextSibling()) { | 251 child_frame = child_frame->nextSibling()) { |
252 frames_vector->push_back(child_frame); | 252 frames_vector->push_back(child_frame); |
253 GetAllChildFrames(child_frame, frames_vector); | 253 GetAllChildFrames(child_frame, frames_vector); |
254 } | 254 } |
255 return true; | 255 return true; |
256 } | 256 } |
257 | 257 |
258 } // namespace extensions | 258 } // namespace extensions |
OLD | NEW |