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

Unified Diff: chrome/browser/ui/browser_init.cc

Issue 9225053: Add a blocking version of the sync promo dialog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
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..cf9a0af6b0dbe4132e841704a28079241abdf5c2 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"
@@ -1150,14 +1154,41 @@ Browser* BrowserInit::LaunchWithProfile::OpenURLsInBrowser(
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());
+ std::vector<Tab> tabs(in_tabs);
+
// 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();
+ // This is the tab that should be active.
+ size_t active_tab_index = std::string::npos;
+ bool first_tab = true;
+
+ // Show the sync promo in a dialog if necessary.
+ if (profile_ && !browser && process_startup &&
sky 2012/01/30 15:27:47 Move this into its own function.
sail 2012/01/30 17:13:03 Done.
+ SyncPromoUI::GetSyncPromoVersion() == SyncPromoUI::VERSION_DIALOG) {
+ for (size_t i = 0; i < tabs.size(); ++i) {
+ if (tabs[i].url.SchemeIs(chrome::kChromeUIScheme) &&
+ tabs[i].url.host() == chrome::kChromeUISyncPromoHost) {
+ SyncPromoDialog dialog(profile_, tabs[i].url);
+ dialog.ShowDialog();
+ browser = dialog.spawned_browser();
+ if (dialog.sync_promo_was_closed()) {
+ tabs.erase(tabs.begin() + i);
+ active_tab_index = 0;
+ } else {
+ active_tab_index = 1;
+ }
+ first_tab = false;
+ break;
+ }
+ }
+ }
+
if (!browser || !browser->is_type_tabbed()) {
browser = Browser::Create(profile_);
} else {
@@ -1175,7 +1206,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 +1217,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;
+ } 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;

Powered by Google App Engine
This is Rietveld 408576698