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

Side by Side Diff: chrome/browser/ui/browser_init.cc

Issue 9972012: Resolve the conflict that auto-launch has with the background mode feature (part 1). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 return true; 245 return true;
246 } 246 }
247 247
248 bool AutolaunchInfoBarDelegate::Cancel() { 248 bool AutolaunchInfoBarDelegate::Cancel() {
249 action_taken_ = true; 249 action_taken_ = true;
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 auto_launch_trial::UpdateToggleAutoLaunchMetric(false);
256 auto_launch_trial::UpdateToggleAutoLaunchMetric(auto_launch);
257 256
258 content::BrowserThread::PostTask( 257 content::BrowserThread::PostTask(
259 content::BrowserThread::FILE, FROM_HERE, 258 content::BrowserThread::FILE, FROM_HERE,
260 base::Bind(&auto_launch_util::SetWillLaunchAtLogin, 259 base::Bind(&auto_launch_util::DisableAutoStartAtLogin,
261 auto_launch,
262 FilePath(),
263 profile_->GetPath().BaseName().value())); 260 profile_->GetPath().BaseName().value()));
264 return true; 261 return true;
265 } 262 }
266 263
267 // Metro driver export, this is how metro passes the initial navigated url 264 // Metro driver export, this is how metro passes the initial navigated url
268 // back to us. 265 // back to us.
269 extern "C" { 266 extern "C" {
270 typedef const wchar_t* (*GetInitialUrl)(); 267 typedef const wchar_t* (*GetInitialUrl)();
271 } 268 }
272 269
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 366
370 bool DefaultBrowserInfoBarDelegate::Cancel() { 367 bool DefaultBrowserInfoBarDelegate::Cancel() {
371 action_taken_ = true; 368 action_taken_ = true;
372 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.DontSetAsDefault", 1); 369 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.DontSetAsDefault", 1);
373 // User clicked "Don't ask me again", remember that. 370 // User clicked "Don't ask me again", remember that.
374 prefs_->SetBoolean(prefs::kCheckDefaultBrowser, false); 371 prefs_->SetBoolean(prefs::kCheckDefaultBrowser, false);
375 return true; 372 return true;
376 } 373 }
377 374
378 #if defined(OS_WIN) 375 #if defined(OS_WIN)
379 void CheckAutoLaunchCallback() { 376 void CheckAutoLaunchCallback(Profile* profile) {
380 if (!auto_launch_trial::IsInAutoLaunchGroup()) 377 if (!auto_launch_trial::IsInAutoLaunchGroup())
381 return; 378 return;
382 379
383 Browser* browser = BrowserList::GetLastActive(); 380 // We must not use GetLastActive here because this is at Chrome startup and
381 // no window might have been made active yet. We'll settle for any window.
382 Browser* browser = BrowserList::FindAnyBrowser(profile, true);
384 TabContentsWrapper* tab = browser->GetSelectedTabContentsWrapper(); 383 TabContentsWrapper* tab = browser->GetSelectedTabContentsWrapper();
385 384
386 // Don't show the info-bar if there are already info-bars showing. 385 // Don't show the info-bar if there are already info-bars showing.
387 InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); 386 InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper();
388 if (infobar_helper->infobar_count() > 0) 387 if (infobar_helper->infobar_count() > 0)
389 return; 388 return;
390 389
391 infobar_helper->AddInfoBar( 390 infobar_helper->AddInfoBar(
392 new AutolaunchInfoBarDelegate(infobar_helper, 391 new AutolaunchInfoBarDelegate(infobar_helper,
393 tab->profile()->GetPrefs(), tab->profile())); 392 tab->profile()->GetPrefs(), tab->profile()));
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 return (app_tab != NULL); 1065 return (app_tab != NULL);
1067 } 1066 }
1068 } 1067 }
1069 return false; 1068 return false;
1070 } 1069 }
1071 1070
1072 void BrowserInit::LaunchWithProfile::ProcessLaunchURLs( 1071 void BrowserInit::LaunchWithProfile::ProcessLaunchURLs(
1073 bool process_startup, 1072 bool process_startup,
1074 const std::vector<GURL>& urls_to_open) { 1073 const std::vector<GURL>& urls_to_open) {
1075 // If we're starting up in "background mode" (no open browser window) then 1074 // If we're starting up in "background mode" (no open browser window) then
1076 // don't open any browser windows. 1075 // don't open any browser windows, unless kAutoLaunchAtStartup is also
1077 if (process_startup && command_line_.HasSwitch(switches::kNoStartupWindow)) 1076 // specified.
1077 if (process_startup &&
1078 command_line_.HasSwitch(switches::kNoStartupWindow) &&
1079 !command_line_.HasSwitch(switches::kAutoLaunchAtStartup)) {
1078 return; 1080 return;
1081 }
1079 1082
1080 if (process_startup && ProcessStartupURLs(urls_to_open)) { 1083 if (process_startup && ProcessStartupURLs(urls_to_open)) {
1081 // ProcessStartupURLs processed the urls, nothing else to do. 1084 // ProcessStartupURLs processed the urls, nothing else to do.
1082 return; 1085 return;
1083 } 1086 }
1084 1087
1085 IsProcessStartup is_process_startup = process_startup ? 1088 IsProcessStartup is_process_startup = process_startup ?
1086 IS_PROCESS_STARTUP : IS_NOT_PROCESS_STARTUP; 1089 IS_PROCESS_STARTUP : IS_NOT_PROCESS_STARTUP;
1087 if (!process_startup) { 1090 if (!process_startup) {
1088 // Even if we're not starting a new process, this may conceptually be 1091 // 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
1563 if (infobar_shown >= kMaxInfobarShown) 1566 if (infobar_shown >= kMaxInfobarShown)
1564 return false; 1567 return false;
1565 1568
1566 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 1569 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
1567 if (command_line.HasSwitch(switches::kChromeFrame)) 1570 if (command_line.HasSwitch(switches::kChromeFrame))
1568 return false; 1571 return false;
1569 1572
1570 if (command_line.HasSwitch(switches::kAutoLaunchAtStartup) || 1573 if (command_line.HasSwitch(switches::kAutoLaunchAtStartup) ||
1571 first_run::IsChromeFirstRun()) { 1574 first_run::IsChromeFirstRun()) {
1572 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 1575 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
1573 base::Bind(&CheckAutoLaunchCallback)); 1576 base::Bind(&CheckAutoLaunchCallback, profile));
1574 return true; 1577 return true;
1575 } 1578 }
1576 #endif 1579 #endif
1577 return false; 1580 return false;
1578 } 1581 }
1579 1582
1580 void BrowserInit::LaunchWithProfile::CheckPreferencesBackup(Profile* profile) { 1583 void BrowserInit::LaunchWithProfile::CheckPreferencesBackup(Profile* profile) {
1581 ProtectorService* protector_service = 1584 ProtectorService* protector_service =
1582 ProtectorServiceFactory::GetForProfile(profile); 1585 ProtectorServiceFactory::GetForProfile(profile);
1583 ProtectedPrefsWatcher* prefs_watcher = protector_service->GetPrefsWatcher(); 1586 ProtectedPrefsWatcher* prefs_watcher = protector_service->GetPrefsWatcher();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 // Look for the testing channel ID ONLY during process startup 1717 // Look for the testing channel ID ONLY during process startup
1715 if (process_startup && 1718 if (process_startup &&
1716 command_line.HasSwitch(switches::kTestingChannelID)) { 1719 command_line.HasSwitch(switches::kTestingChannelID)) {
1717 std::string testing_channel_id = command_line.GetSwitchValueASCII( 1720 std::string testing_channel_id = command_line.GetSwitchValueASCII(
1718 switches::kTestingChannelID); 1721 switches::kTestingChannelID);
1719 // TODO(sanjeevr) Check if we need to make this a singleton for 1722 // TODO(sanjeevr) Check if we need to make this a singleton for
1720 // compatibility with the old testing code 1723 // compatibility with the old testing code
1721 // If there are any extra parameters, we expect each one to generate a 1724 // 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. 1725 // new tab; if there are none then we get one homepage tab.
1723 int expected_tab_count = 1; 1726 int expected_tab_count = 1;
1724 if (command_line.HasSwitch(switches::kNoStartupWindow)) { 1727 if (command_line.HasSwitch(switches::kNoStartupWindow) &&
1728 !command_line.HasSwitch(switches::kAutoLaunchAtStartup)) {
1725 expected_tab_count = 0; 1729 expected_tab_count = 0;
1726 #if defined(OS_CHROMEOS) 1730 #if defined(OS_CHROMEOS)
1727 // kLoginManager will cause Chrome to start up with the ChromeOS login 1731 // 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. 1732 // screen instead of a browser window, so it won't load any tabs.
1729 } else if (command_line.HasSwitch(switches::kLoginManager)) { 1733 } else if (command_line.HasSwitch(switches::kLoginManager)) {
1730 expected_tab_count = 0; 1734 expected_tab_count = 0;
1731 #endif 1735 #endif
1732 } else if (command_line.HasSwitch(switches::kRestoreLastSession)) { 1736 } else if (command_line.HasSwitch(switches::kRestoreLastSession)) {
1733 std::string restore_session_value( 1737 std::string restore_session_value(
1734 command_line.GetSwitchValueASCII(switches::kRestoreLastSession)); 1738 command_line.GetSwitchValueASCII(switches::kRestoreLastSession));
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 1936
1933 Profile* profile = ProfileManager::GetLastUsedProfile(); 1937 Profile* profile = ProfileManager::GetLastUsedProfile();
1934 if (!profile) { 1938 if (!profile) {
1935 // We should only be able to get here if the profile already exists and 1939 // We should only be able to get here if the profile already exists and
1936 // has been created. 1940 // has been created.
1937 NOTREACHED(); 1941 NOTREACHED();
1938 return; 1942 return;
1939 } 1943 }
1940 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, Profiles(), NULL, NULL); 1944 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, Profiles(), NULL, NULL);
1941 } 1945 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698