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 TabContentsWrapper; | 21 class TabContentsWrapper; |
22 | 22 |
23 // class containing helpers for BrowserMain to spin up a new instance and | 23 // class containing helpers for BrowserMain to spin up a new instance and |
24 // initialize the profile. | 24 // initialize the profile. |
25 class BrowserInit { | 25 class BrowserInit { |
26 public: | 26 public: |
| 27 enum IsProcessStartup { |
| 28 IS_NOT_PROCESS_STARTUP, |
| 29 IS_PROCESS_STARTUP |
| 30 }; |
| 31 enum IsFirstRun { |
| 32 IS_NOT_FIRST_RUN, |
| 33 IS_FIRST_RUN |
| 34 }; |
| 35 |
27 BrowserInit(); | 36 BrowserInit(); |
28 ~BrowserInit(); | 37 ~BrowserInit(); |
29 | 38 |
30 // Adds a url to be opened during first run. This overrides the standard | 39 // Adds a url to be opened during first run. This overrides the standard |
31 // tabs shown at first run. | 40 // tabs shown at first run. |
32 void AddFirstRunTab(const GURL& url); | 41 void AddFirstRunTab(const GURL& url); |
33 | 42 |
34 // This function is equivalent to ProcessCommandLine but should only be | 43 // This function is equivalent to ProcessCommandLine but should only be |
35 // called during actual process startup. | 44 // called during actual process startup. |
36 bool Start(const CommandLine& cmd_line, const FilePath& cur_dir, | 45 bool Start(const CommandLine& cmd_line, const FilePath& cur_dir, |
(...skipping 20 matching lines...) Expand all Loading... |
57 Profile* profile, | 66 Profile* profile, |
58 size_t expected_tabs); | 67 size_t expected_tabs); |
59 | 68 |
60 // Returns true if the browser is coming up. | 69 // Returns true if the browser is coming up. |
61 static bool InProcessStartup(); | 70 static bool InProcessStartup(); |
62 | 71 |
63 // Launches a browser window associated with |profile|. |command_line| should | 72 // Launches a browser window associated with |profile|. |command_line| should |
64 // be the command line passed to this process. |cur_dir| can be empty, which | 73 // be the command line passed to this process. |cur_dir| can be empty, which |
65 // implies that the directory of the executable should be used. | 74 // implies that the directory of the executable should be used. |
66 // |process_startup| indicates whether this is the first browser. | 75 // |process_startup| indicates whether this is the first browser. |
67 bool LaunchBrowser(const CommandLine& command_line, Profile* profile, | 76 // |is_first_run| indicates that this is a new profile. |
68 const FilePath& cur_dir, bool process_startup, | 77 bool LaunchBrowser(const CommandLine& command_line, |
| 78 Profile* profile, |
| 79 const FilePath& cur_dir, |
| 80 IsProcessStartup is_process_startup, |
| 81 IsFirstRun is_first_run, |
69 int* return_code); | 82 int* return_code); |
70 | 83 |
71 // LaunchWithProfile --------------------------------------------------------- | 84 // LaunchWithProfile --------------------------------------------------------- |
72 // | 85 // |
73 // Assists launching the application and appending the initial tabs for a | 86 // Assists launching the application and appending the initial tabs for a |
74 // browser window. | 87 // browser window. |
75 | 88 |
76 class LaunchWithProfile { | 89 class LaunchWithProfile { |
77 public: | 90 public: |
78 // Used by OpenTabsInBrowser. | 91 // Used by OpenTabsInBrowser. |
(...skipping 11 matching lines...) Expand all Loading... |
90 // True if the is tab pinned. | 103 // True if the is tab pinned. |
91 bool is_pinned; | 104 bool is_pinned; |
92 | 105 |
93 // Id of the app. | 106 // Id of the app. |
94 std::string app_id; | 107 std::string app_id; |
95 }; | 108 }; |
96 | 109 |
97 // There are two ctors. The first one implies a NULL browser_init object | 110 // There are two ctors. The first one implies a NULL browser_init object |
98 // and thus no access to distribution-specific first-run behaviors. The | 111 // and thus no access to distribution-specific first-run behaviors. The |
99 // second one is always called when the browser starts even if it is not | 112 // second one is always called when the browser starts even if it is not |
100 // the first run. | 113 // the first run. |is_first_run| indicates that this is a new profile. |
101 LaunchWithProfile(const FilePath& cur_dir, const CommandLine& command_line); | 114 LaunchWithProfile(const FilePath& cur_dir, |
102 LaunchWithProfile(const FilePath& cur_dir, const CommandLine& command_line, | 115 const CommandLine& command_line, |
103 BrowserInit* browser_init); | 116 IsFirstRun is_first_run); |
| 117 LaunchWithProfile(const FilePath& cur_dir, |
| 118 const CommandLine& command_line, |
| 119 BrowserInit* browser_init, |
| 120 IsFirstRun is_first_run); |
104 ~LaunchWithProfile(); | 121 ~LaunchWithProfile(); |
105 | 122 |
106 // Creates the necessary windows for startup. Returns true on success, | 123 // Creates the necessary windows for startup. Returns true on success, |
107 // false on failure. process_startup is true if Chrome is just | 124 // false on failure. process_startup is true if Chrome is just |
108 // starting up. If process_startup is false, it indicates Chrome was | 125 // starting up. If process_startup is false, it indicates Chrome was |
109 // already running and the user wants to launch another instance. | 126 // already running and the user wants to launch another instance. |
110 bool Launch(Profile* profile, | 127 bool Launch(Profile* profile, |
111 const std::vector<GURL>& urls_to_open, | 128 const std::vector<GURL>& urls_to_open, |
112 bool process_startup); | 129 bool process_startup); |
113 | 130 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 void AddStartupURLs(std::vector<GURL>* startup_urls) const; | 223 void AddStartupURLs(std::vector<GURL>* startup_urls) const; |
207 | 224 |
208 // Checks whether Chrome is still the default browser (unless the user | 225 // Checks whether Chrome is still the default browser (unless the user |
209 // previously instructed not to do so) and warns the user if it is not. | 226 // previously instructed not to do so) and warns the user if it is not. |
210 void CheckDefaultBrowser(Profile* profile); | 227 void CheckDefaultBrowser(Profile* profile); |
211 | 228 |
212 const FilePath cur_dir_; | 229 const FilePath cur_dir_; |
213 const CommandLine& command_line_; | 230 const CommandLine& command_line_; |
214 Profile* profile_; | 231 Profile* profile_; |
215 BrowserInit* browser_init_; | 232 BrowserInit* browser_init_; |
| 233 bool is_first_run_; |
216 DISALLOW_COPY_AND_ASSIGN(LaunchWithProfile); | 234 DISALLOW_COPY_AND_ASSIGN(LaunchWithProfile); |
217 }; | 235 }; |
218 | 236 |
219 private: | 237 private: |
220 // Returns the list of URLs to open from the command line. The returned | 238 // Returns the list of URLs to open from the command line. The returned |
221 // vector is empty if the user didn't specify any URLs on the command line. | 239 // vector is empty if the user didn't specify any URLs on the command line. |
222 static std::vector<GURL> GetURLsFromCommandLine( | 240 static std::vector<GURL> GetURLsFromCommandLine( |
223 const CommandLine& command_line, | 241 const CommandLine& command_line, |
224 const FilePath& cur_dir, | 242 const FilePath& cur_dir, |
225 Profile* profile); | 243 Profile* profile); |
226 | 244 |
227 static bool ProcessCmdLineImpl(const CommandLine& command_line, | 245 static bool ProcessCmdLineImpl(const CommandLine& command_line, |
228 const FilePath& cur_dir, bool process_startup, | 246 const FilePath& cur_dir, bool process_startup, |
229 Profile* profile, int* return_code, | 247 Profile* profile, int* return_code, |
230 BrowserInit* browser_init); | 248 BrowserInit* browser_init); |
231 | 249 |
232 // Additional tabs to open during first run. | 250 // Additional tabs to open during first run. |
233 std::vector<GURL> first_run_tabs_; | 251 std::vector<GURL> first_run_tabs_; |
234 | 252 |
235 DISALLOW_COPY_AND_ASSIGN(BrowserInit); | 253 DISALLOW_COPY_AND_ASSIGN(BrowserInit); |
236 }; | 254 }; |
237 | 255 |
238 #endif // CHROME_BROWSER_UI_BROWSER_INIT_H_ | 256 #endif // CHROME_BROWSER_UI_BROWSER_INIT_H_ |
OLD | NEW |