| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "chrome/browser/component_updater/component_updater_service.h" | 29 #include "chrome/browser/component_updater/component_updater_service.h" |
| 30 #include "chrome/browser/component_updater/flash_component_installer.h" | 30 #include "chrome/browser/component_updater/flash_component_installer.h" |
| 31 #include "chrome/browser/component_updater/recovery_component_installer.h" | 31 #include "chrome/browser/component_updater/recovery_component_installer.h" |
| 32 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h" | 32 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h" |
| 33 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 33 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 34 #include "chrome/browser/defaults.h" | 34 #include "chrome/browser/defaults.h" |
| 35 #include "chrome/browser/extensions/extension_creator.h" | 35 #include "chrome/browser/extensions/extension_creator.h" |
| 36 #include "chrome/browser/extensions/extension_service.h" | 36 #include "chrome/browser/extensions/extension_service.h" |
| 37 #include "chrome/browser/extensions/pack_extension_job.h" | 37 #include "chrome/browser/extensions/pack_extension_job.h" |
| 38 #include "chrome/browser/first_run/first_run.h" | 38 #include "chrome/browser/first_run/first_run.h" |
| 39 #include "chrome/browser/google/google_util.h" |
| 39 #include "chrome/browser/infobars/infobar_tab_helper.h" | 40 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 40 #include "chrome/browser/net/crl_set_fetcher.h" | 41 #include "chrome/browser/net/crl_set_fetcher.h" |
| 41 #include "chrome/browser/net/predictor.h" | 42 #include "chrome/browser/net/predictor.h" |
| 42 #include "chrome/browser/net/url_fixer_upper.h" | 43 #include "chrome/browser/net/url_fixer_upper.h" |
| 43 #include "chrome/browser/notifications/desktop_notification_service.h" | 44 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 44 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 45 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 45 #include "chrome/browser/prefs/pref_service.h" | 46 #include "chrome/browser/prefs/pref_service.h" |
| 46 #include "chrome/browser/prefs/session_startup_pref.h" | 47 #include "chrome/browser/prefs/session_startup_pref.h" |
| 47 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 48 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
| 48 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" | 49 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 bool DefaultBrowserInfoBarDelegate::Cancel() { | 337 bool DefaultBrowserInfoBarDelegate::Cancel() { |
| 337 action_taken_ = true; | 338 action_taken_ = true; |
| 338 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.DontSetAsDefault", 1); | 339 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.DontSetAsDefault", 1); |
| 339 // User clicked "Don't ask me again", remember that. | 340 // User clicked "Don't ask me again", remember that. |
| 340 prefs_->SetBoolean(prefs::kCheckDefaultBrowser, false); | 341 prefs_->SetBoolean(prefs::kCheckDefaultBrowser, false); |
| 341 return true; | 342 return true; |
| 342 } | 343 } |
| 343 | 344 |
| 344 #if defined(OS_WIN) | 345 #if defined(OS_WIN) |
| 345 void CheckAutoLaunchCallback() { | 346 void CheckAutoLaunchCallback() { |
| 346 if (!auto_launch_trial::IsInAutoLaunchGroup()) | 347 if (!auto_launch_trial::IsInAutoLaunchFieldTrial()) |
| 347 return; | 348 return; |
| 348 | 349 |
| 349 Browser* browser = BrowserList::GetLastActive(); | 350 Browser* browser = BrowserList::GetLastActive(); |
| 350 TabContentsWrapper* tab = browser->GetSelectedTabContentsWrapper(); | 351 TabContentsWrapper* tab = browser->GetSelectedTabContentsWrapper(); |
| 351 | 352 |
| 352 int infobar_shown = | 353 // Don't show the info-bar if there are already info-bars showing. |
| 353 tab->profile()->GetPrefs()->GetInteger(prefs::kShownAutoLaunchInfobar); | 354 InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); |
| 354 if (infobar_shown >= kMaxInfobarShown) | 355 if (infobar_helper->infobar_count() > 0) |
| 355 return; | 356 return; |
| 356 | 357 |
| 357 InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); | |
| 358 infobar_helper->AddInfoBar( | 358 infobar_helper->AddInfoBar( |
| 359 new AutolaunchInfoBarDelegate(infobar_helper, | 359 new AutolaunchInfoBarDelegate(infobar_helper, |
| 360 tab->profile()->GetPrefs())); | 360 tab->profile()->GetPrefs())); |
| 361 } | 361 } |
| 362 #endif | 362 #endif |
| 363 | 363 |
| 364 void NotifyNotDefaultBrowserCallback() { | 364 void NotifyNotDefaultBrowserCallback() { |
| 365 Browser* browser = BrowserList::GetLastActive(); | 365 Browser* browser = BrowserList::GetLastActive(); |
| 366 if (!browser) | 366 if (!browser) |
| 367 return; // Reached during ui tests. | 367 return; // Reached during ui tests. |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 LM_TO_BE_DECIDED : LM_WITH_URLS); | 836 LM_TO_BE_DECIDED : LM_WITH_URLS); |
| 837 ProcessLaunchURLs(process_startup, urls_to_open); | 837 ProcessLaunchURLs(process_startup, urls_to_open); |
| 838 | 838 |
| 839 // If this is an app launch, but we didn't open an app window, it may | 839 // If this is an app launch, but we didn't open an app window, it may |
| 840 // be an app tab. | 840 // be an app tab. |
| 841 OpenApplicationTab(profile); | 841 OpenApplicationTab(profile); |
| 842 | 842 |
| 843 if (process_startup) { | 843 if (process_startup) { |
| 844 if (browser_defaults::kOSSupportsOtherBrowsers && | 844 if (browser_defaults::kOSSupportsOtherBrowsers && |
| 845 !command_line_.HasSwitch(switches::kNoDefaultBrowserCheck)) { | 845 !command_line_.HasSwitch(switches::kNoDefaultBrowserCheck)) { |
| 846 CheckIfAutoLaunched(profile); | 846 if (!CheckIfAutoLaunched(profile)) { |
| 847 | 847 // Check whether we are the default browser. |
| 848 // Check whether we are the default browser. | 848 CheckDefaultBrowser(profile); |
| 849 CheckDefaultBrowser(profile); | 849 } |
| 850 } | 850 } |
| 851 #if defined(OS_MACOSX) | 851 #if defined(OS_MACOSX) |
| 852 // Check whether the auto-update system needs to be promoted from user | 852 // Check whether the auto-update system needs to be promoted from user |
| 853 // to system. | 853 // to system. |
| 854 KeystoneInfoBar::PromotionInfoBar(profile); | 854 KeystoneInfoBar::PromotionInfoBar(profile); |
| 855 #endif | 855 #endif |
| 856 } | 856 } |
| 857 } | 857 } |
| 858 | 858 |
| 859 #if defined(OS_WIN) | 859 #if defined(OS_WIN) |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1448 } else { | 1448 } else { |
| 1449 // TODO(pastarmovj): We can't really do anything meaningful here yet but | 1449 // TODO(pastarmovj): We can't really do anything meaningful here yet but |
| 1450 // just prevent showing the infobar. | 1450 // just prevent showing the infobar. |
| 1451 } | 1451 } |
| 1452 return; | 1452 return; |
| 1453 } | 1453 } |
| 1454 BrowserThread::PostTask( | 1454 BrowserThread::PostTask( |
| 1455 BrowserThread::FILE, FROM_HERE, base::Bind(&CheckDefaultBrowserCallback)); | 1455 BrowserThread::FILE, FROM_HERE, base::Bind(&CheckDefaultBrowserCallback)); |
| 1456 } | 1456 } |
| 1457 | 1457 |
| 1458 void BrowserInit::LaunchWithProfile::CheckIfAutoLaunched(Profile* profile) { | 1458 bool BrowserInit::LaunchWithProfile::CheckIfAutoLaunched(Profile* profile) { |
| 1459 #if defined(OS_WIN) | 1459 #if defined(OS_WIN) |
| 1460 if (!auto_launch_trial::IsInAutoLaunchGroup()) | 1460 if (!auto_launch_trial::IsInAutoLaunchFieldTrial()) |
| 1461 return; | 1461 return false; |
| 1462 |
| 1463 int infobar_shown = |
| 1464 profile->GetPrefs()->GetInteger(prefs::kShownAutoLaunchInfobar); |
| 1465 if (infobar_shown >= kMaxInfobarShown) |
| 1466 return false; |
| 1462 | 1467 |
| 1463 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 1468 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 1464 if (command_line.HasSwitch(switches::kAutoLaunchAtStartup)) { | 1469 if (command_line.HasSwitch(switches::kAutoLaunchAtStartup) || |
| 1470 FirstRun::IsChromeFirstRun()) { |
| 1465 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 1471 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 1466 base::Bind(&CheckAutoLaunchCallback)); | 1472 base::Bind(&CheckAutoLaunchCallback)); |
| 1473 return true; |
| 1467 } | 1474 } |
| 1475 |
| 1476 return false; |
| 1468 #endif | 1477 #endif |
| 1469 } | 1478 } |
| 1470 | 1479 |
| 1471 std::vector<GURL> BrowserInit::GetURLsFromCommandLine( | 1480 std::vector<GURL> BrowserInit::GetURLsFromCommandLine( |
| 1472 const CommandLine& command_line, | 1481 const CommandLine& command_line, |
| 1473 const FilePath& cur_dir, | 1482 const FilePath& cur_dir, |
| 1474 Profile* profile) { | 1483 Profile* profile) { |
| 1475 std::vector<GURL> urls; | 1484 std::vector<GURL> urls; |
| 1476 const CommandLine::StringVector& params = command_line.GetArgs(); | 1485 const CommandLine::StringVector& params = command_line.GetArgs(); |
| 1477 | 1486 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1706 | 1715 |
| 1707 Profile* profile = ProfileManager::GetLastUsedProfile(); | 1716 Profile* profile = ProfileManager::GetLastUsedProfile(); |
| 1708 if (!profile) { | 1717 if (!profile) { |
| 1709 // We should only be able to get here if the profile already exists and | 1718 // We should only be able to get here if the profile already exists and |
| 1710 // has been created. | 1719 // has been created. |
| 1711 NOTREACHED(); | 1720 NOTREACHED(); |
| 1712 return; | 1721 return; |
| 1713 } | 1722 } |
| 1714 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, NULL, NULL); | 1723 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, NULL, NULL); |
| 1715 } | 1724 } |
| OLD | NEW |