| 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 #ifndef CHROME_BROWSER_FIRST_RUN_H_ | 5 #ifndef CHROME_BROWSER_FIRST_RUN_H_ |
| 6 #define CHROME_BROWSER_FIRST_RUN_H_ | 6 #define CHROME_BROWSER_FIRST_RUN_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 #elif defined(OS_LINUX) | 130 #elif defined(OS_LINUX) |
| 131 static bool ImportBookmarks(const std::wstring& import_bookmarks_path); | 131 static bool ImportBookmarks(const std::wstring& import_bookmarks_path); |
| 132 #endif | 132 #endif |
| 133 // Import bookmarks from an html file. The path to the file is provided in | 133 // Import bookmarks from an html file. The path to the file is provided in |
| 134 // the command line. | 134 // the command line. |
| 135 static int ImportFromFile(Profile* profile, const CommandLine& cmdline); | 135 static int ImportFromFile(Profile* profile, const CommandLine& cmdline); |
| 136 // This class is for scoping purposes. | 136 // This class is for scoping purposes. |
| 137 DISALLOW_IMPLICIT_CONSTRUCTORS(FirstRun); | 137 DISALLOW_IMPLICIT_CONSTRUCTORS(FirstRun); |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 140 #if defined(OS_WIN) |
| 141 // This class contains the actions that need to be performed when an upgrade | 141 // This class contains the actions that need to be performed when an upgrade |
| 142 // is required. This involves mainly swapping the chrome exe and relaunching | 142 // is required. This involves mainly swapping the chrome exe and relaunching |
| 143 // the new browser. | 143 // the new browser. |
| 144 class Upgrade { | 144 class Upgrade { |
| 145 public: | 145 public: |
| 146 #if defined(OS_WIN) | |
| 147 // Possible results of ShowTryChromeDialog(). | 146 // Possible results of ShowTryChromeDialog(). |
| 148 enum TryResult { | 147 enum TryResult { |
| 149 TD_TRY_CHROME, // Launch chrome right now. | 148 TD_TRY_CHROME, // Launch chrome right now. |
| 150 TD_NOT_NOW, // Don't launch chrome. Exit now. | 149 TD_NOT_NOW, // Don't launch chrome. Exit now. |
| 151 TD_UNINSTALL_CHROME, // Initiate chrome uninstall and exit. | 150 TD_UNINSTALL_CHROME, // Initiate chrome uninstall and exit. |
| 152 TD_DIALOG_ERROR, // An error occurred creating the dialog. | 151 TD_DIALOG_ERROR, // An error occurred creating the dialog. |
| 153 TD_LAST_ENUM | 152 TD_LAST_ENUM |
| 154 }; | 153 }; |
| 155 | 154 |
| 156 // Check if current chrome.exe is already running as a browser process by | 155 // Check if current chrome.exe is already running as a browser process by |
| 157 // trying to create a Global event with name same as full path of chrome.exe. | 156 // trying to create a Global event with name same as full path of chrome.exe. |
| 158 // This method caches the handle to this event so on subsequent calls also | 157 // This method caches the handle to this event so on subsequent calls also |
| 159 // it can first close the handle and check for any other process holding the | 158 // it can first close the handle and check for any other process holding the |
| 160 // handle to the event. | 159 // handle to the event. |
| 161 static bool IsBrowserAlreadyRunning(); | 160 static bool IsBrowserAlreadyRunning(); |
| 162 | 161 |
| 163 // Launches chrome again simulating a 'user' launch. If chrome could not | 162 // Launches chrome again simulating a 'user' launch. If chrome could not |
| 164 // be launched the return is false. | 163 // be launched the return is false. |
| 165 static bool RelaunchChromeBrowser(const CommandLine& command_line); | 164 static bool RelaunchChromeBrowser(const CommandLine& command_line); |
| 166 | 165 |
| 167 // If the new_chrome.exe exists (placed by the installer then is swapped | 166 // If the new_chrome.exe exists (placed by the installer then is swapped |
| 168 // to chrome.exe and the old chrome is renamed to old_chrome.exe. If there | 167 // to chrome.exe and the old chrome is renamed to old_chrome.exe. If there |
| 169 // is no new_chrome.exe or the swap fails the return is false; | 168 // is no new_chrome.exe or the swap fails the return is false; |
| 170 static bool SwapNewChromeExeIfPresent(); | 169 static bool SwapNewChromeExeIfPresent(); |
| 171 | 170 |
| 172 // Combines the two methods, RelaunchChromeBrowser and | 171 // Combines the two methods above to perform the rename and relaunch of |
| 173 // SwapNewChromeExeIfPresent, to perform the rename and relaunch of | |
| 174 // the browser. Note that relaunch does NOT exit the existing browser process. | 172 // the browser. Note that relaunch does NOT exit the existing browser process. |
| 175 // If this is called before message loop is executed, simply exit the main | 173 // If this is called before message loop is executed, simply exit the main |
| 176 // function. If browser is already running, you will need to exit it. | 174 // function. If browser is already running, you will need to exit it. |
| 177 static bool DoUpgradeTasks(const CommandLine& command_line); | 175 static bool DoUpgradeTasks(const CommandLine& command_line); |
| 178 | 176 |
| 177 // Checks if chrome_new.exe is present in the current instance's install. |
| 178 static bool IsUpdatePendingRestart(); |
| 179 |
| 179 // Shows a modal dialog asking the user to give chrome another try. See | 180 // Shows a modal dialog asking the user to give chrome another try. See |
| 180 // above for the possible outcomes of the function. This is an experimental, | 181 // above for the possible outcomes of the function. This is an experimental, |
| 181 // non-localized dialog. | 182 // non-localized dialog. |
| 182 // |version| can be 0, 1 or 2 and selects what strings to present. | 183 // |version| can be 0, 1 or 2 and selects what strings to present. |
| 183 static TryResult ShowTryChromeDialog(size_t version); | 184 static TryResult ShowTryChromeDialog(size_t version); |
| 184 #endif // OS_WIN | 185 }; |
| 185 | |
| 186 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 187 static void SaveLastModifiedTimeOfExe(); | |
| 188 #endif | 186 #endif |
| 189 | 187 |
| 190 static void SetNewCommandLine(CommandLine* new_command_line) { | |
| 191 // Takes ownership of the pointer. | |
| 192 new_command_line_ = new_command_line; | |
| 193 } | |
| 194 | |
| 195 // Launches a new instance of the browser if the current instance in | |
| 196 // persistent mode an upgrade is detected. | |
| 197 static void RelaunchChromeBrowserWithNewCommandLineIfNeeded(); | |
| 198 | |
| 199 // Windows: | |
| 200 // Checks if chrome_new.exe is present in the current instance's install. | |
| 201 // Linux: | |
| 202 // Checks if the last modified time of chrome is newer than that of the | |
| 203 // current running instance. | |
| 204 static bool IsUpdatePendingRestart(); | |
| 205 | |
| 206 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 207 private: | |
| 208 static double GetLastModifiedTimeOfExe(); | |
| 209 static double saved_last_modified_time_of_exe_; | |
| 210 #endif | |
| 211 static CommandLine* new_command_line_; | |
| 212 }; | |
| 213 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | |
| 214 | |
| 215 // A subclass of BrowserProcessImpl that does not have a GoogleURLTracker or | 188 // A subclass of BrowserProcessImpl that does not have a GoogleURLTracker or |
| 216 // IntranetRedirectDetector so we don't do any URL fetches (as we have no IO | 189 // IntranetRedirectDetector so we don't do any URL fetches (as we have no IO |
| 217 // thread to fetch on). | 190 // thread to fetch on). |
| 218 class FirstRunBrowserProcess : public BrowserProcessImpl { | 191 class FirstRunBrowserProcess : public BrowserProcessImpl { |
| 219 public: | 192 public: |
| 220 explicit FirstRunBrowserProcess(const CommandLine& command_line) | 193 explicit FirstRunBrowserProcess(const CommandLine& command_line) |
| 221 : BrowserProcessImpl(command_line) { | 194 : BrowserProcessImpl(command_line) { |
| 222 } | 195 } |
| 223 virtual ~FirstRunBrowserProcess() { } | 196 virtual ~FirstRunBrowserProcess() { } |
| 224 | 197 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // Returns true if the user clicked "Start", false if the user pressed "Cancel" | 241 // Returns true if the user clicked "Start", false if the user pressed "Cancel" |
| 269 // or closed the dialog. | 242 // or closed the dialog. |
| 270 bool OpenFirstRunDialog(Profile* profile, | 243 bool OpenFirstRunDialog(Profile* profile, |
| 271 bool homepage_defined, | 244 bool homepage_defined, |
| 272 int import_items, | 245 int import_items, |
| 273 int dont_import_items, | 246 int dont_import_items, |
| 274 bool search_engine_experiment, | 247 bool search_engine_experiment, |
| 275 ProcessSingleton* process_singleton); | 248 ProcessSingleton* process_singleton); |
| 276 | 249 |
| 277 #endif // CHROME_BROWSER_FIRST_RUN_H_ | 250 #endif // CHROME_BROWSER_FIRST_RUN_H_ |
| OLD | NEW |