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

Side by Side Diff: chrome/browser/ui/startup/startup_browser_creator_impl.h

Issue 10332117: Revert 136573 - Extract StartupTabs and startup types from StartupBrowserCreator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_
6 #define CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_
7 #pragma once
8
9 #include <string>
10 #include <vector>
11
12 #include "base/file_path.h"
13 #include "base/gtest_prod_util.h"
14 #include "chrome/browser/ui/startup/startup_tab.h"
15 #include "chrome/browser/ui/startup/startup_types.h"
16 #include "googleurl/src/gurl.h"
17
18 class Browser;
19 class CommandLine;
20 class FilePath;
21 class Profile;
22 class StartupBrowserCreator;
23
24 // Assists launching the application and appending the initial tabs for a
25 // browser window.
26 class StartupBrowserCreatorImpl {
27 public:
28 // There are two ctors. The first one implies a NULL browser_creator object
29 // and thus no access to distribution-specific first-run behaviors. The
30 // second one is always called when the browser starts even if it is not
31 // the first run. |is_first_run| indicates that this is a new profile.
32 StartupBrowserCreatorImpl(const FilePath& cur_dir,
33 const CommandLine& command_line,
34 browser::startup::IsFirstRun is_first_run);
35 StartupBrowserCreatorImpl(const FilePath& cur_dir,
36 const CommandLine& command_line,
37 StartupBrowserCreator* browser_creator,
38 browser::startup::IsFirstRun is_first_run);
39 ~StartupBrowserCreatorImpl();
40
41 // Creates the necessary windows for startup. Returns true on success,
42 // false on failure. process_startup is true if Chrome is just
43 // starting up. If process_startup is false, it indicates Chrome was
44 // already running and the user wants to launch another instance.
45 bool Launch(Profile* profile,
46 const std::vector<GURL>& urls_to_open,
47 bool process_startup);
48
49 // Convenience for OpenTabsInBrowser that converts |urls| into a set of
50 // Tabs.
51 Browser* OpenURLsInBrowser(Browser* browser,
52 bool process_startup,
53 const std::vector<GURL>& urls);
54
55 // Creates a tab for each of the Tabs in |tabs|. If browser is non-null
56 // and a tabbed browser, the tabs are added to it. Otherwise a new tabbed
57 // browser is created and the tabs are added to it. The browser the tabs
58 // are added to is returned, which is either |browser| or the newly created
59 // browser.
60 Browser* OpenTabsInBrowser(Browser* browser,
61 bool process_startup,
62 const StartupTabs& tabs);
63
64 private:
65 FRIEND_TEST_ALL_PREFIXES(BrowserTest, RestorePinnedTabs);
66 FRIEND_TEST_ALL_PREFIXES(BrowserTest, AppIdSwitch);
67
68 // If the process was launched with the web application command line flags,
69 // e.g. --app=http://www.google.com/ or --app_id=... return true.
70 // In this case |app_url| or |app_id| are populated if they're non-null.
71 bool IsAppLaunch(std::string* app_url, std::string* app_id);
72
73 // If IsAppLaunch is true, tries to open an application window.
74 // If the app is specified to start in a tab, or IsAppLaunch is false,
75 // returns false to specify default processing.
76 bool OpenApplicationWindow(Profile* profile);
77
78 // If IsAppLaunch is true and the user set a pref indicating that the app
79 // should open in a tab, do so.
80 bool OpenApplicationTab(Profile* profile);
81
82 // Invoked from Launch to handle processing of urls. This may do any of the
83 // following:
84 // . Invoke ProcessStartupURLs if |process_startup| is true.
85 // . If |process_startup| is false, restore the last session if necessary,
86 // or invoke ProcessSpecifiedURLs.
87 // . Open the urls directly.
88 void ProcessLaunchURLs(bool process_startup,
89 const std::vector<GURL>& urls_to_open);
90
91 // Does the following:
92 // . If the user's startup pref is to restore the last session (or the
93 // command line flag is present to force using last session), it is
94 // restored.
95 // . Otherwise invoke ProcessSpecifiedURLs
96 // If a browser was created, true is returned. Otherwise returns false and
97 // the caller must create a new browser.
98 bool ProcessStartupURLs(const std::vector<GURL>& urls_to_open);
99
100 // Invoked from either ProcessLaunchURLs or ProcessStartupURLs to handle
101 // processing of URLs where the behavior is common between process startup
102 // and launch via an existing process (i.e. those explicitly specified by
103 // the user somehow). Does the following:
104 // . Attempts to restore any pinned tabs from last run of chrome.
105 // . If urls_to_open is non-empty, they are opened.
106 // . If the user's startup pref is to launch a specific set of URLs they
107 // are opened.
108 //
109 // If any tabs were opened, the Browser which was created is returned.
110 // Otherwise null is returned and the caller must create a new browser.
111 Browser* ProcessSpecifiedURLs(const std::vector<GURL>& urls_to_open);
112
113 // Adds a Tab to |tabs| for each url in |urls| that doesn't already exist
114 // in |tabs|.
115 void AddUniqueURLs(const std::vector<GURL>& urls, StartupTabs* tabs);
116
117 // Adds any startup infobars to the selected tab of the given browser.
118 void AddInfoBarsIfNecessary(
119 Browser* browser,
120 browser::startup::IsProcessStartup is_process_startup);
121
122 // Adds additional startup URLs to the specified vector.
123 void AddStartupURLs(std::vector<GURL>* startup_urls) const;
124
125 // Checks whether the Preferences backup is invalid and notifies user in
126 // that case.
127 void CheckPreferencesBackup(Profile* profile);
128
129 const FilePath cur_dir_;
130 const CommandLine& command_line_;
131 Profile* profile_;
132 StartupBrowserCreator* browser_creator_;
133 bool is_first_run_;
134 DISALLOW_COPY_AND_ASSIGN(StartupBrowserCreatorImpl);
135 };
136
137 // Returns true if |profile| has exited uncleanly and has not been launched
138 // after the unclean exit.
139 bool HasPendingUncleanExit(Profile* profile);
140
141 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698