summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_init.h
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-18 16:46:40 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-18 16:46:40 +0000
commit911f815112d8d11778c771467fbef2c2b1f8e160 (patch)
treea6f9aa0ad2d669de7860e6f4da1b9e7f31f1354d /chrome/browser/browser_init.h
parent4a827847f1b9b860bcd5c45725249a3de3cfc205 (diff)
downloadchromium_src-911f815112d8d11778c771467fbef2c2b1f8e160.zip
chromium_src-911f815112d8d11778c771467fbef2c2b1f8e160.tar.gz
chromium_src-911f815112d8d11778c771467fbef2c2b1f8e160.tar.bz2
Makes pinned tab restore on startup if you haven't enabled session
restore. BUG=23613 TEST=turn off session restore, pin a tab, restart chrome and make sure you get back the pinned tab. Review URL: http://codereview.chromium.org/1026005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41958 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_init.h')
-rw-r--r--chrome/browser/browser_init.h48
1 files changed, 39 insertions, 9 deletions
diff --git a/chrome/browser/browser_init.h b/chrome/browser/browser_init.h
index 1f736b5..562173b 100644
--- a/chrome/browser/browser_init.h
+++ b/chrome/browser/browser_init.h
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "googleurl/src/gurl.h"
+#include "testing/gtest/include/gtest/gtest_prod.h"
class Browser;
class CommandLine;
@@ -84,6 +85,24 @@ class BrowserInit {
class LaunchWithProfile {
public:
+ // Used by OpenTabsInBrowser.
+ struct Tab {
+ Tab() : is_app(false), is_pinned(true) {}
+
+ // The url to load.
+ GURL url;
+
+ // If true, the tab corresponds to an app an |app_id| gives the id of the
+ // app.
+ bool is_app;
+
+ // True if the is tab pinned.
+ bool is_pinned;
+
+ // Id of the app.
+ std::string app_id;
+ };
+
// There are two ctors. The first one implies a NULL browser_init object
// and thus no access to distribution-specific first-run behaviors. The
// second one is always called when the browser starts even if it is not
@@ -101,15 +120,24 @@ class BrowserInit {
// already running and the user wants to launch another instance.
bool Launch(Profile* profile, bool process_startup);
- // Opens the list of urls. If browser is non-null and a tabbed browser, the
- // URLs are opened in it. Otherwise a new tabbed browser is created and the
- // URLs are added to it. The browser the tabs are added to is returned,
- // which is either |browser| or the newly created browser.
+ // Convenience for OpenTabsInBrowser that converts |urls| into a set of
+ // Tabs.
Browser* OpenURLsInBrowser(Browser* browser,
bool process_startup,
const std::vector<GURL>& urls);
+ // Creates a tab for each of the Tabs in |tabs|. If browser is non-null
+ // and a tabbed browser, the tabs are added to it. Otherwise a new tabbed
+ // browser is created and the tabs are added to it. The browser the tabs
+ // are added to is returned, which is either |browser| or the newly created
+ // browser.
+ Browser* OpenTabsInBrowser(Browser* browser,
+ bool process_startup,
+ const std::vector<Tab>& tabs);
+
private:
+ FRIEND_TEST(BrowserTest, RestorePinnedTabs);
+
// If the process was launched with the web application command line flags,
// e.g. --app=http://www.google.com/ or --app_id=... return true.
// In this case |app_url| or |app_id| are populated if they're non-null.
@@ -124,12 +152,14 @@ class BrowserInit {
// . If the user's startup pref is to restore the last session (or the
// command line flag is present to force using last session), it is
// restored, and true is returned.
- // . If the user's startup pref is to launch a specific set of URLs, and
- // urls_to_open is empty, the user specified set of URLs is openned.
+ // . Attempts to restore any pinned tabs from last run of chrome and:
+ // . If urls_to_open is non-empty, they are opened and true is returned.
+ // . If the user's startup pref is to launch a specific set of URLs they
+ // are opened.
//
- // Otherwise false is returned.
- bool OpenStartupURLs(bool is_process_startup,
- const std::vector<GURL>& urls_to_open);
+ // Otherwise false is returned, which indicates the caller must create a
+ // new browser.
+ bool OpenStartupURLs(const std::vector<GURL>& urls_to_open);
// If the last session didn't exit cleanly and tab is a web contents tab,
// an infobar is added allowing the user to restore the last session.