| 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/startup/startup_browser_creator.h" | 5 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> // For max(). | 9 #include <algorithm> // For max(). |
| 10 #include <set> | 10 #include <set> |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 #if defined(TOOLKIT_VIEWS) && defined(OS_LINUX) | 89 #if defined(TOOLKIT_VIEWS) && defined(OS_LINUX) |
| 90 #include "ui/events/devices/x11/touch_factory_x11.h" | 90 #include "ui/events/devices/x11/touch_factory_x11.h" |
| 91 #endif | 91 #endif |
| 92 | 92 |
| 93 #if defined(OS_MACOSX) | 93 #if defined(OS_MACOSX) |
| 94 #include "chrome/browser/web_applications/web_app_mac.h" | 94 #include "chrome/browser/web_applications/web_app_mac.h" |
| 95 #endif | 95 #endif |
| 96 | 96 |
| 97 #if defined(OS_WIN) | 97 #if defined(OS_WIN) |
| 98 #include "chrome/browser/metrics/jumplist_metrics_win.h" | 98 #include "chrome/browser/metrics/jumplist_metrics_win.h" |
| 99 #include "components/search_engines/desktop_search_win.h" | 99 #include "components/search_engines/desktop_search_utils.h" |
| 100 #endif | 100 #endif |
| 101 | 101 |
| 102 #if defined(ENABLE_PRINT_PREVIEW) | 102 #if defined(ENABLE_PRINT_PREVIEW) |
| 103 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 103 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
| 104 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" | 104 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" |
| 105 #include "chrome/browser/printing/print_dialog_cloud.h" | 105 #include "chrome/browser/printing/print_dialog_cloud.h" |
| 106 #endif | 106 #endif |
| 107 | 107 |
| 108 using content::BrowserThread; | 108 using content::BrowserThread; |
| 109 using content::ChildProcessSecurityPolicy; | 109 using content::ChildProcessSecurityPolicy; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 UserManager::Show( | 298 UserManager::Show( |
| 299 base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL, action); | 299 base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL, action); |
| 300 return true; | 300 return true; |
| 301 #endif | 301 #endif |
| 302 } | 302 } |
| 303 | 303 |
| 304 } // namespace | 304 } // namespace |
| 305 | 305 |
| 306 StartupBrowserCreator::StartupBrowserCreator() | 306 StartupBrowserCreator::StartupBrowserCreator() |
| 307 : is_default_browser_dialog_suppressed_(false), | 307 : is_default_browser_dialog_suppressed_(false), |
| 308 show_main_browser_window_(true) { | 308 show_main_browser_window_(true), |
| 309 } | 309 show_desktop_search_redirection_infobar_(false) {} |
| 310 | 310 |
| 311 StartupBrowserCreator::~StartupBrowserCreator() {} | 311 StartupBrowserCreator::~StartupBrowserCreator() {} |
| 312 | 312 |
| 313 // static | 313 // static |
| 314 bool StartupBrowserCreator::was_restarted_read_ = false; | 314 bool StartupBrowserCreator::was_restarted_read_ = false; |
| 315 | 315 |
| 316 // static | 316 // static |
| 317 bool StartupBrowserCreator::in_synchronous_profile_launch_ = false; | 317 bool StartupBrowserCreator::in_synchronous_profile_launch_ = false; |
| 318 | 318 |
| 319 void StartupBrowserCreator::AddFirstRunTab(const GURL& url) { | 319 void StartupBrowserCreator::AddFirstRunTab(const GURL& url) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 | 363 |
| 364 // Note: This check should have been done in ProcessCmdLineImpl() | 364 // Note: This check should have been done in ProcessCmdLineImpl() |
| 365 // before calling this function. However chromeos/login/login_utils.cc | 365 // before calling this function. However chromeos/login/login_utils.cc |
| 366 // calls this function directly (see comments there) so it has to be checked | 366 // calls this function directly (see comments there) so it has to be checked |
| 367 // again. | 367 // again. |
| 368 const bool silent_launch = command_line.HasSwitch(switches::kSilentLaunch); | 368 const bool silent_launch = command_line.HasSwitch(switches::kSilentLaunch); |
| 369 | 369 |
| 370 if (!silent_launch) { | 370 if (!silent_launch) { |
| 371 StartupBrowserCreatorImpl lwp(cur_dir, command_line, this, is_first_run); | 371 StartupBrowserCreatorImpl lwp(cur_dir, command_line, this, is_first_run); |
| 372 const std::vector<GURL> urls_to_launch = | 372 const std::vector<GURL> urls_to_launch = |
| 373 GetURLsFromCommandLine(command_line, cur_dir, profile); | 373 GetURLsFromCommandLine(command_line, cur_dir, profile, |
| 374 &show_desktop_search_redirection_infobar_); |
| 374 chrome::HostDesktopType host_desktop_type = | 375 chrome::HostDesktopType host_desktop_type = |
| 375 chrome::HOST_DESKTOP_TYPE_NATIVE; | 376 chrome::HOST_DESKTOP_TYPE_NATIVE; |
| 376 | 377 |
| 377 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | 378 #if defined(USE_ASH) && !defined(OS_CHROMEOS) |
| 378 // We want to maintain only one type of instance for now, either ASH | 379 // We want to maintain only one type of instance for now, either ASH |
| 379 // or desktop. | 380 // or desktop. |
| 380 // TODO(shrikant): Remove this code once we decide on running both desktop | 381 // TODO(shrikant): Remove this code once we decide on running both desktop |
| 381 // and ASH instances side by side. | 382 // and ASH instances side by side. |
| 382 if (ash::Shell::HasInstance()) | 383 if (ash::Shell::HasInstance()) |
| 383 host_desktop_type = chrome::HOST_DESKTOP_TYPE_ASH; | 384 host_desktop_type = chrome::HOST_DESKTOP_TYPE_ASH; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 // static | 523 // static |
| 523 const wchar_t* StartupBrowserCreator::GetDefaultBrowserUrl() { | 524 const wchar_t* StartupBrowserCreator::GetDefaultBrowserUrl() { |
| 524 return kSetDefaultBrowserHelpUrl; | 525 return kSetDefaultBrowserHelpUrl; |
| 525 } | 526 } |
| 526 #endif // defined(OS_WIN) | 527 #endif // defined(OS_WIN) |
| 527 | 528 |
| 528 // static | 529 // static |
| 529 std::vector<GURL> StartupBrowserCreator::GetURLsFromCommandLine( | 530 std::vector<GURL> StartupBrowserCreator::GetURLsFromCommandLine( |
| 530 const base::CommandLine& command_line, | 531 const base::CommandLine& command_line, |
| 531 const base::FilePath& cur_dir, | 532 const base::FilePath& cur_dir, |
| 532 Profile* profile) { | 533 Profile* profile, |
| 534 bool* show_desktop_search_redirection_infobar) { |
| 535 DCHECK(profile); |
| 536 DCHECK(show_desktop_search_redirection_infobar); |
| 537 |
| 533 std::vector<GURL> urls; | 538 std::vector<GURL> urls; |
| 534 | 539 |
| 535 const base::CommandLine::StringVector& params = command_line.GetArgs(); | 540 const base::CommandLine::StringVector& params = command_line.GetArgs(); |
| 536 for (size_t i = 0; i < params.size(); ++i) { | 541 for (size_t i = 0; i < params.size(); ++i) { |
| 537 base::FilePath param = base::FilePath(params[i]); | 542 base::FilePath param = base::FilePath(params[i]); |
| 538 // Handle Vista way of searching - "? <search-term>" | 543 // Handle Vista way of searching - "? <search-term>" |
| 539 if ((param.value().size() > 2) && (param.value()[0] == '?') && | 544 if ((param.value().size() > 2) && (param.value()[0] == '?') && |
| 540 (param.value()[1] == ' ')) { | 545 (param.value()[1] == ' ')) { |
| 541 GURL url(GetDefaultSearchURLForSearchTerms( | 546 GURL url(GetDefaultSearchURLForSearchTerms( |
| 542 TemplateURLServiceFactory::GetForProfile(profile), | 547 TemplateURLServiceFactory::GetForProfile(profile), |
| 543 param.LossyDisplayName().substr(2))); | 548 param.LossyDisplayName().substr(2))); |
| 544 if (url.is_valid()) { | 549 if (url.is_valid()) { |
| 545 urls.push_back(url); | 550 urls.push_back(url); |
| 546 continue; | 551 continue; |
| 547 } | 552 } |
| 548 } | 553 } |
| 549 | 554 |
| 550 // Otherwise, fall through to treating it as a URL. | 555 // Otherwise, fall through to treating it as a URL. |
| 551 | 556 |
| 552 // This will create a file URL or a regular URL. | 557 // This will create a file URL or a regular URL. |
| 553 // This call can (in rare circumstances) block the UI thread. | 558 // This call can (in rare circumstances) block the UI thread. |
| 554 // Allow it until this bug is fixed. | 559 // Allow it until this bug is fixed. |
| 555 // http://code.google.com/p/chromium/issues/detail?id=60641 | 560 // http://code.google.com/p/chromium/issues/detail?id=60641 |
| 556 GURL url = GURL(param.MaybeAsASCII()); | 561 GURL url = GURL(param.MaybeAsASCII()); |
| 557 | 562 |
| 558 #if defined(OS_WIN) | 563 #if defined(OS_WIN) |
| 559 if (ShouldRedirectWindowsDesktopSearchToDefaultSearchEngine( | 564 // Replace desktop search URL by a default search engine URL if needed. |
| 560 profile->GetPrefs())) { | 565 // Ignore cases where there are multiple command line arguments, because |
| 561 TemplateURLService* template_url_service = | 566 // desktop search never passes multiple URLs to the browser. |
| 562 TemplateURLServiceFactory::GetForProfile(profile); | 567 if (params.size() == 1) { |
| 563 DCHECK(template_url_service); | 568 *show_desktop_search_redirection_infobar = |
| 564 base::string16 search_terms; | 569 ReplaceDesktopSearchURLWithDefaultSearchURLIfNeeded( |
| 565 if (DetectWindowsDesktopSearch( | 570 profile->GetPrefs(), |
| 566 url, template_url_service->search_terms_data(), &search_terms)) { | 571 TemplateURLServiceFactory::GetForProfile(profile), &url); |
| 567 const GURL search_url(GetDefaultSearchURLForSearchTerms( | |
| 568 template_url_service, search_terms)); | |
| 569 if (search_url.is_valid()) { | |
| 570 urls.push_back(search_url); | |
| 571 continue; | |
| 572 } | |
| 573 } | |
| 574 } | 572 } |
| 575 #endif // defined(OS_WIN) | 573 #endif // defined(OS_WIN) |
| 576 | 574 |
| 577 // http://crbug.com/371030: Only use URLFixerUpper if we don't have a valid | 575 // http://crbug.com/371030: Only use URLFixerUpper if we don't have a valid |
| 578 // URL, otherwise we will look in the current directory for a file named | 576 // URL, otherwise we will look in the current directory for a file named |
| 579 // 'about' if the browser was started with a about:foo argument. | 577 // 'about' if the browser was started with a about:foo argument. |
| 580 if (!url.is_valid()) { | 578 if (!url.is_valid()) { |
| 581 base::ThreadRestrictions::ScopedAllowIO allow_io; | 579 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 582 url = url_formatter::FixupRelativeFile(cur_dir, param); | 580 url = url_formatter::FixupRelativeFile(cur_dir, param); |
| 583 } | 581 } |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 // If we are showing the app list then chrome isn't shown so load the app | 930 // If we are showing the app list then chrome isn't shown so load the app |
| 933 // list's profile rather than chrome's. | 931 // list's profile rather than chrome's. |
| 934 if (command_line.HasSwitch(switches::kShowAppList)) { | 932 if (command_line.HasSwitch(switches::kShowAppList)) { |
| 935 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> | 933 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> |
| 936 GetProfilePath(user_data_dir); | 934 GetProfilePath(user_data_dir); |
| 937 } | 935 } |
| 938 | 936 |
| 939 return g_browser_process->profile_manager()->GetLastUsedProfileDir( | 937 return g_browser_process->profile_manager()->GetLastUsedProfileDir( |
| 940 user_data_dir); | 938 user_data_dir); |
| 941 } | 939 } |
| OLD | NEW |