Index: chrome/browser/ui/browser_init.cc |
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc |
index 640bbe7c1e47ece28285d8730db758a7ecc81fad..191a1bb0c44c921b99c45f08bc6804041804fd72 100644 |
--- a/chrome/browser/ui/browser_init.cc |
+++ b/chrome/browser/ui/browser_init.cc |
@@ -63,12 +63,16 @@ |
#include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" |
#include "chrome/browser/tabs/pinned_tab_codec.h" |
#include "chrome/browser/tabs/tab_strip_model.h" |
+#include "chrome/browser/ui/browser_dialogs.h" |
#include "chrome/browser/ui/browser_list.h" |
#include "chrome/browser/ui/browser_navigator.h" |
#include "chrome/browser/ui/browser_window.h" |
+#include "chrome/browser/ui/dialog_style.h" |
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
+#include "chrome/browser/ui/webui/sync_promo/sync_promo_dialog.h" |
#include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" |
#include "chrome/common/chrome_constants.h" |
+#include "chrome/common/chrome_notification_types.h" |
#include "chrome/common/chrome_paths.h" |
#include "chrome/common/chrome_result_codes.h" |
#include "chrome/common/chrome_switches.h" |
@@ -1147,17 +1151,54 @@ Browser* BrowserInit::LaunchWithProfile::OpenURLsInBrowser( |
return OpenTabsInBrowser(browser, process_startup, tabs); |
} |
+size_t BrowserInit::LaunchWithProfile::ShowSyncPromoDialog( |
sky
2012/01/30 18:13:41
Make position match that of header.
sail
2012/01/30 21:00:39
Done.
|
+ Browser** browser, |
+ bool process_startup, |
+ std::vector<Tab>* tabs) { |
+ DCHECK(browser); |
+ DCHECK(tabs); |
+ |
+ if (!profile_ || *browser || !process_startup || |
Dan Beam
2012/01/30 18:10:05
You may want to leave comment clarifying what you'
sail
2012/01/30 21:00:39
Done.
|
+ SyncPromoUI::GetSyncPromoVersion() != SyncPromoUI::VERSION_DIALOG) { |
+ return std::string::npos; |
+ } |
+ |
+ for (size_t i = 0; i < tabs->size(); ++i) { |
+ GURL url((*tabs)[i].url); |
+ if (url.SchemeIs(chrome::kChromeUIScheme) && |
+ url.host() == chrome::kChromeUISyncPromoHost) { |
+ SyncPromoDialog dialog(profile_, url); |
+ dialog.ShowDialog(); |
+ *browser = dialog.spawned_browser(); |
+ if (dialog.sync_promo_was_closed()) { |
+ tabs->erase(tabs->begin() + i); |
+ return 0; |
sky
2012/01/30 18:13:41
I don't understand the return value here. CAn you
sail
2012/01/30 21:00:39
Done.
|
+ } else { |
+ return 1; |
+ } |
+ } |
+ } |
+ |
+ return std::string::npos; |
+} |
+ |
Browser* BrowserInit::LaunchWithProfile::OpenTabsInBrowser( |
Browser* browser, |
bool process_startup, |
- const std::vector<Tab>& tabs) { |
- DCHECK(!tabs.empty()); |
+ const std::vector<Tab>& in_tabs) { |
+ DCHECK(!in_tabs.empty()); |
+ |
// If we don't yet have a profile, try to use the one we're given from |
// |browser|. While we may not end up actually using |browser| (since it |
// could be a popup window), we can at least use the profile. |
if (!profile_ && browser) |
profile_ = browser->profile(); |
+ std::vector<Tab> tabs(in_tabs); |
+ size_t active_tab_index = |
+ ShowSyncPromoDialog(&browser, process_startup, &tabs); |
+ bool first_tab = active_tab_index == std::string::npos; |
+ |
if (!browser || !browser->is_type_tabbed()) { |
browser = Browser::Create(profile_); |
} else { |
@@ -1175,7 +1216,6 @@ Browser* BrowserInit::LaunchWithProfile::OpenTabsInBrowser( |
browser->ToggleFullscreenMode(false); |
#endif |
- bool first_tab = true; |
for (size_t i = 0; i < tabs.size(); ++i) { |
// We skip URLs that we'd have to launch an external protocol handler for. |
// This avoids us getting into an infinite loop asking ourselves to open |
@@ -1187,16 +1227,24 @@ Browser* BrowserInit::LaunchWithProfile::OpenTabsInBrowser( |
if (!process_startup && !handled_by_chrome) |
continue; |
- int add_types = first_tab ? TabStripModel::ADD_ACTIVE : |
- TabStripModel::ADD_NONE; |
+ size_t index; |
+ if (tabs[i].url.SchemeIs(chrome::kChromeUIScheme) && |
+ tabs[i].url.host() == chrome::kChromeUISyncPromoHost) { |
+ index = 0; |
sky
2012/01/30 18:13:41
Add a comment as to why you're forcing these to ap
sail
2012/01/30 21:00:39
Done.
|
+ } else { |
+ index = browser->GetIndexForInsertionDuringRestore(i); |
+ } |
+ |
+ int add_types = (first_tab || index == active_tab_index) ? |
+ TabStripModel::ADD_ACTIVE : TabStripModel::ADD_NONE; |
add_types |= TabStripModel::ADD_FORCE_INDEX; |
if (tabs[i].is_pinned) |
add_types |= TabStripModel::ADD_PINNED; |
- int index = browser->GetIndexForInsertionDuringRestore(i); |
browser::NavigateParams params(browser, tabs[i].url, |
content::PAGE_TRANSITION_START_PAGE); |
- params.disposition = first_tab ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; |
+ params.disposition = (first_tab || index == active_tab_index) ? |
+ NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; |
params.tabstrip_index = index; |
params.tabstrip_add_types = add_types; |
params.extension_app_id = tabs[i].app_id; |