| 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/file_path.h" |
| 10 #include "base/histogram.h" | 11 #include "base/histogram.h" |
| 11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 12 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 13 #include "base/sys_info.h" | 14 #include "base/sys_info.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete.h" | 15 #include "chrome/browser/autocomplete/autocomplete.h" |
| 15 #include "chrome/browser/automation/automation_provider.h" | 16 #include "chrome/browser/automation/automation_provider.h" |
| 16 #include "chrome/browser/automation/automation_provider_list.h" | 17 #include "chrome/browser/automation/automation_provider_list.h" |
| 17 #include "chrome/browser/browser_list.h" | 18 #include "chrome/browser/browser_list.h" |
| 18 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/extensions/extensions_service.h" | 20 #include "chrome/browser/extensions/extensions_service.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // The Profile that we restore sessions from. | 91 // The Profile that we restore sessions from. |
| 91 Profile* profile_; | 92 Profile* profile_; |
| 92 | 93 |
| 93 DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate); | 94 DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate); |
| 94 }; | 95 }; |
| 95 | 96 |
| 96 void SetOverrideHomePage(const CommandLine& command_line, | 97 void SetOverrideHomePage(const CommandLine& command_line, |
| 97 PrefService* prefs) { | 98 PrefService* prefs) { |
| 98 // If homepage is specified on the command line, canonify & store it. | 99 // If homepage is specified on the command line, canonify & store it. |
| 99 if (command_line.HasSwitch(switches::kHomePage)) { | 100 if (command_line.HasSwitch(switches::kHomePage)) { |
| 100 std::wstring browser_directory; | 101 FilePath browser_directory; |
| 101 PathService::Get(base::DIR_CURRENT, &browser_directory); | 102 PathService::Get(base::DIR_CURRENT, &browser_directory); |
| 102 std::wstring new_homepage = URLFixerUpper::FixupRelativeFile( | 103 std::wstring new_homepage = URLFixerUpper::FixupRelativeFile( |
| 103 browser_directory, | 104 browser_directory.ToWStringHack(), |
| 104 command_line.GetSwitchValue(switches::kHomePage)); | 105 command_line.GetSwitchValue(switches::kHomePage)); |
| 105 prefs->transient()->SetString(prefs::kHomePage, new_homepage); | 106 prefs->transient()->SetString(prefs::kHomePage, new_homepage); |
| 106 prefs->transient()->SetBoolean(prefs::kHomePageIsNewTabPage, false); | 107 prefs->transient()->SetBoolean(prefs::kHomePageIsNewTabPage, false); |
| 107 } | 108 } |
| 108 } | 109 } |
| 109 | 110 |
| 110 SessionStartupPref GetSessionStartupPref(const CommandLine& command_line, | 111 SessionStartupPref GetSessionStartupPref(const CommandLine& command_line, |
| 111 Profile* profile) { | 112 Profile* profile) { |
| 112 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile); | 113 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile); |
| 113 if (command_line.HasSwitch(switches::kRestoreLastSession)) | 114 if (command_line.HasSwitch(switches::kRestoreLastSession)) |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 browser = BrowserList::GetLastActive(); | 244 browser = BrowserList::GetLastActive(); |
| 244 OpenURLsInBrowser(browser, process_startup, urls_to_open); | 245 OpenURLsInBrowser(browser, process_startup, urls_to_open); |
| 245 } | 246 } |
| 246 } else { | 247 } else { |
| 247 RecordLaunchModeHistogram(LM_AS_WEBAPP); | 248 RecordLaunchModeHistogram(LM_AS_WEBAPP); |
| 248 } | 249 } |
| 249 | 250 |
| 250 // If we're recording or playing back, startup the EventRecorder now | 251 // If we're recording or playing back, startup the EventRecorder now |
| 251 // unless otherwise specified. | 252 // unless otherwise specified. |
| 252 if (!command_line_.HasSwitch(switches::kNoEvents)) { | 253 if (!command_line_.HasSwitch(switches::kNoEvents)) { |
| 253 std::wstring script_path; | 254 FilePath script_path; |
| 254 PathService::Get(chrome::FILE_RECORDED_SCRIPT, &script_path); | 255 PathService::Get(chrome::FILE_RECORDED_SCRIPT, &script_path); |
| 255 | 256 |
| 256 bool record_mode = command_line_.HasSwitch(switches::kRecordMode); | 257 bool record_mode = command_line_.HasSwitch(switches::kRecordMode); |
| 257 bool playback_mode = command_line_.HasSwitch(switches::kPlaybackMode); | 258 bool playback_mode = command_line_.HasSwitch(switches::kPlaybackMode); |
| 258 | 259 |
| 259 if (record_mode && chrome::kRecordModeEnabled) | 260 if (record_mode && chrome::kRecordModeEnabled) |
| 260 base::EventRecorder::current()->StartRecording(script_path); | 261 base::EventRecorder::current()->StartRecording(script_path); |
| 261 if (playback_mode) | 262 if (playback_mode) |
| 262 base::EventRecorder::current()->StartPlayback(script_path); | 263 base::EventRecorder::current()->StartPlayback(script_path); |
| 263 } | 264 } |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 bool launched = lwp.Launch(profile, process_startup); | 553 bool launched = lwp.Launch(profile, process_startup); |
| 553 if (!launched) { | 554 if (!launched) { |
| 554 LOG(ERROR) << "launch error"; | 555 LOG(ERROR) << "launch error"; |
| 555 if (return_code != NULL) | 556 if (return_code != NULL) |
| 556 *return_code = ResultCodes::INVALID_CMDLINE_URL; | 557 *return_code = ResultCodes::INVALID_CMDLINE_URL; |
| 557 return false; | 558 return false; |
| 558 } | 559 } |
| 559 | 560 |
| 560 return true; | 561 return true; |
| 561 } | 562 } |
| OLD | NEW |