OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
7 | 7 |
8 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
9 | 9 |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "base/process_util.h" | 23 #include "base/process_util.h" |
24 #include "base/rand_util.h" | 24 #include "base/rand_util.h" |
25 #include "base/scoped_ptr.h" | 25 #include "base/scoped_ptr.h" |
26 #include "base/shared_memory.h" | 26 #include "base/shared_memory.h" |
27 #include "base/singleton.h" | 27 #include "base/singleton.h" |
28 #include "base/string_util.h" | 28 #include "base/string_util.h" |
29 #include "base/thread.h" | 29 #include "base/thread.h" |
30 #include "chrome/browser/browser_process.h" | 30 #include "chrome/browser/browser_process.h" |
31 #include "chrome/browser/child_process_security_policy.h" | 31 #include "chrome/browser/child_process_security_policy.h" |
32 #include "chrome/browser/extensions/extension_message_service.h" | 32 #include "chrome/browser/extensions/extension_message_service.h" |
| 33 #include "chrome/browser/extensions/extensions_service.h" |
33 #include "chrome/browser/extensions/user_script_master.h" | 34 #include "chrome/browser/extensions/user_script_master.h" |
34 #include "chrome/browser/history/history.h" | 35 #include "chrome/browser/history/history.h" |
35 #include "chrome/browser/plugin_service.h" | 36 #include "chrome/browser/plugin_service.h" |
36 #include "chrome/browser/profile.h" | 37 #include "chrome/browser/profile.h" |
37 #include "chrome/browser/renderer_host/render_view_host.h" | 38 #include "chrome/browser/renderer_host/render_view_host.h" |
38 #include "chrome/browser/renderer_host/render_widget_helper.h" | 39 #include "chrome/browser/renderer_host/render_widget_helper.h" |
39 #include "chrome/browser/renderer_host/render_widget_host.h" | 40 #include "chrome/browser/renderer_host/render_widget_host.h" |
40 #include "chrome/browser/renderer_host/resource_message_filter.h" | 41 #include "chrome/browser/renderer_host/resource_message_filter.h" |
41 #include "chrome/browser/renderer_host/web_cache_manager.h" | 42 #include "chrome/browser/renderer_host/web_cache_manager.h" |
42 #include "chrome/browser/visitedlink_master.h" | 43 #include "chrome/browser/visitedlink_master.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 switches::kDebugPrint, | 267 switches::kDebugPrint, |
267 switches::kAllowAllActiveX, | 268 switches::kAllowAllActiveX, |
268 switches::kMemoryProfiling, | 269 switches::kMemoryProfiling, |
269 switches::kEnableWatchdog, | 270 switches::kEnableWatchdog, |
270 switches::kMessageLoopHistogrammer, | 271 switches::kMessageLoopHistogrammer, |
271 switches::kEnableDCHECK, | 272 switches::kEnableDCHECK, |
272 switches::kSilentDumpOnDCHECK, | 273 switches::kSilentDumpOnDCHECK, |
273 switches::kUseLowFragHeapCrt, | 274 switches::kUseLowFragHeapCrt, |
274 switches::kEnableWebWorkers, | 275 switches::kEnableWebWorkers, |
275 switches::kEnableStatsTable, | 276 switches::kEnableStatsTable, |
276 switches::kEnableExtensions, | |
277 switches::kDisableOutOfProcessDevTools, | 277 switches::kDisableOutOfProcessDevTools, |
278 switches::kAutoSpellCorrect, | 278 switches::kAutoSpellCorrect, |
279 switches::kDisableAudio, | 279 switches::kDisableAudio, |
280 switches::kSimpleDataSource, | 280 switches::kSimpleDataSource, |
281 switches::kEnableBenchmarking, | 281 switches::kEnableBenchmarking, |
282 }; | 282 }; |
283 | 283 |
284 for (size_t i = 0; i < arraysize(switch_names); ++i) { | 284 for (size_t i = 0; i < arraysize(switch_names); ++i) { |
285 if (browser_command_line.HasSwitch(switch_names[i])) { | 285 if (browser_command_line.HasSwitch(switch_names[i])) { |
286 cmd_line.AppendSwitchWithValue(switch_names[i], | 286 cmd_line.AppendSwitchWithValue(switch_names[i], |
287 browser_command_line.GetSwitchValue(switch_names[i])); | 287 browser_command_line.GetSwitchValue(switch_names[i])); |
288 } | 288 } |
289 } | 289 } |
290 | 290 |
| 291 // Tell the renderer to enable extensions if there are any extensions loaded. |
| 292 // |
| 293 // NOTE: This is subtly different than just passing along whether |
| 294 // --enable-extenisons is present in the browser process. For example, there |
| 295 // is also an extensions.enabled preference, and there may be various special |
| 296 // cases about whether to allow extensions to load. |
| 297 // |
| 298 // This introduces a race condition where the first renderer never gets |
| 299 // extensions enabled, so we also set the flag if extensions_enabled(). This |
| 300 // isn't perfect though, because of the special cases above. |
| 301 // |
| 302 // TODO(aa): We need to get rid of the need to pass this flag at all. It is |
| 303 // only used in one place in the renderer. |
| 304 if (profile()->GetExtensionsService()) { |
| 305 if (profile()->GetExtensionsService()->extensions()->size() > 0 || |
| 306 profile()->GetExtensionsService()->extensions_enabled()) |
| 307 cmd_line.AppendSwitch(switches::kEnableExtensions); |
| 308 } |
| 309 |
291 // Pass on the browser locale. | 310 // Pass on the browser locale. |
292 const std::wstring locale = g_browser_process->GetApplicationLocale(); | 311 const std::wstring locale = g_browser_process->GetApplicationLocale(); |
293 cmd_line.AppendSwitchWithValue(switches::kLang, locale); | 312 cmd_line.AppendSwitchWithValue(switches::kLang, locale); |
294 | 313 |
295 // If we run a FieldTrial that we want to pass to the renderer, this is where | 314 // If we run a FieldTrial that we want to pass to the renderer, this is where |
296 // the SINGULAR trial name and value should be specified. Note that only one | 315 // the SINGULAR trial name and value should be specified. Note that only one |
297 // such flag should be passed/set in the renderer command line. | 316 // such flag should be passed/set in the renderer command line. |
298 | 317 |
299 // Today we're watching the impact of DNS on some page load times. | 318 // Today we're watching the impact of DNS on some page load times. |
300 FieldTrial* field_trial = FieldTrialList::Find("DnsImpact"); | 319 FieldTrial* field_trial = FieldTrialList::Find("DnsImpact"); |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 ExtensionMessageService* ems = ExtensionMessageService::GetInstance(context); | 880 ExtensionMessageService* ems = ExtensionMessageService::GetInstance(context); |
862 ems->AddEventListener(event_name, pid()); | 881 ems->AddEventListener(event_name, pid()); |
863 } | 882 } |
864 | 883 |
865 void BrowserRenderProcessHost::OnExtensionRemoveListener( | 884 void BrowserRenderProcessHost::OnExtensionRemoveListener( |
866 const std::string& event_name) { | 885 const std::string& event_name) { |
867 URLRequestContext* context = profile()->GetRequestContext(); | 886 URLRequestContext* context = profile()->GetRequestContext(); |
868 ExtensionMessageService* ems = ExtensionMessageService::GetInstance(context); | 887 ExtensionMessageService* ems = ExtensionMessageService::GetInstance(context); |
869 ems->RemoveEventListener(event_name, pid()); | 888 ems->RemoveEventListener(event_name, pid()); |
870 } | 889 } |
OLD | NEW |