| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_UI_BROWSER_INIT_H_ | 5 #ifndef CHROME_BROWSER_UI_BROWSER_INIT_H_ |
| 6 #define CHROME_BROWSER_UI_BROWSER_INIT_H_ | 6 #define CHROME_BROWSER_UI_BROWSER_INIT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 16 | 16 |
| 17 class Browser; | 17 class Browser; |
| 18 class CommandLine; | 18 class CommandLine; |
| 19 class GURL; | 19 class GURL; |
| 20 class Profile; | 20 class Profile; |
| 21 class PrefService; |
| 21 class TabContentsWrapper; | 22 class TabContentsWrapper; |
| 22 | 23 |
| 23 // class containing helpers for BrowserMain to spin up a new instance and | 24 // class containing helpers for BrowserMain to spin up a new instance and |
| 24 // initialize the profile. | 25 // initialize the profile. |
| 25 class BrowserInit { | 26 class BrowserInit { |
| 26 public: | 27 public: |
| 27 enum IsProcessStartup { | 28 enum IsProcessStartup { |
| 28 IS_NOT_PROCESS_STARTUP, | 29 IS_NOT_PROCESS_STARTUP, |
| 29 IS_PROCESS_STARTUP | 30 IS_PROCESS_STARTUP |
| 30 }; | 31 }; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 63 } |
| 63 | 64 |
| 64 template <class AutomationProviderClass> | 65 template <class AutomationProviderClass> |
| 65 static bool CreateAutomationProvider(const std::string& channel_id, | 66 static bool CreateAutomationProvider(const std::string& channel_id, |
| 66 Profile* profile, | 67 Profile* profile, |
| 67 size_t expected_tabs); | 68 size_t expected_tabs); |
| 68 | 69 |
| 69 // Returns true if the browser is coming up. | 70 // Returns true if the browser is coming up. |
| 70 static bool InProcessStartup(); | 71 static bool InProcessStartup(); |
| 71 | 72 |
| 73 static void RegisterUserPrefs(PrefService* prefs); |
| 74 |
| 72 // Launches a browser window associated with |profile|. |command_line| should | 75 // Launches a browser window associated with |profile|. |command_line| should |
| 73 // be the command line passed to this process. |cur_dir| can be empty, which | 76 // be the command line passed to this process. |cur_dir| can be empty, which |
| 74 // implies that the directory of the executable should be used. | 77 // implies that the directory of the executable should be used. |
| 75 // |process_startup| indicates whether this is the first browser. | 78 // |process_startup| indicates whether this is the first browser. |
| 76 // |is_first_run| indicates that this is a new profile. | 79 // |is_first_run| indicates that this is a new profile. |
| 77 bool LaunchBrowser(const CommandLine& command_line, | 80 bool LaunchBrowser(const CommandLine& command_line, |
| 78 Profile* profile, | 81 Profile* profile, |
| 79 const FilePath& cur_dir, | 82 const FilePath& cur_dir, |
| 80 IsProcessStartup is_process_startup, | 83 IsProcessStartup is_process_startup, |
| 81 IsFirstRun is_first_run, | 84 IsFirstRun is_first_run, |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 // about it. | 222 // about it. |
| 220 void AddObsoleteSystemInfoBarIfNecessary(TabContentsWrapper* tab); | 223 void AddObsoleteSystemInfoBarIfNecessary(TabContentsWrapper* tab); |
| 221 | 224 |
| 222 // Adds additional startup URLs to the specified vector. | 225 // Adds additional startup URLs to the specified vector. |
| 223 void AddStartupURLs(std::vector<GURL>* startup_urls) const; | 226 void AddStartupURLs(std::vector<GURL>* startup_urls) const; |
| 224 | 227 |
| 225 // Checks whether Chrome is still the default browser (unless the user | 228 // Checks whether Chrome is still the default browser (unless the user |
| 226 // previously instructed not to do so) and warns the user if it is not. | 229 // previously instructed not to do so) and warns the user if it is not. |
| 227 void CheckDefaultBrowser(Profile* profile); | 230 void CheckDefaultBrowser(Profile* profile); |
| 228 | 231 |
| 232 // Checks whether Chrome was auto-started at login. |
| 233 void CheckIfAutoLaunched(Profile* profile); |
| 234 |
| 229 const FilePath cur_dir_; | 235 const FilePath cur_dir_; |
| 230 const CommandLine& command_line_; | 236 const CommandLine& command_line_; |
| 231 Profile* profile_; | 237 Profile* profile_; |
| 232 BrowserInit* browser_init_; | 238 BrowserInit* browser_init_; |
| 233 bool is_first_run_; | 239 bool is_first_run_; |
| 234 DISALLOW_COPY_AND_ASSIGN(LaunchWithProfile); | 240 DISALLOW_COPY_AND_ASSIGN(LaunchWithProfile); |
| 235 }; | 241 }; |
| 236 | 242 |
| 237 private: | 243 private: |
| 238 // Returns the list of URLs to open from the command line. The returned | 244 // Returns the list of URLs to open from the command line. The returned |
| 239 // vector is empty if the user didn't specify any URLs on the command line. | 245 // vector is empty if the user didn't specify any URLs on the command line. |
| 240 static std::vector<GURL> GetURLsFromCommandLine( | 246 static std::vector<GURL> GetURLsFromCommandLine( |
| 241 const CommandLine& command_line, | 247 const CommandLine& command_line, |
| 242 const FilePath& cur_dir, | 248 const FilePath& cur_dir, |
| 243 Profile* profile); | 249 Profile* profile); |
| 244 | 250 |
| 245 static bool ProcessCmdLineImpl(const CommandLine& command_line, | 251 static bool ProcessCmdLineImpl(const CommandLine& command_line, |
| 246 const FilePath& cur_dir, bool process_startup, | 252 const FilePath& cur_dir, bool process_startup, |
| 247 Profile* profile, int* return_code, | 253 Profile* profile, int* return_code, |
| 248 BrowserInit* browser_init); | 254 BrowserInit* browser_init); |
| 249 | 255 |
| 250 // Additional tabs to open during first run. | 256 // Additional tabs to open during first run. |
| 251 std::vector<GURL> first_run_tabs_; | 257 std::vector<GURL> first_run_tabs_; |
| 252 | 258 |
| 253 DISALLOW_COPY_AND_ASSIGN(BrowserInit); | 259 DISALLOW_COPY_AND_ASSIGN(BrowserInit); |
| 254 }; | 260 }; |
| 255 | 261 |
| 256 #endif // CHROME_BROWSER_UI_BROWSER_INIT_H_ | 262 #endif // CHROME_BROWSER_UI_BROWSER_INIT_H_ |
| OLD | NEW |