Chromium Code Reviews| 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 "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
| 17 | 17 |
| 18 class Browser; | 18 class Browser; |
| 19 class CommandLine; | 19 class CommandLine; |
| 20 class GURL; | 20 class GURL; |
| 21 class PrefService; | 21 class PrefService; |
| 22 class TabContentsWrapper; | 22 class TabContentsWrapper; |
| 23 | 23 |
| 24 // 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 |
| 25 // initialize the profile. | 25 // initialize the profile. |
| 26 class BrowserInit { | 26 class BrowserInit { |
| 27 public: | 27 public: |
| 28 typedef std::vector<Profile*> Profiles; | |
| 29 | |
| 28 enum IsProcessStartup { | 30 enum IsProcessStartup { |
| 29 IS_NOT_PROCESS_STARTUP, | 31 IS_NOT_PROCESS_STARTUP, |
| 30 IS_PROCESS_STARTUP | 32 IS_PROCESS_STARTUP |
| 31 }; | 33 }; |
| 32 enum IsFirstRun { | 34 enum IsFirstRun { |
| 33 IS_NOT_FIRST_RUN, | 35 IS_NOT_FIRST_RUN, |
| 34 IS_FIRST_RUN | 36 IS_FIRST_RUN |
| 35 }; | 37 }; |
| 36 | 38 |
| 37 BrowserInit(); | 39 BrowserInit(); |
| 38 ~BrowserInit(); | 40 ~BrowserInit(); |
| 39 | 41 |
| 40 // Adds a url to be opened during first run. This overrides the standard | 42 // Adds a url to be opened during first run. This overrides the standard |
| 41 // tabs shown at first run. | 43 // tabs shown at first run. |
| 42 void AddFirstRunTab(const GURL& url); | 44 void AddFirstRunTab(const GURL& url); |
| 43 | 45 |
| 44 // This function is equivalent to ProcessCommandLine but should only be | 46 // This function is equivalent to ProcessCommandLine but should only be |
| 45 // called during actual process startup. | 47 // called during actual process startup. |
| 46 bool Start(const CommandLine& cmd_line, const FilePath& cur_dir, | 48 bool Start(const CommandLine& cmd_line, |
| 47 Profile* profile, int* return_code) { | 49 const FilePath& cur_dir, |
| 48 return ProcessCmdLineImpl(cmd_line, cur_dir, true, profile, return_code, | 50 Profile* last_used_profile, |
|
Peter Kasting
2012/01/11 18:38:01
Nit: If you're going to mess with the names, I thi
marja
2012/01/12 09:20:22
Yes. ProfileManager already had LastUsedProfile()
| |
| 49 this); | 51 const Profiles& last_active_profiles, |
| 52 int* return_code) { | |
| 53 return ProcessCmdLineImpl(cmd_line, cur_dir, true, last_used_profile, | |
| 54 last_active_profiles, return_code, this); | |
| 50 } | 55 } |
| 51 | 56 |
| 52 // This function performs command-line handling and is invoked only after | 57 // This function performs command-line handling and is invoked only after |
| 53 // start up (for example when we get a start request for another process). | 58 // start up (for example when we get a start request for another process). |
| 54 // |command_line| holds the command line we need to process | 59 // |command_line| holds the command line we need to process |
| 55 static void ProcessCommandLineAlreadyRunning(const CommandLine& cmd_line, | 60 static void ProcessCommandLineAlreadyRunning(const CommandLine& cmd_line, |
| 56 const FilePath& cur_dir); | 61 const FilePath& cur_dir); |
| 57 | 62 |
| 58 template <class AutomationProviderClass> | 63 template <class AutomationProviderClass> |
| 59 static bool CreateAutomationProvider(const std::string& channel_id, | 64 static bool CreateAutomationProvider(const std::string& channel_id, |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 | 246 |
| 242 private: | 247 private: |
| 243 // Returns the list of URLs to open from the command line. The returned | 248 // Returns the list of URLs to open from the command line. The returned |
| 244 // vector is empty if the user didn't specify any URLs on the command line. | 249 // vector is empty if the user didn't specify any URLs on the command line. |
| 245 static std::vector<GURL> GetURLsFromCommandLine( | 250 static std::vector<GURL> GetURLsFromCommandLine( |
| 246 const CommandLine& command_line, | 251 const CommandLine& command_line, |
| 247 const FilePath& cur_dir, | 252 const FilePath& cur_dir, |
| 248 Profile* profile); | 253 Profile* profile); |
| 249 | 254 |
| 250 static bool ProcessCmdLineImpl(const CommandLine& command_line, | 255 static bool ProcessCmdLineImpl(const CommandLine& command_line, |
| 251 const FilePath& cur_dir, bool process_startup, | 256 const FilePath& cur_dir, |
| 252 Profile* profile, int* return_code, | 257 bool process_startup, |
| 258 Profile* last_used_profile, | |
| 259 const Profiles& last_active_profiles, | |
| 260 int* return_code, | |
| 253 BrowserInit* browser_init); | 261 BrowserInit* browser_init); |
| 254 | 262 |
| 255 // Callback after a profile has been created. | 263 // Callback after a profile has been created. |
| 256 static void ProcessCommandLineOnProfileCreated( | 264 static void ProcessCommandLineOnProfileCreated( |
| 257 const CommandLine& cmd_line, | 265 const CommandLine& cmd_line, |
| 258 const FilePath& cur_dir, | 266 const FilePath& cur_dir, |
| 259 Profile* profile, | 267 Profile* profile, |
| 260 Profile::CreateStatus status); | 268 Profile::CreateStatus status); |
| 261 | 269 |
| 262 // Additional tabs to open during first run. | 270 // Additional tabs to open during first run. |
| 263 std::vector<GURL> first_run_tabs_; | 271 std::vector<GURL> first_run_tabs_; |
| 264 | 272 |
| 265 DISALLOW_COPY_AND_ASSIGN(BrowserInit); | 273 DISALLOW_COPY_AND_ASSIGN(BrowserInit); |
| 266 }; | 274 }; |
| 267 | 275 |
| 268 #endif // CHROME_BROWSER_UI_BROWSER_INIT_H_ | 276 #endif // CHROME_BROWSER_UI_BROWSER_INIT_H_ |
| OLD | NEW |