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/chrome_content_renderer_client.h" | 5 #include "chrome/renderer/chrome_content_renderer_client.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "chrome/renderer/extensions/miscellaneous_bindings.h" | 43 #include "chrome/renderer/extensions/miscellaneous_bindings.h" |
44 #include "chrome/renderer/extensions/schema_generated_bindings.h" | 44 #include "chrome/renderer/extensions/schema_generated_bindings.h" |
45 #include "chrome/renderer/external_extension.h" | 45 #include "chrome/renderer/external_extension.h" |
46 #include "chrome/renderer/loadtimes_extension_bindings.h" | 46 #include "chrome/renderer/loadtimes_extension_bindings.h" |
47 #include "chrome/renderer/localized_error.h" | 47 #include "chrome/renderer/localized_error.h" |
48 #include "chrome/renderer/net/renderer_net_predictor.h" | 48 #include "chrome/renderer/net/renderer_net_predictor.h" |
49 #include "chrome/renderer/page_click_tracker.h" | 49 #include "chrome/renderer/page_click_tracker.h" |
50 #include "chrome/renderer/page_load_histograms.h" | 50 #include "chrome/renderer/page_load_histograms.h" |
51 #include "chrome/renderer/plugins/plugin_placeholder.h" | 51 #include "chrome/renderer/plugins/plugin_placeholder.h" |
52 #include "chrome/renderer/plugins/plugin_uma.h" | 52 #include "chrome/renderer/plugins/plugin_uma.h" |
| 53 #include "chrome/renderer/prerender/prerender_dispatcher.h" |
53 #include "chrome/renderer/prerender/prerender_helper.h" | 54 #include "chrome/renderer/prerender/prerender_helper.h" |
54 #include "chrome/renderer/prerender/prerender_webmediaplayer.h" | 55 #include "chrome/renderer/prerender/prerender_webmediaplayer.h" |
55 #include "chrome/renderer/print_web_view_helper.h" | 56 #include "chrome/renderer/print_web_view_helper.h" |
56 #include "chrome/renderer/renderer_histogram_snapshots.h" | 57 #include "chrome/renderer/renderer_histogram_snapshots.h" |
57 #include "chrome/renderer/safe_browsing/malware_dom_details.h" | 58 #include "chrome/renderer/safe_browsing/malware_dom_details.h" |
58 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 59 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
59 #include "chrome/renderer/search_extension.h" | 60 #include "chrome/renderer/search_extension.h" |
60 #include "chrome/renderer/searchbox.h" | 61 #include "chrome/renderer/searchbox.h" |
61 #include "chrome/renderer/searchbox_extension.h" | 62 #include "chrome/renderer/searchbox_extension.h" |
62 #include "chrome/renderer/spellchecker/spellcheck.h" | 63 #include "chrome/renderer/spellchecker/spellcheck.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 void ChromeContentRendererClient::RenderThreadStarted() { | 151 void ChromeContentRendererClient::RenderThreadStarted() { |
151 chrome_observer_.reset(new ChromeRenderProcessObserver(this)); | 152 chrome_observer_.reset(new ChromeRenderProcessObserver(this)); |
152 extension_dispatcher_.reset(new ExtensionDispatcher()); | 153 extension_dispatcher_.reset(new ExtensionDispatcher()); |
153 histogram_snapshots_.reset(new RendererHistogramSnapshots()); | 154 histogram_snapshots_.reset(new RendererHistogramSnapshots()); |
154 net_predictor_.reset(new RendererNetPredictor()); | 155 net_predictor_.reset(new RendererNetPredictor()); |
155 spellcheck_.reset(new SpellCheck()); | 156 spellcheck_.reset(new SpellCheck()); |
156 visited_link_slave_.reset(new VisitedLinkSlave()); | 157 visited_link_slave_.reset(new VisitedLinkSlave()); |
157 #if defined(ENABLE_SAFE_BROWSING) | 158 #if defined(ENABLE_SAFE_BROWSING) |
158 phishing_classifier_.reset(safe_browsing::PhishingClassifierFilter::Create()); | 159 phishing_classifier_.reset(safe_browsing::PhishingClassifierFilter::Create()); |
159 #endif | 160 #endif |
| 161 prerender_dispatcher_.reset(new prerender::PrerenderDispatcher()); |
160 | 162 |
161 RenderThread* thread = RenderThread::Get(); | 163 RenderThread* thread = RenderThread::Get(); |
162 | 164 |
163 thread->AddObserver(chrome_observer_.get()); | 165 thread->AddObserver(chrome_observer_.get()); |
164 thread->AddObserver(extension_dispatcher_.get()); | 166 thread->AddObserver(extension_dispatcher_.get()); |
165 thread->AddObserver(histogram_snapshots_.get()); | 167 thread->AddObserver(histogram_snapshots_.get()); |
166 #if defined(ENABLE_SAFE_BROWSING) | 168 #if defined(ENABLE_SAFE_BROWSING) |
167 thread->AddObserver(phishing_classifier_.get()); | 169 thread->AddObserver(phishing_classifier_.get()); |
168 #endif | 170 #endif |
169 thread->AddObserver(spellcheck_.get()); | 171 thread->AddObserver(spellcheck_.get()); |
170 thread->AddObserver(visited_link_slave_.get()); | 172 thread->AddObserver(visited_link_slave_.get()); |
| 173 thread->AddObserver(prerender_dispatcher_.get()); |
171 | 174 |
172 thread->RegisterExtension(extensions_v8::ExternalExtension::Get()); | 175 thread->RegisterExtension(extensions_v8::ExternalExtension::Get()); |
173 thread->RegisterExtension(extensions_v8::LoadTimesExtension::Get()); | 176 thread->RegisterExtension(extensions_v8::LoadTimesExtension::Get()); |
174 thread->RegisterExtension(extensions_v8::SearchBoxExtension::Get()); | 177 thread->RegisterExtension(extensions_v8::SearchBoxExtension::Get()); |
175 v8::Extension* search_extension = extensions_v8::SearchExtension::Get(); | 178 v8::Extension* search_extension = extensions_v8::SearchExtension::Get(); |
176 // search_extension is null if not enabled. | 179 // search_extension is null if not enabled. |
177 if (search_extension) | 180 if (search_extension) |
178 thread->RegisterExtension(search_extension); | 181 thread->RegisterExtension(search_extension); |
179 | 182 |
180 if (CommandLine::ForCurrentProcess()->HasSwitch( | 183 if (CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 bool ChromeContentRendererClient::AllowPopup(const GURL& creator) { | 638 bool ChromeContentRendererClient::AllowPopup(const GURL& creator) { |
636 ChromeV8Context* current_context = | 639 ChromeV8Context* current_context = |
637 extension_dispatcher_->v8_context_set().GetCurrent(); | 640 extension_dispatcher_->v8_context_set().GetCurrent(); |
638 return current_context && !current_context->extension_id().empty(); | 641 return current_context && !current_context->extension_id().empty(); |
639 } | 642 } |
640 | 643 |
641 bool ChromeContentRendererClient::ShouldFork(WebFrame* frame, | 644 bool ChromeContentRendererClient::ShouldFork(WebFrame* frame, |
642 const GURL& url, | 645 const GURL& url, |
643 bool is_initial_navigation, | 646 bool is_initial_navigation, |
644 bool* send_referrer) { | 647 bool* send_referrer) { |
| 648 DCHECK(!frame->parent()); |
| 649 |
| 650 // If |url| matches one of the prerendered URLs, stop this navigation and try |
| 651 // to swap in the prerendered page on the browser process. If the prerendered |
| 652 // page no longer exists by the time the OpenURL IPC is handled, a normal |
| 653 // navigation is attempted. |
| 654 if (prerender_dispatcher_.get() && prerender_dispatcher_->IsPrerenderURL(url)) |
| 655 return true; |
| 656 |
645 const ExtensionSet* extensions = extension_dispatcher_->extensions(); | 657 const ExtensionSet* extensions = extension_dispatcher_->extensions(); |
646 | 658 |
647 // Determine if the new URL is an extension (excluding bookmark apps). | 659 // Determine if the new URL is an extension (excluding bookmark apps). |
648 const Extension* new_url_extension = extensions::GetNonBookmarkAppExtension( | 660 const Extension* new_url_extension = extensions::GetNonBookmarkAppExtension( |
649 *extensions, ExtensionURLInfo(url)); | 661 *extensions, ExtensionURLInfo(url)); |
650 bool is_extension_url = !!new_url_extension; | 662 bool is_extension_url = !!new_url_extension; |
651 | 663 |
652 // If the navigation would cross an app extent boundary, we also need | 664 // If the navigation would cross an app extent boundary, we also need |
653 // to defer to the browser to ensure process isolation. | 665 // to defer to the browser to ensure process isolation. |
654 // TODO(erikkay) This is happening inside of a check to is_content_initiated | 666 // TODO(erikkay) This is happening inside of a check to is_content_initiated |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 bool ChromeContentRendererClient::IsOtherExtensionWithWebRequestInstalled() { | 862 bool ChromeContentRendererClient::IsOtherExtensionWithWebRequestInstalled() { |
851 return extension_dispatcher_->IsOtherExtensionWithWebRequestInstalled(); | 863 return extension_dispatcher_->IsOtherExtensionWithWebRequestInstalled(); |
852 } | 864 } |
853 | 865 |
854 void ChromeContentRendererClient::RegisterPPAPIInterfaceFactories( | 866 void ChromeContentRendererClient::RegisterPPAPIInterfaceFactories( |
855 webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) { | 867 webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) { |
856 factory_manager->RegisterFactory(ChromePPAPIInterfaceFactory); | 868 factory_manager->RegisterFactory(ChromePPAPIInterfaceFactory); |
857 } | 869 } |
858 | 870 |
859 } // namespace chrome | 871 } // namespace chrome |
OLD | NEW |