Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/browser_init.h" | 5 #include "chrome/browser/browser_init.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/event_recorder.h" | 9 #include "base/event_recorder.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 #include "chrome/browser/extensions/extensions_service.h" | 21 #include "chrome/browser/extensions/extensions_service.h" |
| 22 #include "chrome/browser/first_run.h" | 22 #include "chrome/browser/first_run.h" |
| 23 #include "chrome/browser/net/dns_global.h" | 23 #include "chrome/browser/net/dns_global.h" |
| 24 #include "chrome/browser/notifications/desktop_notification_service.h" | 24 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 25 #include "chrome/browser/pref_service.h" | 25 #include "chrome/browser/pref_service.h" |
| 26 #include "chrome/browser/profile.h" | 26 #include "chrome/browser/profile.h" |
| 27 #include "chrome/browser/renderer_host/render_process_host.h" | 27 #include "chrome/browser/renderer_host/render_process_host.h" |
| 28 #include "chrome/browser/search_engines/template_url_model.h" | 28 #include "chrome/browser/search_engines/template_url_model.h" |
| 29 #include "chrome/browser/session_startup_pref.h" | 29 #include "chrome/browser/session_startup_pref.h" |
| 30 #include "chrome/browser/sessions/session_restore.h" | 30 #include "chrome/browser/sessions/session_restore.h" |
| 31 #include "chrome/browser/sessions/session_service.h" | |
| 31 #include "chrome/browser/shell_integration.h" | 32 #include "chrome/browser/shell_integration.h" |
| 32 #include "chrome/browser/tabs/pinned_tab_codec.h" | 33 #include "chrome/browser/tabs/pinned_tab_codec.h" |
| 33 #include "chrome/browser/tab_contents/infobar_delegate.h" | 34 #include "chrome/browser/tab_contents/infobar_delegate.h" |
| 34 #include "chrome/browser/tab_contents/navigation_controller.h" | 35 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 35 #include "chrome/browser/tab_contents/tab_contents.h" | 36 #include "chrome/browser/tab_contents/tab_contents.h" |
| 36 #include "chrome/browser/tab_contents/tab_contents_view.h" | 37 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 37 #include "chrome/browser/net/url_fixer_upper.h" | 38 #include "chrome/browser/net/url_fixer_upper.h" |
| 38 #include "chrome/browser/status_icons/status_tray_manager.h" | 39 #include "chrome/browser/status_icons/status_tray_manager.h" |
| 39 #include "chrome/browser/user_data_manager.h" | 40 #include "chrome/browser/user_data_manager.h" |
| 40 #include "chrome/common/chrome_constants.h" | 41 #include "chrome/common/chrome_constants.h" |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 482 webkit_glue::SetUserAgent(command_line_.GetSwitchValueASCII( | 483 webkit_glue::SetUserAgent(command_line_.GetSwitchValueASCII( |
| 483 switches::kUserAgent)); | 484 switches::kUserAgent)); |
| 484 } | 485 } |
| 485 | 486 |
| 486 // Open the required browser windows and tabs. | 487 // Open the required browser windows and tabs. |
| 487 // First, see if we're being run as an application window. | 488 // First, see if we're being run as an application window. |
| 488 if (!OpenApplicationWindow(profile)) { | 489 if (!OpenApplicationWindow(profile)) { |
| 489 std::vector<GURL> urls_to_open = GetURLsFromCommandLine(profile_); | 490 std::vector<GURL> urls_to_open = GetURLsFromCommandLine(profile_); |
| 490 RecordLaunchModeHistogram(urls_to_open.empty()? | 491 RecordLaunchModeHistogram(urls_to_open.empty()? |
| 491 LM_TO_BE_DECIDED : LM_WITH_URLS); | 492 LM_TO_BE_DECIDED : LM_WITH_URLS); |
| 492 | |
| 493 // TODO(viettrungluu): Temporary: Display a EULA before allowing the user to | 493 // TODO(viettrungluu): Temporary: Display a EULA before allowing the user to |
| 494 // actually enable Flash, unless they've already accepted it. Process this | 494 // actually enable Flash, unless they've already accepted it. Process this |
| 495 // in the same way as command-line URLs. | 495 // in the same way as command-line URLs. |
| 496 FilePath flash_path; | 496 FilePath flash_path; |
| 497 if (command_line_.HasSwitch(switches::kEnableInternalFlash) && | 497 if (command_line_.HasSwitch(switches::kEnableInternalFlash) && |
| 498 PathService::Get(chrome::FILE_FLASH_PLUGIN, &flash_path)) { | 498 PathService::Get(chrome::FILE_FLASH_PLUGIN, &flash_path)) { |
| 499 PrefService* prefs = profile->GetPrefs(); | 499 PrefService* prefs = profile->GetPrefs(); |
| 500 // Check whether the EULA has previously been accepted, defaulting to | 500 // Check whether the EULA has previously been accepted, defaulting to |
| 501 // "no". If it hasn't, display a page which links to the EULA, etc. (This | 501 // "no". If it hasn't, display a page which links to the EULA, etc. (This |
| 502 // pref is registered by the plugin service.) | 502 // pref is registered by the plugin service.) |
| 503 if (!prefs->GetBoolean(prefs::kPluginsFlashAuthorized)) { | 503 if (!prefs->GetBoolean(prefs::kPluginsFlashAuthorized)) { |
| 504 urls_to_open.push_back( | 504 urls_to_open.push_back( |
| 505 GURL(chrome::kChromeUIPluginsAuthorizeFlashPathURL)); | 505 GURL(chrome::kChromeUIPluginsAuthorizeFlashPathURL)); |
| 506 } | 506 } |
| 507 } | 507 } |
| 508 | 508 |
| 509 if (!process_startup || !OpenStartupURLs(urls_to_open)) { | 509 ProcessLaunchURLs(process_startup, urls_to_open); |
| 510 // Add the home page and any special first run URLs. | |
| 511 Browser* browser = NULL; | |
| 512 if (urls_to_open.empty()) | |
| 513 AddStartupURLs(&urls_to_open); | |
| 514 else if (!command_line_.HasSwitch(switches::kOpenInNewWindow)) | |
| 515 browser = BrowserList::GetLastActive(); | |
| 516 | |
| 517 OpenURLsInBrowser(browser, process_startup, urls_to_open); | |
| 518 } | |
| 519 | 510 |
| 520 // If this is an app launch, but we didn't open an app window, it may | 511 // If this is an app launch, but we didn't open an app window, it may |
| 521 // be an app tab. | 512 // be an app tab. |
| 522 std::string app_id; | 513 std::string app_id; |
| 523 if (IsAppLaunch(NULL, &app_id) && !app_id.empty()) { | 514 if (IsAppLaunch(NULL, &app_id) && !app_id.empty()) { |
| 524 // TODO(erikkay): This could fail if |app_id| is invalid (the app was | 515 // TODO(erikkay): This could fail if |app_id| is invalid (the app was |
| 525 // uninstalled). We may want to show some reasonable error here. | 516 // uninstalled). We may want to show some reasonable error here. |
| 526 Browser::OpenApplication(profile, app_id); | 517 Browser::OpenApplication(profile, app_id); |
| 527 } | 518 } |
| 528 | 519 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 ChildProcessSecurityPolicy::GetInstance(); | 612 ChildProcessSecurityPolicy::GetInstance(); |
| 622 if (policy->IsWebSafeScheme(url.scheme()) || | 613 if (policy->IsWebSafeScheme(url.scheme()) || |
| 623 url.SchemeIs(chrome::kFileScheme)) { | 614 url.SchemeIs(chrome::kFileScheme)) { |
| 624 Browser::OpenApplicationWindow(profile, url, false); | 615 Browser::OpenApplicationWindow(profile, url, false); |
| 625 return true; | 616 return true; |
| 626 } | 617 } |
| 627 } | 618 } |
| 628 return false; | 619 return false; |
| 629 } | 620 } |
| 630 | 621 |
| 631 bool BrowserInit::LaunchWithProfile::OpenStartupURLs( | 622 void BrowserInit::LaunchWithProfile::ProcessLaunchURLs( |
| 623 bool process_startup, | |
| 624 const std::vector<GURL>& urls_to_open) { | |
| 625 if (process_startup && ProcessStartupURLs(urls_to_open)) { | |
| 626 // ProcessStartupURLs processed the urls, nothing else to do. | |
| 627 return; | |
| 628 } | |
| 629 | |
| 630 if (!process_startup && | |
| 631 (profile_->GetSessionService() && | |
| 632 profile_->GetSessionService()->RestoreIfNecessary(urls_to_open))) { | |
| 633 // We're already running and session restore wanted to run. This can happen | |
| 634 // at various point, such as if there is only an app window running and the | |
|
brettw
2010/03/26 00:33:32
grammar: point -> points
| |
| 635 // user double clicked the chrome icon. Return so we don't open the urls. | |
| 636 return; | |
| 637 } | |
| 638 | |
| 639 // Session restore didn't occur, open the urls. | |
| 640 | |
| 641 Browser* browser = NULL; | |
| 642 std::vector<GURL> adjust_urls = urls_to_open; | |
| 643 if (adjust_urls.empty()) | |
| 644 AddStartupURLs(&adjust_urls); | |
| 645 else if (!command_line_.HasSwitch(switches::kOpenInNewWindow)) | |
| 646 browser = BrowserList::GetLastActive(); | |
| 647 | |
| 648 OpenURLsInBrowser(browser, process_startup, adjust_urls); | |
| 649 } | |
| 650 | |
| 651 bool BrowserInit::LaunchWithProfile::ProcessStartupURLs( | |
| 632 const std::vector<GURL>& urls_to_open) { | 652 const std::vector<GURL>& urls_to_open) { |
| 633 SessionStartupPref pref = GetSessionStartupPref(command_line_, profile_); | 653 SessionStartupPref pref = GetSessionStartupPref(command_line_, profile_); |
| 634 if (command_line_.HasSwitch(switches::kTestingChannelID) && | 654 if (command_line_.HasSwitch(switches::kTestingChannelID) && |
| 635 !command_line_.HasSwitch(switches::kRestoreLastSession) && | 655 !command_line_.HasSwitch(switches::kRestoreLastSession) && |
| 636 browser_defaults::kDefaultSessionStartupType != | 656 browser_defaults::kDefaultSessionStartupType != |
| 637 SessionStartupPref::DEFAULT) { | 657 SessionStartupPref::DEFAULT) { |
| 638 // When we have non DEFAULT session start type, then we won't open up a | 658 // When we have non DEFAULT session start type, then we won't open up a |
| 639 // fresh session. But none of the tests are written with this in mind, so | 659 // fresh session. But none of the tests are written with this in mind, so |
| 640 // we explicitly ignore it during testing. | 660 // we explicitly ignore it during testing. |
| 641 return false; | 661 return false; |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1009 scoped_refptr<AutomationProviderClass> automation = | 1029 scoped_refptr<AutomationProviderClass> automation = |
| 1010 new AutomationProviderClass(profile); | 1030 new AutomationProviderClass(profile); |
| 1011 automation->ConnectToChannel(channel_id); | 1031 automation->ConnectToChannel(channel_id); |
| 1012 automation->SetExpectedTabCount(expected_tabs); | 1032 automation->SetExpectedTabCount(expected_tabs); |
| 1013 | 1033 |
| 1014 AutomationProviderList* list = | 1034 AutomationProviderList* list = |
| 1015 g_browser_process->InitAutomationProviderList(); | 1035 g_browser_process->InitAutomationProviderList(); |
| 1016 DCHECK(list); | 1036 DCHECK(list); |
| 1017 list->AddProvider(automation); | 1037 list->AddProvider(automation); |
| 1018 } | 1038 } |
| OLD | NEW |