| 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.h" | 9 #include "base/message_loop.h" |
| 10 #include "chrome/common/extensions/extension_manifest_constants.h" | 10 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 11 #include "chrome/common/extensions/extension_messages.h" | 11 #include "chrome/common/extensions/extension_messages.h" |
| 12 #include "chrome/common/extensions/permissions/permissions_data.h" |
| 12 #include "chrome/renderer/chrome_render_process_observer.h" | 13 #include "chrome/renderer/chrome_render_process_observer.h" |
| 13 #include "chrome/renderer/extensions/dispatcher.h" | 14 #include "chrome/renderer/extensions/dispatcher.h" |
| 14 #include "chrome/renderer/extensions/dom_activity_logger.h" | 15 #include "chrome/renderer/extensions/dom_activity_logger.h" |
| 15 #include "chrome/renderer/extensions/extension_groups.h" | 16 #include "chrome/renderer/extensions/extension_groups.h" |
| 16 #include "chrome/renderer/extensions/extension_helper.h" | 17 #include "chrome/renderer/extensions/extension_helper.h" |
| 17 #include "chrome/renderer/extensions/user_script_slave.h" | 18 #include "chrome/renderer/extensions/user_script_slave.h" |
| 18 #include "content/public/renderer/render_view.h" | 19 #include "content/public/renderer/render_view.h" |
| 19 #include "content/public/renderer/v8_value_converter.h" | 20 #include "content/public/renderer/v8_value_converter.h" |
| 20 #include "extensions/common/error_utils.h" | 21 #include "extensions/common/error_utils.h" |
| 21 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 22 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // with navigation. | 173 // with navigation. |
| 173 // | 174 // |
| 174 // But different frames can have different URLs, and the extension might | 175 // But different frames can have different URLs, and the extension might |
| 175 // only have access to a subset of them. For the top frame, we can | 176 // only have access to a subset of them. For the top frame, we can |
| 176 // immediately send an error and stop because the browser process | 177 // immediately send an error and stop because the browser process |
| 177 // considers that an error too. | 178 // considers that an error too. |
| 178 // | 179 // |
| 179 // For child frames, we just skip ones the extension doesn't have access | 180 // For child frames, we just skip ones the extension doesn't have access |
| 180 // to and carry on. | 181 // to and carry on. |
| 181 if (!params.is_web_view && | 182 if (!params.is_web_view && |
| 182 !extension->CanExecuteScriptOnPage(child_frame->document().url(), | 183 !PermissionsData::CanExecuteScriptOnPage( |
| 183 frame_->document().url(), | 184 extension, |
| 184 extension_helper->tab_id(), | 185 child_frame->document().url(), |
| 185 NULL, | 186 frame_->document().url(), |
| 186 NULL)) { | 187 extension_helper->tab_id(), |
| 188 NULL, |
| 189 NULL)) { |
| 187 if (child_frame->parent()) { | 190 if (child_frame->parent()) { |
| 188 continue; | 191 continue; |
| 189 } else { | 192 } else { |
| 190 error = ErrorUtils::FormatErrorMessage( | 193 error = ErrorUtils::FormatErrorMessage( |
| 191 extension_manifest_errors::kCannotAccessPage, | 194 extension_manifest_errors::kCannotAccessPage, |
| 192 child_frame->document().url().spec()); | 195 child_frame->document().url().spec()); |
| 193 break; | 196 break; |
| 194 } | 197 } |
| 195 } | 198 } |
| 196 | 199 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 | 266 |
| 264 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; | 267 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; |
| 265 child_frame = child_frame->nextSibling()) { | 268 child_frame = child_frame->nextSibling()) { |
| 266 frames_vector->push_back(child_frame); | 269 frames_vector->push_back(child_frame); |
| 267 GetAllChildFrames(child_frame, frames_vector); | 270 GetAllChildFrames(child_frame, frames_vector); |
| 268 } | 271 } |
| 269 return true; | 272 return true; |
| 270 } | 273 } |
| 271 | 274 |
| 272 } // namespace extensions | 275 } // namespace extensions |
| OLD | NEW |