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/browser_init.h" | 5 #include "chrome/browser/ui/browser_init.h" |
| 6 | 6 |
| 7 #include <algorithm> // For max(). | 7 #include <algorithm> // For max(). |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 | 250 |
| 251 // Track infobar reponse. | 251 // Track infobar reponse. |
| 252 auto_launch_trial::UpdateInfobarResponseMetric( | 252 auto_launch_trial::UpdateInfobarResponseMetric( |
| 253 auto_launch_trial::INFOBAR_CUT_IT_OUT); | 253 auto_launch_trial::INFOBAR_CUT_IT_OUT); |
| 254 // Also make sure we keep track of how many disable and how many enable. | 254 // Also make sure we keep track of how many disable and how many enable. |
| 255 const bool auto_launch = false; | 255 const bool auto_launch = false; |
| 256 auto_launch_trial::UpdateToggleAutoLaunchMetric(auto_launch); | 256 auto_launch_trial::UpdateToggleAutoLaunchMetric(auto_launch); |
| 257 | 257 |
| 258 content::BrowserThread::PostTask( | 258 content::BrowserThread::PostTask( |
| 259 content::BrowserThread::FILE, FROM_HERE, | 259 content::BrowserThread::FILE, FROM_HERE, |
| 260 base::Bind(&auto_launch_util::SetWillLaunchAtLogin, | 260 base::Bind(&auto_launch_util::DisableAutoStartAtLogin, |
| 261 auto_launch, | 261 profile_->GetPath().BaseName().value())); // Background mode. |
|
Finnur
2012/04/16 18:09:07
Comment removed locally.
| |
| 262 FilePath(), | |
| 263 profile_->GetPath().BaseName().value())); | |
| 264 return true; | 262 return true; |
| 265 } | 263 } |
| 266 | 264 |
| 267 // Metro driver export, this is how metro passes the initial navigated url | 265 // Metro driver export, this is how metro passes the initial navigated url |
| 268 // back to us. | 266 // back to us. |
| 269 extern "C" { | 267 extern "C" { |
| 270 typedef const wchar_t* (*GetInitialUrl)(); | 268 typedef const wchar_t* (*GetInitialUrl)(); |
| 271 } | 269 } |
| 272 | 270 |
| 273 | 271 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 | 367 |
| 370 bool DefaultBrowserInfoBarDelegate::Cancel() { | 368 bool DefaultBrowserInfoBarDelegate::Cancel() { |
| 371 action_taken_ = true; | 369 action_taken_ = true; |
| 372 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.DontSetAsDefault", 1); | 370 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.DontSetAsDefault", 1); |
| 373 // User clicked "Don't ask me again", remember that. | 371 // User clicked "Don't ask me again", remember that. |
| 374 prefs_->SetBoolean(prefs::kCheckDefaultBrowser, false); | 372 prefs_->SetBoolean(prefs::kCheckDefaultBrowser, false); |
| 375 return true; | 373 return true; |
| 376 } | 374 } |
| 377 | 375 |
| 378 #if defined(OS_WIN) | 376 #if defined(OS_WIN) |
| 379 void CheckAutoLaunchCallback() { | 377 void CheckAutoLaunchCallback(Profile* profile) { |
| 380 if (!auto_launch_trial::IsInAutoLaunchGroup()) | 378 if (!auto_launch_trial::IsInAutoLaunchGroup()) |
| 381 return; | 379 return; |
| 382 | 380 |
| 383 Browser* browser = BrowserList::GetLastActive(); | 381 // We must not use GetLastActive here because this is at Chrome startup and |
| 382 // no window might have been made active yet. We'll settle for any window. | |
| 383 Browser* browser = BrowserList::FindAnyBrowser(profile, true); | |
|
grt (UTC plus 2)
2012/04/16 19:43:58
Looks like this could potentially return NULL. Wi
Andrew T Wilson (Slow)
2012/04/16 22:57:33
Agreed. Do we know this is never called with no wi
Finnur
2012/04/17 12:27:45
Yes, this codepath doesn't execute when in backgro
| |
| 384 TabContentsWrapper* tab = browser->GetSelectedTabContentsWrapper(); | 384 TabContentsWrapper* tab = browser->GetSelectedTabContentsWrapper(); |
| 385 | 385 |
| 386 // Don't show the info-bar if there are already info-bars showing. | 386 // Don't show the info-bar if there are already info-bars showing. |
| 387 InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); | 387 InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); |
| 388 if (infobar_helper->infobar_count() > 0) | 388 if (infobar_helper->infobar_count() > 0) |
| 389 return; | 389 return; |
| 390 | 390 |
| 391 infobar_helper->AddInfoBar( | 391 infobar_helper->AddInfoBar( |
| 392 new AutolaunchInfoBarDelegate(infobar_helper, | 392 new AutolaunchInfoBarDelegate(infobar_helper, |
| 393 tab->profile()->GetPrefs(), tab->profile())); | 393 tab->profile()->GetPrefs(), tab->profile())); |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1066 return (app_tab != NULL); | 1066 return (app_tab != NULL); |
| 1067 } | 1067 } |
| 1068 } | 1068 } |
| 1069 return false; | 1069 return false; |
| 1070 } | 1070 } |
| 1071 | 1071 |
| 1072 void BrowserInit::LaunchWithProfile::ProcessLaunchURLs( | 1072 void BrowserInit::LaunchWithProfile::ProcessLaunchURLs( |
| 1073 bool process_startup, | 1073 bool process_startup, |
| 1074 const std::vector<GURL>& urls_to_open) { | 1074 const std::vector<GURL>& urls_to_open) { |
| 1075 // If we're starting up in "background mode" (no open browser window) then | 1075 // If we're starting up in "background mode" (no open browser window) then |
| 1076 // don't open any browser windows. | 1076 // don't open any browser windows, unless kAutoLaunchAtStartup is also |
| 1077 if (process_startup && command_line_.HasSwitch(switches::kNoStartupWindow)) | 1077 // specified. |
| 1078 if (process_startup && | |
| 1079 command_line_.HasSwitch(switches::kNoStartupWindow) && | |
| 1080 !command_line_.HasSwitch(switches::kAutoLaunchAtStartup)) { | |
| 1078 return; | 1081 return; |
| 1082 } | |
| 1079 | 1083 |
| 1080 if (process_startup && ProcessStartupURLs(urls_to_open)) { | 1084 if (process_startup && ProcessStartupURLs(urls_to_open)) { |
| 1081 // ProcessStartupURLs processed the urls, nothing else to do. | 1085 // ProcessStartupURLs processed the urls, nothing else to do. |
| 1082 return; | 1086 return; |
| 1083 } | 1087 } |
| 1084 | 1088 |
| 1085 IsProcessStartup is_process_startup = process_startup ? | 1089 IsProcessStartup is_process_startup = process_startup ? |
| 1086 IS_PROCESS_STARTUP : IS_NOT_PROCESS_STARTUP; | 1090 IS_PROCESS_STARTUP : IS_NOT_PROCESS_STARTUP; |
| 1087 if (!process_startup) { | 1091 if (!process_startup) { |
| 1088 // Even if we're not starting a new process, this may conceptually be | 1092 // Even if we're not starting a new process, this may conceptually be |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1563 if (infobar_shown >= kMaxInfobarShown) | 1567 if (infobar_shown >= kMaxInfobarShown) |
| 1564 return false; | 1568 return false; |
| 1565 | 1569 |
| 1566 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 1570 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 1567 if (command_line.HasSwitch(switches::kChromeFrame)) | 1571 if (command_line.HasSwitch(switches::kChromeFrame)) |
| 1568 return false; | 1572 return false; |
| 1569 | 1573 |
| 1570 if (command_line.HasSwitch(switches::kAutoLaunchAtStartup) || | 1574 if (command_line.HasSwitch(switches::kAutoLaunchAtStartup) || |
| 1571 first_run::IsChromeFirstRun()) { | 1575 first_run::IsChromeFirstRun()) { |
| 1572 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 1576 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 1573 base::Bind(&CheckAutoLaunchCallback)); | 1577 base::Bind(&CheckAutoLaunchCallback, profile)); |
| 1574 return true; | 1578 return true; |
| 1575 } | 1579 } |
| 1576 #endif | 1580 #endif |
| 1577 return false; | 1581 return false; |
| 1578 } | 1582 } |
| 1579 | 1583 |
| 1580 void BrowserInit::LaunchWithProfile::CheckPreferencesBackup(Profile* profile) { | 1584 void BrowserInit::LaunchWithProfile::CheckPreferencesBackup(Profile* profile) { |
| 1581 ProtectorService* protector_service = | 1585 ProtectorService* protector_service = |
| 1582 ProtectorServiceFactory::GetForProfile(profile); | 1586 ProtectorServiceFactory::GetForProfile(profile); |
| 1583 ProtectedPrefsWatcher* prefs_watcher = protector_service->GetPrefsWatcher(); | 1587 ProtectedPrefsWatcher* prefs_watcher = protector_service->GetPrefsWatcher(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1714 // Look for the testing channel ID ONLY during process startup | 1718 // Look for the testing channel ID ONLY during process startup |
| 1715 if (process_startup && | 1719 if (process_startup && |
| 1716 command_line.HasSwitch(switches::kTestingChannelID)) { | 1720 command_line.HasSwitch(switches::kTestingChannelID)) { |
| 1717 std::string testing_channel_id = command_line.GetSwitchValueASCII( | 1721 std::string testing_channel_id = command_line.GetSwitchValueASCII( |
| 1718 switches::kTestingChannelID); | 1722 switches::kTestingChannelID); |
| 1719 // TODO(sanjeevr) Check if we need to make this a singleton for | 1723 // TODO(sanjeevr) Check if we need to make this a singleton for |
| 1720 // compatibility with the old testing code | 1724 // compatibility with the old testing code |
| 1721 // If there are any extra parameters, we expect each one to generate a | 1725 // If there are any extra parameters, we expect each one to generate a |
| 1722 // new tab; if there are none then we get one homepage tab. | 1726 // new tab; if there are none then we get one homepage tab. |
| 1723 int expected_tab_count = 1; | 1727 int expected_tab_count = 1; |
| 1724 if (command_line.HasSwitch(switches::kNoStartupWindow)) { | 1728 if (command_line.HasSwitch(switches::kNoStartupWindow) && |
| 1729 !command_line.HasSwitch(switches::kAutoLaunchAtStartup)) { | |
| 1725 expected_tab_count = 0; | 1730 expected_tab_count = 0; |
| 1726 #if defined(OS_CHROMEOS) | 1731 #if defined(OS_CHROMEOS) |
| 1727 // kLoginManager will cause Chrome to start up with the ChromeOS login | 1732 // kLoginManager will cause Chrome to start up with the ChromeOS login |
| 1728 // screen instead of a browser window, so it won't load any tabs. | 1733 // screen instead of a browser window, so it won't load any tabs. |
| 1729 } else if (command_line.HasSwitch(switches::kLoginManager)) { | 1734 } else if (command_line.HasSwitch(switches::kLoginManager)) { |
| 1730 expected_tab_count = 0; | 1735 expected_tab_count = 0; |
| 1731 #endif | 1736 #endif |
| 1732 } else if (command_line.HasSwitch(switches::kRestoreLastSession)) { | 1737 } else if (command_line.HasSwitch(switches::kRestoreLastSession)) { |
| 1733 std::string restore_session_value( | 1738 std::string restore_session_value( |
| 1734 command_line.GetSwitchValueASCII(switches::kRestoreLastSession)); | 1739 command_line.GetSwitchValueASCII(switches::kRestoreLastSession)); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1932 | 1937 |
| 1933 Profile* profile = ProfileManager::GetLastUsedProfile(); | 1938 Profile* profile = ProfileManager::GetLastUsedProfile(); |
| 1934 if (!profile) { | 1939 if (!profile) { |
| 1935 // We should only be able to get here if the profile already exists and | 1940 // We should only be able to get here if the profile already exists and |
| 1936 // has been created. | 1941 // has been created. |
| 1937 NOTREACHED(); | 1942 NOTREACHED(); |
| 1938 return; | 1943 return; |
| 1939 } | 1944 } |
| 1940 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, Profiles(), NULL, NULL); | 1945 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, Profiles(), NULL, NULL); |
| 1941 } | 1946 } |
| OLD | NEW |