| 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/extension_helper.h" | 5 #include "chrome/renderer/extensions/extension_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/extensions/extension_messages.h" | 15 #include "chrome/common/extensions/extension_messages.h" |
| 16 #include "chrome/common/render_messages.h" | 16 #include "chrome/common/render_messages.h" |
| 17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 18 #include "chrome/common/view_type.h" | 18 #include "chrome/common/view_type.h" |
| 19 #include "chrome/renderer/extensions/chrome_v8_context.h" | 19 #include "chrome/renderer/extensions/chrome_v8_context.h" |
| 20 #include "chrome/renderer/extensions/content_watcher.h" |
| 20 #include "chrome/renderer/extensions/dispatcher.h" | 21 #include "chrome/renderer/extensions/dispatcher.h" |
| 21 #include "chrome/renderer/extensions/miscellaneous_bindings.h" | 22 #include "chrome/renderer/extensions/miscellaneous_bindings.h" |
| 22 #include "chrome/renderer/extensions/user_script_scheduler.h" | 23 #include "chrome/renderer/extensions/user_script_scheduler.h" |
| 23 #include "chrome/renderer/extensions/user_script_slave.h" | 24 #include "chrome/renderer/extensions/user_script_slave.h" |
| 24 #include "content/public/renderer/render_view.h" | 25 #include "content/public/renderer/render_view.h" |
| 25 #include "content/public/renderer/render_view_visitor.h" | 26 #include "content/public/renderer/render_view_visitor.h" |
| 26 #include "extensions/common/constants.h" | 27 #include "extensions/common/constants.h" |
| 27 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" | 28 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" |
| 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" | 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" |
| 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 145 |
| 145 ExtensionHelper::ExtensionHelper(content::RenderView* render_view, | 146 ExtensionHelper::ExtensionHelper(content::RenderView* render_view, |
| 146 Dispatcher* dispatcher) | 147 Dispatcher* dispatcher) |
| 147 : content::RenderViewObserver(render_view), | 148 : content::RenderViewObserver(render_view), |
| 148 content::RenderViewObserverTracker<ExtensionHelper>(render_view), | 149 content::RenderViewObserverTracker<ExtensionHelper>(render_view), |
| 149 dispatcher_(dispatcher), | 150 dispatcher_(dispatcher), |
| 150 pending_app_icon_requests_(0), | 151 pending_app_icon_requests_(0), |
| 151 view_type_(chrome::VIEW_TYPE_INVALID), | 152 view_type_(chrome::VIEW_TYPE_INVALID), |
| 152 tab_id_(-1), | 153 tab_id_(-1), |
| 153 browser_window_id_(-1) { | 154 browser_window_id_(-1) { |
| 155 dispatcher_->content_watcher()->OnWebViewCreated(render_view->GetWebView()); |
| 154 } | 156 } |
| 155 | 157 |
| 156 ExtensionHelper::~ExtensionHelper() { | 158 ExtensionHelper::~ExtensionHelper() { |
| 157 } | 159 } |
| 158 | 160 |
| 159 bool ExtensionHelper::InstallWebApplicationUsingDefinitionFile( | 161 bool ExtensionHelper::InstallWebApplicationUsingDefinitionFile( |
| 160 WebFrame* frame, string16* error) { | 162 WebFrame* frame, string16* error) { |
| 161 // There is an issue of drive-by installs with the below implementation. A web | 163 // There is an issue of drive-by installs with the below implementation. A web |
| 162 // site could force a user to install an app by timing the dialog to come up | 164 // site could force a user to install an app by timing the dialog to come up |
| 163 // just before the user clicks. | 165 // just before the user clicks. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 // This could be called before DidCreateDataSource, in which case the frame | 279 // This could be called before DidCreateDataSource, in which case the frame |
| 278 // won't be in the map. | 280 // won't be in the map. |
| 279 SchedulerMap::iterator i = g_schedulers.Get().find(frame); | 281 SchedulerMap::iterator i = g_schedulers.Get().find(frame); |
| 280 if (i == g_schedulers.Get().end()) | 282 if (i == g_schedulers.Get().end()) |
| 281 return; | 283 return; |
| 282 | 284 |
| 283 delete i->second; | 285 delete i->second; |
| 284 g_schedulers.Get().erase(i); | 286 g_schedulers.Get().erase(i); |
| 285 } | 287 } |
| 286 | 288 |
| 289 void ExtensionHelper::CssMatches( |
| 290 WebKit::WebFrame* frame, |
| 291 const WebKit::WebVector<WebKit::WebString>& newlyMatchingSelectors, |
| 292 const WebKit::WebVector<WebKit::WebString>& stoppedMatchingSelectors) { |
| 293 dispatcher_->CssMatches(frame, newlyMatchingSelectors, |
| 294 stoppedMatchingSelectors); |
| 295 } |
| 296 |
| 287 void ExtensionHelper::DidCreateDataSource(WebFrame* frame, WebDataSource* ds) { | 297 void ExtensionHelper::DidCreateDataSource(WebFrame* frame, WebDataSource* ds) { |
| 288 // If there are any app-related fetches in progress, they can be cancelled now | 298 // If there are any app-related fetches in progress, they can be cancelled now |
| 289 // since we have navigated away from the page that created them. | 299 // since we have navigated away from the page that created them. |
| 290 if (!frame->parent()) { | 300 if (!frame->parent()) { |
| 291 app_icon_fetchers_.clear(); | 301 app_icon_fetchers_.clear(); |
| 292 app_definition_fetcher_.reset(NULL); | 302 app_definition_fetcher_.reset(NULL); |
| 293 } | 303 } |
| 294 | 304 |
| 295 // Check first if we created a scheduler for the frame, since this function | 305 // Check first if we created a scheduler for the frame, since this function |
| 296 // gets called for navigations within the document. | 306 // gets called for navigations within the document. |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 case content::CONSOLE_MESSAGE_LEVEL_ERROR: | 548 case content::CONSOLE_MESSAGE_LEVEL_ERROR: |
| 539 target_level = WebConsoleMessage::LevelError; | 549 target_level = WebConsoleMessage::LevelError; |
| 540 break; | 550 break; |
| 541 } | 551 } |
| 542 render_view()->GetWebView()->mainFrame()->addMessageToConsole( | 552 render_view()->GetWebView()->mainFrame()->addMessageToConsole( |
| 543 WebConsoleMessage(target_level, message)); | 553 WebConsoleMessage(target_level, message)); |
| 544 } | 554 } |
| 545 } | 555 } |
| 546 | 556 |
| 547 } // namespace extensions | 557 } // namespace extensions |
| OLD | NEW |