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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 #include "chrome/renderer/plugins/plugin_uma.h" | 56 #include "chrome/renderer/plugins/plugin_uma.h" |
57 #include "chrome/renderer/prerender/prerender_dispatcher.h" | 57 #include "chrome/renderer/prerender/prerender_dispatcher.h" |
58 #include "chrome/renderer/prerender/prerender_helper.h" | 58 #include "chrome/renderer/prerender/prerender_helper.h" |
59 #include "chrome/renderer/prerender/prerender_media_load_deferrer.h" | 59 #include "chrome/renderer/prerender/prerender_media_load_deferrer.h" |
60 #include "chrome/renderer/prerender/prerenderer_client.h" | 60 #include "chrome/renderer/prerender/prerenderer_client.h" |
61 #include "chrome/renderer/printing/print_web_view_helper.h" | 61 #include "chrome/renderer/printing/print_web_view_helper.h" |
62 #include "chrome/renderer/safe_browsing/malware_dom_details.h" | 62 #include "chrome/renderer/safe_browsing/malware_dom_details.h" |
63 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 63 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
64 #include "chrome/renderer/searchbox/searchbox.h" | 64 #include "chrome/renderer/searchbox/searchbox.h" |
65 #include "chrome/renderer/searchbox/searchbox_extension.h" | 65 #include "chrome/renderer/searchbox/searchbox_extension.h" |
66 #include "chrome/renderer/spellchecker/spellcheck.h" | |
67 #include "chrome/renderer/spellchecker/spellcheck_provider.h" | |
68 #include "chrome/renderer/tts_dispatcher.h" | 66 #include "chrome/renderer/tts_dispatcher.h" |
69 #include "chrome/renderer/validation_message_agent.h" | 67 #include "chrome/renderer/validation_message_agent.h" |
70 #include "components/autofill/content/renderer/autofill_agent.h" | 68 #include "components/autofill/content/renderer/autofill_agent.h" |
71 #include "components/autofill/content/renderer/password_autofill_agent.h" | 69 #include "components/autofill/content/renderer/password_autofill_agent.h" |
72 #include "components/autofill/content/renderer/password_generation_manager.h" | 70 #include "components/autofill/content/renderer/password_generation_manager.h" |
73 #include "components/visitedlink/renderer/visitedlink_slave.h" | 71 #include "components/visitedlink/renderer/visitedlink_slave.h" |
74 #include "content/public/common/content_constants.h" | 72 #include "content/public/common/content_constants.h" |
75 #include "content/public/renderer/render_thread.h" | 73 #include "content/public/renderer/render_thread.h" |
76 #include "content/public/renderer/render_view.h" | 74 #include "content/public/renderer/render_view.h" |
77 #include "content/public/renderer/render_view_visitor.h" | 75 #include "content/public/renderer/render_view_visitor.h" |
(...skipping 21 matching lines...) Expand all Loading... |
99 #include "ui/base/l10n/l10n_util.h" | 97 #include "ui/base/l10n/l10n_util.h" |
100 #include "ui/base/layout.h" | 98 #include "ui/base/layout.h" |
101 #include "ui/base/resource/resource_bundle.h" | 99 #include "ui/base/resource/resource_bundle.h" |
102 #include "ui/webui/jstemplate_builder.h" | 100 #include "ui/webui/jstemplate_builder.h" |
103 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 101 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
104 | 102 |
105 #if defined(ENABLE_WEBRTC) | 103 #if defined(ENABLE_WEBRTC) |
106 #include "chrome/renderer/media/webrtc_logging_message_filter.h" | 104 #include "chrome/renderer/media/webrtc_logging_message_filter.h" |
107 #endif | 105 #endif |
108 | 106 |
| 107 #if defined(ENABLE_SPELLCHECK) |
| 108 #include "chrome/renderer/spellchecker/spellcheck.h" |
| 109 #include "chrome/renderer/spellchecker/spellcheck_provider.h" |
| 110 #endif |
| 111 |
109 using autofill::AutofillAgent; | 112 using autofill::AutofillAgent; |
110 using autofill::PasswordAutofillAgent; | 113 using autofill::PasswordAutofillAgent; |
111 using autofill::PasswordGenerationManager; | 114 using autofill::PasswordGenerationManager; |
112 using content::RenderThread; | 115 using content::RenderThread; |
113 using content::WebPluginInfo; | 116 using content::WebPluginInfo; |
114 using extensions::Extension; | 117 using extensions::Extension; |
115 using WebKit::WebCache; | 118 using WebKit::WebCache; |
116 using WebKit::WebConsoleMessage; | 119 using WebKit::WebConsoleMessage; |
117 using WebKit::WebDataSource; | 120 using WebKit::WebDataSource; |
118 using WebKit::WebDocument; | 121 using WebKit::WebDocument; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 158 |
156 for (size_t i = 0; i < additional_names.size(); ++i) { | 159 for (size_t i = 0; i < additional_names.size(); ++i) { |
157 names[existing_size + i] = additional_names[i]; | 160 names[existing_size + i] = additional_names[i]; |
158 values[existing_size + i] = additional_values[i]; | 161 values[existing_size + i] = additional_values[i]; |
159 } | 162 } |
160 | 163 |
161 existing_names->swap(names); | 164 existing_names->swap(names); |
162 existing_values->swap(values); | 165 existing_values->swap(values); |
163 } | 166 } |
164 | 167 |
| 168 #if defined(ENABLE_SPELLCHECK) |
165 class SpellCheckReplacer : public content::RenderViewVisitor { | 169 class SpellCheckReplacer : public content::RenderViewVisitor { |
166 public: | 170 public: |
167 explicit SpellCheckReplacer(SpellCheck* spellcheck) | 171 explicit SpellCheckReplacer(SpellCheck* spellcheck) |
168 : spellcheck_(spellcheck) {} | 172 : spellcheck_(spellcheck) {} |
169 virtual bool Visit(content::RenderView* render_view) OVERRIDE; | 173 virtual bool Visit(content::RenderView* render_view) OVERRIDE; |
170 | 174 |
171 private: | 175 private: |
172 SpellCheck* spellcheck_; // New shared spellcheck for all views. Weak Ptr. | 176 SpellCheck* spellcheck_; // New shared spellcheck for all views. Weak Ptr. |
173 DISALLOW_COPY_AND_ASSIGN(SpellCheckReplacer); | 177 DISALLOW_COPY_AND_ASSIGN(SpellCheckReplacer); |
174 }; | 178 }; |
175 | 179 |
176 bool SpellCheckReplacer::Visit(content::RenderView* render_view) { | 180 bool SpellCheckReplacer::Visit(content::RenderView* render_view) { |
177 SpellCheckProvider* provider = SpellCheckProvider::Get(render_view); | 181 SpellCheckProvider* provider = SpellCheckProvider::Get(render_view); |
178 DCHECK(provider); | 182 DCHECK(provider); |
179 provider->set_spellcheck(spellcheck_); | 183 provider->set_spellcheck(spellcheck_); |
180 return true; | 184 return true; |
181 } | 185 } |
| 186 #endif |
182 | 187 |
183 // For certain sandboxed Pepper plugins, use the JavaScript Content Settings. | 188 // For certain sandboxed Pepper plugins, use the JavaScript Content Settings. |
184 bool ShouldUseJavaScriptSettingForPlugin(const WebPluginInfo& plugin) { | 189 bool ShouldUseJavaScriptSettingForPlugin(const WebPluginInfo& plugin) { |
185 if (plugin.type != WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS && | 190 if (plugin.type != WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS && |
186 plugin.type != WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS) { | 191 plugin.type != WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS) { |
187 return false; | 192 return false; |
188 } | 193 } |
189 | 194 |
190 // Treat Native Client invocations like JavaScript. | 195 // Treat Native Client invocations like JavaScript. |
191 if (plugin.name == ASCIIToUTF16(chrome::ChromeContentClient::kNaClPluginName)) | 196 if (plugin.name == ASCIIToUTF16(chrome::ChromeContentClient::kNaClPluginName)) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 } | 231 } |
227 | 232 |
228 void ChromeContentRendererClient::RenderThreadStarted() { | 233 void ChromeContentRendererClient::RenderThreadStarted() { |
229 chrome_observer_.reset(new ChromeRenderProcessObserver(this)); | 234 chrome_observer_.reset(new ChromeRenderProcessObserver(this)); |
230 extension_dispatcher_.reset(new extensions::Dispatcher()); | 235 extension_dispatcher_.reset(new extensions::Dispatcher()); |
231 permissions_policy_delegate_.reset( | 236 permissions_policy_delegate_.reset( |
232 new extensions::RendererPermissionsPolicyDelegate( | 237 new extensions::RendererPermissionsPolicyDelegate( |
233 extension_dispatcher_.get())); | 238 extension_dispatcher_.get())); |
234 prescient_networking_dispatcher_.reset(new PrescientNetworkingDispatcher()); | 239 prescient_networking_dispatcher_.reset(new PrescientNetworkingDispatcher()); |
235 net_predictor_.reset(new RendererNetPredictor()); | 240 net_predictor_.reset(new RendererNetPredictor()); |
| 241 #if defined(ENABLE_SPELLCHECK) |
236 spellcheck_.reset(new SpellCheck()); | 242 spellcheck_.reset(new SpellCheck()); |
| 243 #endif |
237 visited_link_slave_.reset(new visitedlink::VisitedLinkSlave()); | 244 visited_link_slave_.reset(new visitedlink::VisitedLinkSlave()); |
238 #if defined(FULL_SAFE_BROWSING) | 245 #if defined(FULL_SAFE_BROWSING) |
239 phishing_classifier_.reset(safe_browsing::PhishingClassifierFilter::Create()); | 246 phishing_classifier_.reset(safe_browsing::PhishingClassifierFilter::Create()); |
240 #endif | 247 #endif |
241 prerender_dispatcher_.reset(new prerender::PrerenderDispatcher()); | 248 prerender_dispatcher_.reset(new prerender::PrerenderDispatcher()); |
242 #if defined(ENABLE_WEBRTC) | 249 #if defined(ENABLE_WEBRTC) |
243 webrtc_logging_message_filter_ = new WebRtcLoggingMessageFilter( | 250 webrtc_logging_message_filter_ = new WebRtcLoggingMessageFilter( |
244 content::RenderThread::Get()->GetIOMessageLoopProxy()); | 251 content::RenderThread::Get()->GetIOMessageLoopProxy()); |
245 #endif | 252 #endif |
246 | 253 |
247 RenderThread* thread = RenderThread::Get(); | 254 RenderThread* thread = RenderThread::Get(); |
248 | 255 |
249 thread->AddObserver(chrome_observer_.get()); | 256 thread->AddObserver(chrome_observer_.get()); |
250 thread->AddObserver(extension_dispatcher_.get()); | 257 thread->AddObserver(extension_dispatcher_.get()); |
251 #if defined(FULL_SAFE_BROWSING) | 258 #if defined(FULL_SAFE_BROWSING) |
252 thread->AddObserver(phishing_classifier_.get()); | 259 thread->AddObserver(phishing_classifier_.get()); |
253 #endif | 260 #endif |
| 261 #if defined(ENABLE_SPELLCHECK) |
254 thread->AddObserver(spellcheck_.get()); | 262 thread->AddObserver(spellcheck_.get()); |
| 263 #endif |
255 thread->AddObserver(visited_link_slave_.get()); | 264 thread->AddObserver(visited_link_slave_.get()); |
256 thread->AddObserver(prerender_dispatcher_.get()); | 265 thread->AddObserver(prerender_dispatcher_.get()); |
257 | 266 |
258 #if defined(ENABLE_WEBRTC) | 267 #if defined(ENABLE_WEBRTC) |
259 thread->AddFilter(webrtc_logging_message_filter_.get()); | 268 thread->AddFilter(webrtc_logging_message_filter_.get()); |
260 #endif | 269 #endif |
261 | 270 |
262 thread->RegisterExtension(extensions_v8::ExternalExtension::Get()); | 271 thread->RegisterExtension(extensions_v8::ExternalExtension::Get()); |
263 thread->RegisterExtension(extensions_v8::LoadTimesExtension::Get()); | 272 thread->RegisterExtension(extensions_v8::LoadTimesExtension::Get()); |
264 | 273 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 new ContentSettingsObserver(render_view); | 356 new ContentSettingsObserver(render_view); |
348 if (chrome_observer_.get()) { | 357 if (chrome_observer_.get()) { |
349 content_settings->SetContentSettingRules( | 358 content_settings->SetContentSettingRules( |
350 chrome_observer_->content_setting_rules()); | 359 chrome_observer_->content_setting_rules()); |
351 } | 360 } |
352 new extensions::ExtensionHelper(render_view, extension_dispatcher_.get()); | 361 new extensions::ExtensionHelper(render_view, extension_dispatcher_.get()); |
353 new PageLoadHistograms(render_view); | 362 new PageLoadHistograms(render_view); |
354 #if defined(ENABLE_PRINTING) | 363 #if defined(ENABLE_PRINTING) |
355 new printing::PrintWebViewHelper(render_view); | 364 new printing::PrintWebViewHelper(render_view); |
356 #endif | 365 #endif |
| 366 #if defined(ENABLE_SPELLCHECK) |
357 new SpellCheckProvider(render_view, spellcheck_.get()); | 367 new SpellCheckProvider(render_view, spellcheck_.get()); |
| 368 #endif |
358 new prerender::PrerendererClient(render_view); | 369 new prerender::PrerendererClient(render_view); |
359 #if defined(FULL_SAFE_BROWSING) | 370 #if defined(FULL_SAFE_BROWSING) |
360 safe_browsing::MalwareDOMDetails::Create(render_view); | 371 safe_browsing::MalwareDOMDetails::Create(render_view); |
361 #endif | 372 #endif |
362 | 373 |
363 PasswordAutofillAgent* password_autofill_agent = | 374 PasswordAutofillAgent* password_autofill_agent = |
364 new PasswordAutofillAgent(render_view); | 375 new PasswordAutofillAgent(render_view); |
365 new AutofillAgent(render_view, password_autofill_agent); | 376 new AutofillAgent(render_view, password_autofill_agent); |
366 new ValidationMessageAgent(render_view); | 377 new ValidationMessageAgent(render_view); |
367 | 378 |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 | 1168 |
1158 // Only consider keeping non-app URLs in an app process if this window | 1169 // Only consider keeping non-app URLs in an app process if this window |
1159 // has an opener (in which case it might be an OAuth popup that tries to | 1170 // has an opener (in which case it might be an OAuth popup that tries to |
1160 // script an iframe within the app). | 1171 // script an iframe within the app). |
1161 bool should_consider_workaround = !!frame->opener(); | 1172 bool should_consider_workaround = !!frame->opener(); |
1162 | 1173 |
1163 return extensions::CrossesExtensionProcessBoundary( | 1174 return extensions::CrossesExtensionProcessBoundary( |
1164 extensions, old_url, new_url, should_consider_workaround); | 1175 extensions, old_url, new_url, should_consider_workaround); |
1165 } | 1176 } |
1166 | 1177 |
| 1178 #if defined(ENABLE_SPELLCHECK) |
1167 void ChromeContentRendererClient::SetSpellcheck(SpellCheck* spellcheck) { | 1179 void ChromeContentRendererClient::SetSpellcheck(SpellCheck* spellcheck) { |
1168 RenderThread* thread = RenderThread::Get(); | 1180 RenderThread* thread = RenderThread::Get(); |
1169 if (spellcheck_.get() && thread) | 1181 if (spellcheck_.get() && thread) |
1170 thread->RemoveObserver(spellcheck_.get()); | 1182 thread->RemoveObserver(spellcheck_.get()); |
1171 spellcheck_.reset(spellcheck); | 1183 spellcheck_.reset(spellcheck); |
1172 SpellCheckReplacer replacer(spellcheck_.get()); | 1184 SpellCheckReplacer replacer(spellcheck_.get()); |
1173 content::RenderView::ForEach(&replacer); | 1185 content::RenderView::ForEach(&replacer); |
1174 if (thread) | 1186 if (thread) |
1175 thread->AddObserver(spellcheck_.get()); | 1187 thread->AddObserver(spellcheck_.get()); |
1176 } | 1188 } |
| 1189 #endif |
1177 | 1190 |
1178 void ChromeContentRendererClient::OnPurgeMemory() { | 1191 void ChromeContentRendererClient::OnPurgeMemory() { |
| 1192 #if defined(ENABLE_SPELLCHECK) |
1179 DVLOG(1) << "Resetting spellcheck in renderer client"; | 1193 DVLOG(1) << "Resetting spellcheck in renderer client"; |
1180 SetSpellcheck(new SpellCheck()); | 1194 SetSpellcheck(new SpellCheck()); |
| 1195 #endif |
1181 } | 1196 } |
1182 | 1197 |
1183 bool ChromeContentRendererClient::IsAdblockInstalled() { | 1198 bool ChromeContentRendererClient::IsAdblockInstalled() { |
1184 return g_current_client->extension_dispatcher_->extensions()->Contains( | 1199 return g_current_client->extension_dispatcher_->extensions()->Contains( |
1185 "gighmmpiobklfepjocnamgkkbiglidom"); | 1200 "gighmmpiobklfepjocnamgkkbiglidom"); |
1186 } | 1201 } |
1187 | 1202 |
1188 bool ChromeContentRendererClient::IsAdblockPlusInstalled() { | 1203 bool ChromeContentRendererClient::IsAdblockPlusInstalled() { |
1189 return g_current_client->extension_dispatcher_->extensions()->Contains( | 1204 return g_current_client->extension_dispatcher_->extensions()->Contains( |
1190 "cfhdojbkjhnklbpkdaibdccddilifddb"); | 1205 "cfhdojbkjhnklbpkdaibdccddilifddb"); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1297 if (CommandLine::ForCurrentProcess()->HasSwitch( |
1283 switches::kEnablePepperTesting)) { | 1298 switches::kEnablePepperTesting)) { |
1284 return true; | 1299 return true; |
1285 } | 1300 } |
1286 #endif // !defined(OS_ANDROID) | 1301 #endif // !defined(OS_ANDROID) |
1287 return false; | 1302 return false; |
1288 } | 1303 } |
1289 | 1304 |
1290 | 1305 |
1291 } // namespace chrome | 1306 } // namespace chrome |
OLD | NEW |