Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 5 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "apps/app_restore_service.h" | 10 #include "apps/app_restore_service.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 const extensions::Extension* extension = | 241 const extensions::Extension* extension = |
| 242 extensions.GetAppByURL(autolaunch_tabs.at(i).url); | 242 extensions.GetAppByURL(autolaunch_tabs.at(i).url); |
| 243 if (extension) { | 243 if (extension) { |
| 244 CoreAppLauncherHandler::RecordAppLaunchType( | 244 CoreAppLauncherHandler::RecordAppLaunchType( |
| 245 extension_misc::APP_LAUNCH_AUTOLAUNCH, | 245 extension_misc::APP_LAUNCH_AUTOLAUNCH, |
| 246 extension->GetType()); | 246 extension->GetType()); |
| 247 } | 247 } |
| 248 } | 248 } |
| 249 } | 249 } |
| 250 | 250 |
| 251 bool IsNewTabURL(Profile* profile, const GURL& url) { | |
| 252 GURL ntp_url(chrome::kChromeUINewTabURL); | |
| 253 return url == ntp_url || | |
| 254 (url.is_empty() && profile->GetHomePage() == ntp_url); | |
| 255 } | |
| 256 | |
| 257 class WebContentsCloseObserver : public content::NotificationObserver { | 251 class WebContentsCloseObserver : public content::NotificationObserver { |
| 258 public: | 252 public: |
| 259 WebContentsCloseObserver() : contents_(NULL) {} | 253 WebContentsCloseObserver() : contents_(NULL) {} |
| 260 virtual ~WebContentsCloseObserver() {} | 254 virtual ~WebContentsCloseObserver() {} |
| 261 | 255 |
| 262 void SetContents(content::WebContents* contents) { | 256 void SetContents(content::WebContents* contents) { |
| 263 DCHECK(!contents_); | 257 DCHECK(!contents_); |
| 264 contents_ = contents; | 258 contents_ = contents; |
| 265 | 259 |
| 266 registrar_.Add(this, | 260 registrar_.Add(this, |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 883 // TODO(atwilson): Simplify the logic that decides which tabs to open on | 877 // TODO(atwilson): Simplify the logic that decides which tabs to open on |
| 884 // start-up and make it more consistent. http://crbug.com/248883 | 878 // start-up and make it more consistent. http://crbug.com/248883 |
| 885 | 879 |
| 886 // If we have urls specified by the first run master preferences use them | 880 // If we have urls specified by the first run master preferences use them |
| 887 // and nothing else. | 881 // and nothing else. |
| 888 if (browser_creator_ && startup_urls->empty()) { | 882 if (browser_creator_ && startup_urls->empty()) { |
| 889 if (!browser_creator_->first_run_tabs_.empty()) { | 883 if (!browser_creator_->first_run_tabs_.empty()) { |
| 890 std::vector<GURL>::iterator it = | 884 std::vector<GURL>::iterator it = |
| 891 browser_creator_->first_run_tabs_.begin(); | 885 browser_creator_->first_run_tabs_.begin(); |
| 892 while (it != browser_creator_->first_run_tabs_.end()) { | 886 while (it != browser_creator_->first_run_tabs_.end()) { |
| 893 // Replace magic names for the actual urls. | 887 startup_urls->push_back(*it); |
| 894 if (it->host() == "new_tab_page") { | |
|
sky
2014/05/20 17:30:54
Are you sure we aren't actually using these names
cpu_(ooo_6.6-7.5)
2014/05/20 18:35:38
They where at some point at least. They will be in
robertshield
2014/05/20 19:36:26
What Carlos said: these magic values are used by d
| |
| 895 startup_urls->push_back(GURL(chrome::kChromeUINewTabURL)); | |
| 896 } else if (it->host() == "welcome_page") { | |
| 897 startup_urls->push_back(internals::GetWelcomePageURL()); | |
| 898 } else { | |
| 899 startup_urls->push_back(*it); | |
| 900 } | |
| 901 ++it; | 888 ++it; |
| 902 } | 889 } |
| 903 browser_creator_->first_run_tabs_.clear(); | 890 browser_creator_->first_run_tabs_.clear(); |
| 904 } | 891 } |
| 905 } | 892 } |
| 906 | 893 |
| 907 // Otherwise open at least the new tab page (and the welcome page, if this | 894 // Otherwise open at least the new tab page (and the welcome page, if this |
| 908 // is the first time the browser is being started), or the set of URLs | 895 // is the first time the browser is being started), or the set of URLs |
| 909 // specified on the command line. | 896 // specified on the command line. |
| 910 if (startup_urls->empty()) { | 897 if (startup_urls->empty()) { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 926 if (*it == sync_promo_url) { | 913 if (*it == sync_promo_url) { |
| 927 add_promo = false; | 914 add_promo = false; |
| 928 break; | 915 break; |
| 929 } | 916 } |
| 930 } | 917 } |
| 931 | 918 |
| 932 if (add_promo) { | 919 if (add_promo) { |
| 933 // If the first URL is the NTP, replace it with the sync promo. This | 920 // If the first URL is the NTP, replace it with the sync promo. This |
| 934 // behavior is desired because completing or skipping the sync promo | 921 // behavior is desired because completing or skipping the sync promo |
| 935 // causes a redirect to the NTP. | 922 // causes a redirect to the NTP. |
| 936 if (!startup_urls->empty() && IsNewTabURL(profile_, startup_urls->at(0))) | 923 if (!startup_urls->empty() && |
| 924 startup_urls->at(0) == GURL(chrome::kChromeUINewTabURL)) | |
| 937 startup_urls->at(0) = sync_promo_url; | 925 startup_urls->at(0) = sync_promo_url; |
| 938 else | 926 else |
| 939 startup_urls->insert(startup_urls->begin(), sync_promo_url); | 927 startup_urls->insert(startup_urls->begin(), sync_promo_url); |
| 940 } | 928 } |
| 941 } | 929 } |
| 942 } | 930 } |
| OLD | NEW |