| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/first_run.h" | 5 #include "chrome/browser/first_run.h" |
| 6 | 6 |
| 7 #include "app/app_switches.h" | 7 #include "app/app_switches.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "chrome/browser/gtk/first_run_dialog.h" | 12 #include "chrome/browser/gtk/first_run_dialog.h" |
| 13 #include "chrome/browser/profile_manager.h" | 13 #include "chrome/browser/profile_manager.h" |
| 14 #include "chrome/browser/shell_integration.h" | 14 #include "chrome/browser/shell_integration.h" |
| 15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "chrome/common/result_codes.h" | 17 #include "chrome/common/result_codes.h" |
| 18 #include "chrome/installer/util/google_update_settings.h" | 18 #include "chrome/installer/util/google_update_settings.h" |
| 19 #include "chrome/installer/util/master_preferences.h" | 19 #include "chrome/installer/util/master_preferences.h" |
| 20 #include "chrome/installer/util/util_constants.h" | 20 #include "chrome/installer/util/util_constants.h" |
| 21 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
| 22 | 22 |
| 23 CommandLine* Upgrade::new_command_line_ = NULL; |
| 24 |
| 23 bool OpenFirstRunDialog(Profile* profile, bool homepage_defined, | 25 bool OpenFirstRunDialog(Profile* profile, bool homepage_defined, |
| 24 int import_items, | 26 int import_items, |
| 25 int dont_import_items, | 27 int dont_import_items, |
| 26 bool search_engine_experiment, | 28 bool search_engine_experiment, |
| 27 ProcessSingleton* process_singleton) { | 29 ProcessSingleton* process_singleton) { |
| 28 return FirstRunDialog::Show(profile, process_singleton); | 30 return FirstRunDialog::Show(profile, process_singleton); |
| 29 } | 31 } |
| 30 | 32 |
| 31 FilePath GetDefaultPrefFilePath(bool create_profile_dir, | 33 FilePath GetDefaultPrefFilePath(bool create_profile_dir, |
| 32 const FilePath& user_data_dir) { | 34 const FilePath& user_data_dir) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 import_cmd.AppendSwitchWithValue( | 134 import_cmd.AppendSwitchWithValue( |
| 133 switches::kLang, | 135 switches::kLang, |
| 134 ASCIIToWide(g_browser_process->GetApplicationLocale())); | 136 ASCIIToWide(g_browser_process->GetApplicationLocale())); |
| 135 | 137 |
| 136 import_cmd.CommandLine::AppendSwitchWithValue( | 138 import_cmd.CommandLine::AppendSwitchWithValue( |
| 137 switches::kImportFromFile, import_bookmarks_path); | 139 switches::kImportFromFile, import_bookmarks_path); |
| 138 // Time to launch the process that is going to do the import. We'll wait | 140 // Time to launch the process that is going to do the import. We'll wait |
| 139 // for the process to return. | 141 // for the process to return. |
| 140 return base::LaunchApp(import_cmd, true, false, NULL); | 142 return base::LaunchApp(import_cmd, true, false, NULL); |
| 141 } | 143 } |
| 144 |
| 145 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| 146 double Upgrade::saved_last_modified_time_of_exe_ = 0; |
| 147 |
| 148 // static |
| 149 bool Upgrade::IsUpdatePendingRestart() { |
| 150 return saved_last_modified_time_of_exe_ != |
| 151 Upgrade::GetLastModifiedTimeOfExe(); |
| 152 } |
| 153 |
| 154 // static |
| 155 void Upgrade::SaveLastModifiedTimeOfExe() { |
| 156 saved_last_modified_time_of_exe_ = Upgrade::GetLastModifiedTimeOfExe(); |
| 157 } |
| 158 |
| 159 // static |
| 160 void Upgrade::RelaunchChromeBrowserWithNewCommandLineIfNeeded() { |
| 161 if (new_command_line_) { |
| 162 if (!base::LaunchApp(*new_command_line_, false, false, NULL)) { |
| 163 DLOG(ERROR) << "Launching a new instance of the browser failed."; |
| 164 } else { |
| 165 DLOG(WARNING) << "Launched a new instance of the browser."; |
| 166 } |
| 167 delete new_command_line_; |
| 168 new_command_line_ = NULL; |
| 169 } |
| 170 } |
| 171 |
| 172 // static |
| 173 double Upgrade::GetLastModifiedTimeOfExe() { |
| 174 FilePath exe_file_path; |
| 175 if (!PathService::Get(base::FILE_EXE, &exe_file_path)) { |
| 176 LOG(WARNING) << "Failed to get FilePath object for FILE_EXE."; |
| 177 return saved_last_modified_time_of_exe_; |
| 178 } |
| 179 file_util::FileInfo exe_file_info; |
| 180 if (!file_util::GetFileInfo(exe_file_path, &exe_file_info)) { |
| 181 LOG(WARNING) << "Failed to get FileInfo object for FILE_EXE - " |
| 182 << exe_file_path.value(); |
| 183 return saved_last_modified_time_of_exe_; |
| 184 } |
| 185 return exe_file_info.last_modified.ToDoubleT(); |
| 186 } |
| 187 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| OLD | NEW |