Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(594)

Side by Side Diff: chrome/browser/ui/browser_init.h

Issue 9232007: Fix: after updating, restore tabs from all profiles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review. Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/prefs/session_startup_pref.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
17 18
18 class Browser; 19 class Browser;
19 class CommandLine; 20 class CommandLine;
20 class GURL; 21 class GURL;
21 class PrefService; 22 class PrefService;
22 class TabContentsWrapper; 23 class TabContentsWrapper;
23 24
24 // class containing helpers for BrowserMain to spin up a new instance and 25 // class containing helpers for BrowserMain to spin up a new instance and
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 const FilePath& cur_dir, 81 const FilePath& cur_dir,
81 IsProcessStartup is_process_startup, 82 IsProcessStartup is_process_startup,
82 IsFirstRun is_first_run, 83 IsFirstRun is_first_run,
83 int* return_code); 84 int* return_code);
84 85
85 // When called the first time, reads the value of the preference kWasRestarted 86 // When called the first time, reads the value of the preference kWasRestarted
86 // and resets it to false. Subsequent calls return the value which was read 87 // and resets it to false. Subsequent calls return the value which was read
87 // the first time. 88 // the first time.
88 static bool WasRestarted(); 89 static bool WasRestarted();
89 90
91 static SessionStartupPref GetSessionStartupPref(
92 const CommandLine& command_line,
93 Profile* profile);
94
90 // LaunchWithProfile --------------------------------------------------------- 95 // LaunchWithProfile ---------------------------------------------------------
91 // 96 //
92 // Assists launching the application and appending the initial tabs for a 97 // Assists launching the application and appending the initial tabs for a
93 // browser window. 98 // browser window.
94 99
95 class LaunchWithProfile { 100 class LaunchWithProfile {
96 public: 101 public:
97 // Used by OpenTabsInBrowser. 102 // Used by OpenTabsInBrowser.
98 struct Tab { 103 struct Tab {
99 Tab(); 104 Tab();
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 const CommandLine& command_line_; 245 const CommandLine& command_line_;
241 Profile* profile_; 246 Profile* profile_;
242 BrowserInit* browser_init_; 247 BrowserInit* browser_init_;
243 bool is_first_run_; 248 bool is_first_run_;
244 DISALLOW_COPY_AND_ASSIGN(LaunchWithProfile); 249 DISALLOW_COPY_AND_ASSIGN(LaunchWithProfile);
245 }; 250 };
246 251
247 private: 252 private:
248 friend class CloudPrintProxyPolicyTest; 253 friend class CloudPrintProxyPolicyTest;
249 friend class CloudPrintProxyPolicyStartupTest; 254 friend class CloudPrintProxyPolicyStartupTest;
255 FRIEND_TEST_ALL_PREFIXES(BrowserInitTest,
256 ReadingWasRestartedAfterNormalStart);
257 FRIEND_TEST_ALL_PREFIXES(BrowserInitTest, ReadingWasRestartedAfterRestart);
258 FRIEND_TEST_ALL_PREFIXES(BrowserInitTest, UpdateWithTwoProfiles);
250 259
251 // Returns the list of URLs to open from the command line. The returned 260 // Returns the list of URLs to open from the command line. The returned
252 // vector is empty if the user didn't specify any URLs on the command line. 261 // vector is empty if the user didn't specify any URLs on the command line.
253 static std::vector<GURL> GetURLsFromCommandLine( 262 static std::vector<GURL> GetURLsFromCommandLine(
254 const CommandLine& command_line, 263 const CommandLine& command_line,
255 const FilePath& cur_dir, 264 const FilePath& cur_dir,
256 Profile* profile); 265 Profile* profile);
257 266
258 static bool ProcessCmdLineImpl(const CommandLine& command_line, 267 static bool ProcessCmdLineImpl(const CommandLine& command_line,
259 const FilePath& cur_dir, 268 const FilePath& cur_dir,
260 bool process_startup, 269 bool process_startup,
261 Profile* last_used_profile, 270 Profile* last_used_profile,
262 const Profiles& last_opened_profiles, 271 const Profiles& last_opened_profiles,
263 int* return_code, 272 int* return_code,
264 BrowserInit* browser_init); 273 BrowserInit* browser_init);
265 274
266 // Callback after a profile has been created. 275 // Callback after a profile has been created.
267 static void ProcessCommandLineOnProfileCreated( 276 static void ProcessCommandLineOnProfileCreated(
268 const CommandLine& cmd_line, 277 const CommandLine& cmd_line,
269 const FilePath& cur_dir, 278 const FilePath& cur_dir,
270 Profile* profile, 279 Profile* profile,
271 Profile::CreateStatus status); 280 Profile::CreateStatus status);
272 281
273 // Additional tabs to open during first run. 282 // Additional tabs to open during first run.
274 std::vector<GURL> first_run_tabs_; 283 std::vector<GURL> first_run_tabs_;
275 284
285 // True if we have already read and reset the preference kWasRestarted. (A
286 // member variable instead of a static variable inside WasRestarted because
287 // of testing.)
288 static bool was_restarted_read_;
289
276 DISALLOW_COPY_AND_ASSIGN(BrowserInit); 290 DISALLOW_COPY_AND_ASSIGN(BrowserInit);
277 }; 291 };
278 292
279 #endif // CHROME_BROWSER_UI_BROWSER_INIT_H_ 293 #endif // CHROME_BROWSER_UI_BROWSER_INIT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698