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

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: gclient sync, ignore 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::DisableForegroundStartAtLogin,
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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 // Look for the testing channel ID ONLY during process startup 1729 // Look for the testing channel ID ONLY during process startup
1727 if (process_startup && 1730 if (process_startup &&
1728 command_line.HasSwitch(switches::kTestingChannelID)) { 1731 command_line.HasSwitch(switches::kTestingChannelID)) {
1729 std::string testing_channel_id = command_line.GetSwitchValueASCII( 1732 std::string testing_channel_id = command_line.GetSwitchValueASCII(
1730 switches::kTestingChannelID); 1733 switches::kTestingChannelID);
1731 // TODO(sanjeevr) Check if we need to make this a singleton for 1734 // TODO(sanjeevr) Check if we need to make this a singleton for
1732 // compatibility with the old testing code 1735 // compatibility with the old testing code
1733 // If there are any extra parameters, we expect each one to generate a 1736 // If there are any extra parameters, we expect each one to generate a
1734 // new tab; if there are none then we get one homepage tab. 1737 // new tab; if there are none then we get one homepage tab.
1735 int expected_tab_count = 1; 1738 int expected_tab_count = 1;
1736 if (command_line.HasSwitch(switches::kNoStartupWindow)) { 1739 if (command_line.HasSwitch(switches::kNoStartupWindow) &&
1740 !command_line.HasSwitch(switches::kAutoLaunchAtStartup)) {
1737 expected_tab_count = 0; 1741 expected_tab_count = 0;
1738 #if defined(OS_CHROMEOS) 1742 #if defined(OS_CHROMEOS)
1739 // kLoginManager will cause Chrome to start up with the ChromeOS login 1743 // kLoginManager will cause Chrome to start up with the ChromeOS login
1740 // screen instead of a browser window, so it won't load any tabs. 1744 // screen instead of a browser window, so it won't load any tabs.
1741 } else if (command_line.HasSwitch(switches::kLoginManager)) { 1745 } else if (command_line.HasSwitch(switches::kLoginManager)) {
1742 expected_tab_count = 0; 1746 expected_tab_count = 0;
1743 #endif 1747 #endif
1744 } else if (command_line.HasSwitch(switches::kRestoreLastSession)) { 1748 } else if (command_line.HasSwitch(switches::kRestoreLastSession)) {
1745 std::string restore_session_value( 1749 std::string restore_session_value(
1746 command_line.GetSwitchValueASCII(switches::kRestoreLastSession)); 1750 command_line.GetSwitchValueASCII(switches::kRestoreLastSession));
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1944 1948
1945 Profile* profile = ProfileManager::GetLastUsedProfile(); 1949 Profile* profile = ProfileManager::GetLastUsedProfile();
1946 if (!profile) { 1950 if (!profile) {
1947 // We should only be able to get here if the profile already exists and 1951 // We should only be able to get here if the profile already exists and
1948 // has been created. 1952 // has been created.
1949 NOTREACHED(); 1953 NOTREACHED();
1950 return; 1954 return;
1951 } 1955 }
1952 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, Profiles(), NULL, NULL); 1956 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, Profiles(), NULL, NULL);
1953 } 1957 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698