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

Unified Diff: chrome/browser/ui/startup/startup_browser_creator_impl.cc

Issue 16141008: Do not show sync promo when RestoreOnStartupURLs policy is set (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit addressed. TODO added. Created 7 years, 6 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
« no previous file with comments | « chrome/browser/ui/startup/startup_browser_creator_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/startup/startup_browser_creator_impl.cc
diff --git a/chrome/browser/ui/startup/startup_browser_creator_impl.cc b/chrome/browser/ui/startup/startup_browser_creator_impl.cc
index 14314c414207f406034b18ced30220356ee625d5..2f29df62a114625f2fa39e67109e712ed832664f 100644
--- a/chrome/browser/ui/startup/startup_browser_creator_impl.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator_impl.cc
@@ -272,30 +272,6 @@ bool IsNewTabURL(Profile* profile, const GURL& url) {
(url.is_empty() && profile->GetHomePage() == ntp_url);
}
-void AddSyncPromoTab(Profile* profile, StartupTabs* tabs) {
- SyncPromoUI::DidShowSyncPromoAtStartup(profile);
-
- StartupTab sync_promo_tab;
- sync_promo_tab.url = SyncPromoUI::GetSyncPromoURL(
- SyncPromoUI::SOURCE_START_PAGE, false);
- sync_promo_tab.is_pinned = false;
-
- // No need to add if the sync promo is already in the startup list.
- for (StartupTabs::const_iterator it = tabs->begin(); it != tabs->end();
- ++it) {
- if (it->url == sync_promo_tab.url)
- return;
- }
-
- tabs->insert(tabs->begin(), sync_promo_tab);
-
- // If the next URL is the NTP then remove it, effectively replacing the NTP
- // with the sync promo. This behavior is desired because completing or
- // skipping the sync promo causes a redirect to the NTP.
- if (tabs->size() > 1 && IsNewTabURL(profile, tabs->at(1).url))
- tabs->erase(tabs->begin() + 1);
-}
-
class WebContentsCloseObserver : public content::NotificationObserver {
public:
WebContentsCloseObserver() : contents_(NULL) {}
@@ -763,11 +739,6 @@ Browser* StartupBrowserCreatorImpl::ProcessSpecifiedURLs(
NOTREACHED() << "SessionStartupPref has deprecated type HOMEPAGE";
}
- if (pref.type != SessionStartupPref::LAST &&
- SyncPromoUI::ShouldShowSyncPromoAtStartup(profile_, is_first_run_)) {
- AddSyncPromoTab(profile_, &tabs);
- }
-
if (tabs.empty())
return NULL;
@@ -930,9 +901,11 @@ void StartupBrowserCreatorImpl::AddInfoBarsIfNecessary(
}
}
-
void StartupBrowserCreatorImpl::AddStartupURLs(
std::vector<GURL>* startup_urls) const {
+ // TODO(atwilson): Simplify the logic that decides which tabs to open on
+ // start-up and make it more consistent. http://crbug.com/248883
+
// If we have urls specified by the first run master preferences use them
// and nothing else.
if (browser_creator_ && startup_urls->empty()) {
@@ -962,6 +935,33 @@ void StartupBrowserCreatorImpl::AddStartupURLs(
if (first_run::ShouldShowWelcomePage())
startup_urls->push_back(internals::GetWelcomePageURL());
}
+
+ if (SyncPromoUI::ShouldShowSyncPromoAtStartup(profile_, is_first_run_)) {
+ SyncPromoUI::DidShowSyncPromoAtStartup(profile_);
+
+ const GURL sync_promo_url = SyncPromoUI::GetSyncPromoURL(
+ SyncPromoUI::SOURCE_START_PAGE, false);
+
+ // No need to add if the sync promo is already in the startup list.
+ bool add_promo = true;
+ for (std::vector<GURL>::const_iterator it = startup_urls->begin();
+ it != startup_urls->end(); ++it) {
+ if (*it == sync_promo_url) {
+ add_promo = false;
+ break;
+ }
+ }
+
+ if (add_promo) {
+ // If the first URL is the NTP, replace it with the sync promo. This
+ // behavior is desired because completing or skipping the sync promo
+ // causes a redirect to the NTP.
+ if (!startup_urls->empty() && IsNewTabURL(profile_, startup_urls->at(0)))
+ startup_urls->at(0) = sync_promo_url;
+ else
+ startup_urls->insert(startup_urls->begin(), sync_promo_url);
+ }
+ }
}
#if !defined(OS_WIN)
« no previous file with comments | « chrome/browser/ui/startup/startup_browser_creator_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698