Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

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

Issue 1026005: Makes pinned tab restore on startup if you haven't enabled session (Closed)
Patch Set: check Created 10 years, 9 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
« no previous file with comments | « chrome/browser/browser_browsertest.cc ('k') | chrome/browser/browser_init.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_BROWSER_INIT_H_ 5 #ifndef CHROME_BROWSER_BROWSER_INIT_H_
6 #define CHROME_BROWSER_BROWSER_INIT_H_ 6 #define CHROME_BROWSER_BROWSER_INIT_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "googleurl/src/gurl.h" 12 #include "googleurl/src/gurl.h"
13 #include "testing/gtest/include/gtest/gtest_prod.h"
13 14
14 class Browser; 15 class Browser;
15 class CommandLine; 16 class CommandLine;
16 class GURL; 17 class GURL;
17 class PrefService; 18 class PrefService;
18 class Profile; 19 class Profile;
19 class TabContents; 20 class TabContents;
20 21
21 // class containing helpers for BrowserMain to spin up a new instance and 22 // class containing helpers for BrowserMain to spin up a new instance and
22 // initialize the profile. 23 // initialize the profile.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 const std::wstring& cur_dir, bool process_startup, 78 const std::wstring& cur_dir, bool process_startup,
78 int* return_code); 79 int* return_code);
79 80
80 // LaunchWithProfile --------------------------------------------------------- 81 // LaunchWithProfile ---------------------------------------------------------
81 // 82 //
82 // Assists launching the application and appending the initial tabs for a 83 // Assists launching the application and appending the initial tabs for a
83 // browser window. 84 // browser window.
84 85
85 class LaunchWithProfile { 86 class LaunchWithProfile {
86 public: 87 public:
88 // Used by OpenTabsInBrowser.
89 struct Tab {
90 Tab() : is_app(false), is_pinned(true) {}
91
92 // The url to load.
93 GURL url;
94
95 // If true, the tab corresponds to an app an |app_id| gives the id of the
96 // app.
97 bool is_app;
98
99 // True if the is tab pinned.
100 bool is_pinned;
101
102 // Id of the app.
103 std::string app_id;
104 };
105
87 // There are two ctors. The first one implies a NULL browser_init object 106 // There are two ctors. The first one implies a NULL browser_init object
88 // and thus no access to distribution-specific first-run behaviors. The 107 // and thus no access to distribution-specific first-run behaviors. The
89 // second one is always called when the browser starts even if it is not 108 // second one is always called when the browser starts even if it is not
90 // the first run. 109 // the first run.
91 LaunchWithProfile(const std::wstring& cur_dir, 110 LaunchWithProfile(const std::wstring& cur_dir,
92 const CommandLine& command_line); 111 const CommandLine& command_line);
93 LaunchWithProfile(const std::wstring& cur_dir, 112 LaunchWithProfile(const std::wstring& cur_dir,
94 const CommandLine& command_line, 113 const CommandLine& command_line,
95 BrowserInit* browser_init); 114 BrowserInit* browser_init);
96 ~LaunchWithProfile() { } 115 ~LaunchWithProfile() { }
97 116
98 // Creates the necessary windows for startup. Returns true on success, 117 // Creates the necessary windows for startup. Returns true on success,
99 // false on failure. process_startup is true if Chrome is just 118 // false on failure. process_startup is true if Chrome is just
100 // starting up. If process_startup is false, it indicates Chrome was 119 // starting up. If process_startup is false, it indicates Chrome was
101 // already running and the user wants to launch another instance. 120 // already running and the user wants to launch another instance.
102 bool Launch(Profile* profile, bool process_startup); 121 bool Launch(Profile* profile, bool process_startup);
103 122
104 // Opens the list of urls. If browser is non-null and a tabbed browser, the 123 // Convenience for OpenTabsInBrowser that converts |urls| into a set of
105 // URLs are opened in it. Otherwise a new tabbed browser is created and the 124 // Tabs.
106 // URLs are added to it. The browser the tabs are added to is returned,
107 // which is either |browser| or the newly created browser.
108 Browser* OpenURLsInBrowser(Browser* browser, 125 Browser* OpenURLsInBrowser(Browser* browser,
109 bool process_startup, 126 bool process_startup,
110 const std::vector<GURL>& urls); 127 const std::vector<GURL>& urls);
111 128
129 // Creates a tab for each of the Tabs in |tabs|. If browser is non-null
130 // and a tabbed browser, the tabs are added to it. Otherwise a new tabbed
131 // browser is created and the tabs are added to it. The browser the tabs
132 // are added to is returned, which is either |browser| or the newly created
133 // browser.
134 Browser* OpenTabsInBrowser(Browser* browser,
135 bool process_startup,
136 const std::vector<Tab>& tabs);
137
112 private: 138 private:
139 FRIEND_TEST(BrowserTest, RestorePinnedTabs);
140
113 // If the process was launched with the web application command line flags, 141 // If the process was launched with the web application command line flags,
114 // e.g. --app=http://www.google.com/ or --app_id=... return true. 142 // e.g. --app=http://www.google.com/ or --app_id=... return true.
115 // In this case |app_url| or |app_id| are populated if they're non-null. 143 // In this case |app_url| or |app_id| are populated if they're non-null.
116 bool IsAppLaunch(std::string* app_url, std::string* app_id); 144 bool IsAppLaunch(std::string* app_url, std::string* app_id);
117 145
118 // If IsAppLaunch is true, tries to open an application window. 146 // If IsAppLaunch is true, tries to open an application window.
119 // If the app is specified to start in a tab, or IsAppLaunch is false, 147 // If the app is specified to start in a tab, or IsAppLaunch is false,
120 // returns false to specify default processing. 148 // returns false to specify default processing.
121 bool OpenApplicationWindow(Profile* profile); 149 bool OpenApplicationWindow(Profile* profile);
122 150
123 // Does the following: 151 // Does the following:
124 // . If the user's startup pref is to restore the last session (or the 152 // . If the user's startup pref is to restore the last session (or the
125 // command line flag is present to force using last session), it is 153 // command line flag is present to force using last session), it is
126 // restored, and true is returned. 154 // restored, and true is returned.
127 // . If the user's startup pref is to launch a specific set of URLs, and 155 // . Attempts to restore any pinned tabs from last run of chrome and:
128 // urls_to_open is empty, the user specified set of URLs is openned. 156 // . If urls_to_open is non-empty, they are opened and true is returned.
157 // . If the user's startup pref is to launch a specific set of URLs they
158 // are opened.
129 // 159 //
130 // Otherwise false is returned. 160 // Otherwise false is returned, which indicates the caller must create a
131 bool OpenStartupURLs(bool is_process_startup, 161 // new browser.
132 const std::vector<GURL>& urls_to_open); 162 bool OpenStartupURLs(const std::vector<GURL>& urls_to_open);
133 163
134 // If the last session didn't exit cleanly and tab is a web contents tab, 164 // If the last session didn't exit cleanly and tab is a web contents tab,
135 // an infobar is added allowing the user to restore the last session. 165 // an infobar is added allowing the user to restore the last session.
136 void AddCrashedInfoBarIfNecessary(TabContents* tab); 166 void AddCrashedInfoBarIfNecessary(TabContents* tab);
137 167
138 // Returns the list of URLs to open from the command line. The returned 168 // Returns the list of URLs to open from the command line. The returned
139 // vector is empty if the user didn't specify any URLs on the command line. 169 // vector is empty if the user didn't specify any URLs on the command line.
140 std::vector<GURL> GetURLsFromCommandLine(Profile* profile); 170 std::vector<GURL> GetURLsFromCommandLine(Profile* profile);
141 171
142 // Adds additional startup URLs to the specified vector. 172 // Adds additional startup URLs to the specified vector.
(...skipping 18 matching lines...) Expand all
161 191
162 // Additional tabs to open during first run. 192 // Additional tabs to open during first run.
163 std::vector<GURL> first_run_tabs_; 193 std::vector<GURL> first_run_tabs_;
164 // Additional bookmarks to set during first run. 194 // Additional bookmarks to set during first run.
165 std::vector<GURL> default_bookmarks_; 195 std::vector<GURL> default_bookmarks_;
166 196
167 DISALLOW_COPY_AND_ASSIGN(BrowserInit); 197 DISALLOW_COPY_AND_ASSIGN(BrowserInit);
168 }; 198 };
169 199
170 #endif // CHROME_BROWSER_BROWSER_INIT_H_ 200 #endif // CHROME_BROWSER_BROWSER_INIT_H_
OLDNEW
« no previous file with comments | « chrome/browser/browser_browsertest.cc ('k') | chrome/browser/browser_init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698