| 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 switches::kEnableDatabases, | 342 switches::kEnableDatabases, |
| 343 }; | 343 }; |
| 344 | 344 |
| 345 for (size_t i = 0; i < arraysize(switch_names); ++i) { | 345 for (size_t i = 0; i < arraysize(switch_names); ++i) { |
| 346 if (browser_command_line.HasSwitch(switch_names[i])) { | 346 if (browser_command_line.HasSwitch(switch_names[i])) { |
| 347 cmd_line.AppendSwitchWithValue(switch_names[i], | 347 cmd_line.AppendSwitchWithValue(switch_names[i], |
| 348 browser_command_line.GetSwitchValue(switch_names[i])); | 348 browser_command_line.GetSwitchValue(switch_names[i])); |
| 349 } | 349 } |
| 350 } | 350 } |
| 351 | 351 |
| 352 // Tell the renderer to enable extensions if there are any extensions loaded. |
| 353 // |
| 354 // NOTE: This is subtly different than just passing along whether |
| 355 // --enable-extenisons is present in the browser process. For example, there |
| 356 // is also an extensions.enabled preference, and there may be various special |
| 357 // cases about whether to allow extensions to load. |
| 358 // |
| 359 // This introduces a race condition where the first renderer never gets |
| 360 // extensions enabled, so we also set the flag if extensions_enabled(). This |
| 361 // isn't perfect though, because of the special cases above. |
| 362 // |
| 363 // TODO(aa): We need to get rid of the need to pass this flag at all. It is |
| 364 // only used in one place in the renderer. |
| 365 if (profile()->GetExtensionsService()) { |
| 366 if (profile()->GetExtensionsService()->extensions()->size() > 0 || |
| 367 profile()->GetExtensionsService()->extensions_enabled()) |
| 368 cmd_line.AppendSwitch(switches::kEnableExtensions); |
| 369 } |
| 370 |
| 352 // Pass on the browser locale. | 371 // Pass on the browser locale. |
| 353 const std::string locale = g_browser_process->GetApplicationLocale(); | 372 const std::string locale = g_browser_process->GetApplicationLocale(); |
| 354 cmd_line.AppendSwitchWithValue(switches::kLang, ASCIIToWide(locale)); | 373 cmd_line.AppendSwitchWithValue(switches::kLang, ASCIIToWide(locale)); |
| 355 | 374 |
| 356 // If we run FieldTrials, we want to pass to their state to the renderer so | 375 // If we run FieldTrials, we want to pass to their state to the renderer so |
| 357 // that it can act in accordance with each state, or record histograms | 376 // that it can act in accordance with each state, or record histograms |
| 358 // relating to the FieldTrial states. | 377 // relating to the FieldTrial states. |
| 359 std::string field_trial_states; | 378 std::string field_trial_states; |
| 360 FieldTrialList::StatesToString(&field_trial_states); | 379 FieldTrialList::StatesToString(&field_trial_states); |
| 361 if (!field_trial_states.empty()) | 380 if (!field_trial_states.empty()) |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 profile()->GetExtensionMessageService()->RemoveEventListener( | 978 profile()->GetExtensionMessageService()->RemoveEventListener( |
| 960 event_name, id()); | 979 event_name, id()); |
| 961 } | 980 } |
| 962 } | 981 } |
| 963 | 982 |
| 964 void BrowserRenderProcessHost::OnExtensionCloseChannel(int port_id) { | 983 void BrowserRenderProcessHost::OnExtensionCloseChannel(int port_id) { |
| 965 if (profile()->GetExtensionMessageService()) { | 984 if (profile()->GetExtensionMessageService()) { |
| 966 profile()->GetExtensionMessageService()->CloseChannel(port_id); | 985 profile()->GetExtensionMessageService()->CloseChannel(port_id); |
| 967 } | 986 } |
| 968 } | 987 } |
| OLD | NEW |