OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/browser/browser_init.h" | 5 #include "chrome/browser/browser_init.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/event_recorder.h" | 9 #include "base/event_recorder.h" |
10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 void SetOverrideHomePage(const CommandLine& command_line, | 107 void SetOverrideHomePage(const CommandLine& command_line, |
108 PrefService* prefs) { | 108 PrefService* prefs) { |
109 // If homepage is specified on the command line, canonify & store it. | 109 // If homepage is specified on the command line, canonify & store it. |
110 if (command_line.HasSwitch(switches::kHomePage)) { | 110 if (command_line.HasSwitch(switches::kHomePage)) { |
111 std::wstring browser_directory; | 111 std::wstring browser_directory; |
112 PathService::Get(base::DIR_CURRENT, &browser_directory); | 112 PathService::Get(base::DIR_CURRENT, &browser_directory); |
113 std::wstring new_homepage = URLFixerUpper::FixupRelativeFile( | 113 std::wstring new_homepage = URLFixerUpper::FixupRelativeFile( |
114 browser_directory, | 114 browser_directory, |
115 command_line.GetSwitchValue(switches::kHomePage)); | 115 command_line.GetSwitchValue(switches::kHomePage)); |
116 prefs->transient()->SetString(prefs::kHomePage, new_homepage); | 116 prefs->transient()->SetString(WideToUTF16Hack(prefs::kHomePage), |
117 prefs->transient()->SetBoolean(prefs::kHomePageIsNewTabPage, false); | 117 WideToUTF16Hack(new_homepage)); |
| 118 prefs->transient()->SetBoolean( |
| 119 WideToUTF16Hack(prefs::kHomePageIsNewTabPage), false); |
118 } | 120 } |
119 } | 121 } |
120 | 122 |
121 SessionStartupPref GetSessionStartupPref(const CommandLine& command_line, | 123 SessionStartupPref GetSessionStartupPref(const CommandLine& command_line, |
122 Profile* profile) { | 124 Profile* profile) { |
123 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile); | 125 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile); |
124 if (command_line.HasSwitch(switches::kRestoreLastSession)) | 126 if (command_line.HasSwitch(switches::kRestoreLastSession)) |
125 pref.type = SessionStartupPref::LAST; | 127 pref.type = SessionStartupPref::LAST; |
126 if (command_line.HasSwitch(switches::kIncognito) && | 128 if (command_line.HasSwitch(switches::kIncognito) && |
127 pref.type == SessionStartupPref::LAST) { | 129 pref.type == SessionStartupPref::LAST) { |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 profile, | 469 profile, |
468 static_cast<size_t>(expected_tab_count)); | 470 static_cast<size_t>(expected_tab_count)); |
469 } | 471 } |
470 #endif | 472 #endif |
471 } | 473 } |
472 | 474 |
473 // Allow the command line to override the persisted setting of home page. | 475 // Allow the command line to override the persisted setting of home page. |
474 SetOverrideHomePage(command_line, profile->GetPrefs()); | 476 SetOverrideHomePage(command_line, profile->GetPrefs()); |
475 | 477 |
476 if (command_line.HasSwitch(switches::kBrowserStartRenderersManually)) | 478 if (command_line.HasSwitch(switches::kBrowserStartRenderersManually)) |
477 prefs->transient()->SetBoolean(prefs::kStartRenderersManually, true); | 479 prefs->transient()->SetBoolean( |
| 480 WideToUTF16Hack(prefs::kStartRenderersManually), true); |
478 | 481 |
479 bool silent_launch = false; | 482 bool silent_launch = false; |
480 #if defined(OS_WIN) | 483 #if defined(OS_WIN) |
481 if (command_line.HasSwitch(switches::kAutomationClientChannelID)) { | 484 if (command_line.HasSwitch(switches::kAutomationClientChannelID)) { |
482 std::wstring automation_channel_id = | 485 std::wstring automation_channel_id = |
483 command_line.GetSwitchValue(switches::kAutomationClientChannelID); | 486 command_line.GetSwitchValue(switches::kAutomationClientChannelID); |
484 // If there are any loose parameters, we expect each one to generate a | 487 // If there are any loose parameters, we expect each one to generate a |
485 // new tab; if there are none then we have no tabs | 488 // new tab; if there are none then we have no tabs |
486 size_t expected_tabs = | 489 size_t expected_tabs = |
487 std::max(static_cast<int>(command_line.GetLooseValues().size()), | 490 std::max(static_cast<int>(command_line.GetLooseValues().size()), |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 bool launched = lwp.Launch(profile, process_startup); | 565 bool launched = lwp.Launch(profile, process_startup); |
563 if (!launched) { | 566 if (!launched) { |
564 LOG(ERROR) << "launch error"; | 567 LOG(ERROR) << "launch error"; |
565 if (return_code != NULL) | 568 if (return_code != NULL) |
566 *return_code = ResultCodes::INVALID_CMDLINE_URL; | 569 *return_code = ResultCodes::INVALID_CMDLINE_URL; |
567 return false; | 570 return false; |
568 } | 571 } |
569 | 572 |
570 return true; | 573 return true; |
571 } | 574 } |
OLD | NEW |