| 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) | 140 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| 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) |
| 146 // Possible results of ShowTryChromeDialog(). | 147 // Possible results of ShowTryChromeDialog(). |
| 147 enum TryResult { | 148 enum TryResult { |
| 148 TD_TRY_CHROME, // Launch chrome right now. | 149 TD_TRY_CHROME, // Launch chrome right now. |
| 149 TD_NOT_NOW, // Don't launch chrome. Exit now. | 150 TD_NOT_NOW, // Don't launch chrome. Exit now. |
| 150 TD_UNINSTALL_CHROME, // Initiate chrome uninstall and exit. | 151 TD_UNINSTALL_CHROME, // Initiate chrome uninstall and exit. |
| 151 TD_DIALOG_ERROR, // An error occurred creating the dialog. | 152 TD_DIALOG_ERROR, // An error occurred creating the dialog. |
| 152 TD_LAST_ENUM | 153 TD_LAST_ENUM |
| 153 }; | 154 }; |
| 154 | 155 |
| 155 // Check if current chrome.exe is already running as a browser process by | 156 // Check if current chrome.exe is already running as a browser process by |
| 156 // trying to create a Global event with name same as full path of chrome.exe. | 157 // trying to create a Global event with name same as full path of chrome.exe. |
| 157 // This method caches the handle to this event so on subsequent calls also | 158 // This method caches the handle to this event so on subsequent calls also |
| 158 // it can first close the handle and check for any other process holding the | 159 // it can first close the handle and check for any other process holding the |
| 159 // handle to the event. | 160 // handle to the event. |
| 160 static bool IsBrowserAlreadyRunning(); | 161 static bool IsBrowserAlreadyRunning(); |
| 161 | 162 |
| 162 // Launches chrome again simulating a 'user' launch. If chrome could not | 163 // Launches chrome again simulating a 'user' launch. If chrome could not |
| 163 // be launched the return is false. | 164 // be launched the return is false. |
| 164 static bool RelaunchChromeBrowser(const CommandLine& command_line); | 165 static bool RelaunchChromeBrowser(const CommandLine& command_line); |
| 165 | 166 |
| 166 // If the new_chrome.exe exists (placed by the installer then is swapped | 167 // If the new_chrome.exe exists (placed by the installer then is swapped |
| 167 // to chrome.exe and the old chrome is renamed to old_chrome.exe. If there | 168 // to chrome.exe and the old chrome is renamed to old_chrome.exe. If there |
| 168 // is no new_chrome.exe or the swap fails the return is false; | 169 // is no new_chrome.exe or the swap fails the return is false; |
| 169 static bool SwapNewChromeExeIfPresent(); | 170 static bool SwapNewChromeExeIfPresent(); |
| 170 | 171 |
| 171 // Combines the two methods above to perform the rename and relaunch of | 172 // Combines the two methods, RelaunchChromeBrowser and |
| 173 // SwapNewChromeExeIfPresent, to perform the rename and relaunch of |
| 172 // the browser. Note that relaunch does NOT exit the existing browser process. | 174 // the browser. Note that relaunch does NOT exit the existing browser process. |
| 173 // If this is called before message loop is executed, simply exit the main | 175 // If this is called before message loop is executed, simply exit the main |
| 174 // function. If browser is already running, you will need to exit it. | 176 // function. If browser is already running, you will need to exit it. |
| 175 static bool DoUpgradeTasks(const CommandLine& command_line); | 177 static bool DoUpgradeTasks(const CommandLine& command_line); |
| 176 | 178 |
| 177 // Checks if chrome_new.exe is present in the current instance's install. | |
| 178 static bool IsUpdatePendingRestart(); | |
| 179 | |
| 180 // Shows a modal dialog asking the user to give chrome another try. See | 179 // Shows a modal dialog asking the user to give chrome another try. See |
| 181 // above for the possible outcomes of the function. This is an experimental, | 180 // above for the possible outcomes of the function. This is an experimental, |
| 182 // non-localized dialog. | 181 // non-localized dialog. |
| 183 // |version| can be 0, 1 or 2 and selects what strings to present. | 182 // |version| can be 0, 1 or 2 and selects what strings to present. |
| 184 static TryResult ShowTryChromeDialog(size_t version); | 183 static TryResult ShowTryChromeDialog(size_t version); |
| 184 #endif // OS_WIN |
| 185 |
| 186 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 187 static void SaveLastModifiedTimeOfExe(); |
| 188 #endif |
| 189 |
| 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_; |
| 185 }; | 212 }; |
| 186 #endif | 213 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| 187 | 214 |
| 188 // A subclass of BrowserProcessImpl that does not have a GoogleURLTracker or | 215 // A subclass of BrowserProcessImpl that does not have a GoogleURLTracker or |
| 189 // IntranetRedirectDetector so we don't do any URL fetches (as we have no IO | 216 // IntranetRedirectDetector so we don't do any URL fetches (as we have no IO |
| 190 // thread to fetch on). | 217 // thread to fetch on). |
| 191 class FirstRunBrowserProcess : public BrowserProcessImpl { | 218 class FirstRunBrowserProcess : public BrowserProcessImpl { |
| 192 public: | 219 public: |
| 193 explicit FirstRunBrowserProcess(const CommandLine& command_line) | 220 explicit FirstRunBrowserProcess(const CommandLine& command_line) |
| 194 : BrowserProcessImpl(command_line) { | 221 : BrowserProcessImpl(command_line) { |
| 195 } | 222 } |
| 196 virtual ~FirstRunBrowserProcess() { } | 223 virtual ~FirstRunBrowserProcess() { } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 // Returns true if the user clicked "Start", false if the user pressed "Cancel" | 268 // Returns true if the user clicked "Start", false if the user pressed "Cancel" |
| 242 // or closed the dialog. | 269 // or closed the dialog. |
| 243 bool OpenFirstRunDialog(Profile* profile, | 270 bool OpenFirstRunDialog(Profile* profile, |
| 244 bool homepage_defined, | 271 bool homepage_defined, |
| 245 int import_items, | 272 int import_items, |
| 246 int dont_import_items, | 273 int dont_import_items, |
| 247 bool search_engine_experiment, | 274 bool search_engine_experiment, |
| 248 ProcessSingleton* process_singleton); | 275 ProcessSingleton* process_singleton); |
| 249 | 276 |
| 250 #endif // CHROME_BROWSER_FIRST_RUN_H_ | 277 #endif // CHROME_BROWSER_FIRST_RUN_H_ |
| OLD | NEW |