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 <algorithm> // For max(). | 7 #include <algorithm> // For max(). |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "apps/app_load_service.h" | 10 #include "apps/app_load_service.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 #include "chrome/browser/google/google_util.h" | 38 #include "chrome/browser/google/google_util.h" |
39 #include "chrome/browser/net/url_fixer_upper.h" | 39 #include "chrome/browser/net/url_fixer_upper.h" |
40 #include "chrome/browser/notifications/desktop_notification_service.h" | 40 #include "chrome/browser/notifications/desktop_notification_service.h" |
41 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 41 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
42 #include "chrome/browser/prefs/session_startup_pref.h" | 42 #include "chrome/browser/prefs/session_startup_pref.h" |
43 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 43 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
44 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" | 44 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" |
45 #include "chrome/browser/printing/print_dialog_cloud.h" | 45 #include "chrome/browser/printing/print_dialog_cloud.h" |
46 #include "chrome/browser/profiles/profile.h" | 46 #include "chrome/browser/profiles/profile.h" |
47 #include "chrome/browser/profiles/profile_manager.h" | 47 #include "chrome/browser/profiles/profile_manager.h" |
48 #include "chrome/browser/search_engines/template_url.h" | 48 #include "chrome/browser/search_engines/util.h" |
49 #include "chrome/browser/search_engines/template_url_service.h" | |
50 #include "chrome/browser/search_engines/template_url_service_factory.h" | |
51 #include "chrome/browser/ui/browser.h" | 49 #include "chrome/browser/ui/browser.h" |
52 #include "chrome/browser/ui/browser_finder.h" | 50 #include "chrome/browser/ui/browser_finder.h" |
53 #include "chrome/browser/ui/browser_window.h" | 51 #include "chrome/browser/ui/browser_window.h" |
54 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 52 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
55 #include "chrome/common/chrome_constants.h" | 53 #include "chrome/common/chrome_constants.h" |
56 #include "chrome/common/chrome_notification_types.h" | 54 #include "chrome/common/chrome_notification_types.h" |
57 #include "chrome/common/chrome_paths.h" | 55 #include "chrome/common/chrome_paths.h" |
58 #include "chrome/common/chrome_result_codes.h" | 56 #include "chrome/common/chrome_result_codes.h" |
59 #include "chrome/common/chrome_switches.h" | 57 #include "chrome/common/chrome_switches.h" |
60 #include "chrome/common/chrome_version_info.h" | 58 #include "chrome/common/chrome_version_info.h" |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 void StartupBrowserCreator::ClearLaunchedProfilesForTesting() { | 375 void StartupBrowserCreator::ClearLaunchedProfilesForTesting() { |
378 profile_launch_observer.Get().Clear(); | 376 profile_launch_observer.Get().Clear(); |
379 } | 377 } |
380 | 378 |
381 // static | 379 // static |
382 std::vector<GURL> StartupBrowserCreator::GetURLsFromCommandLine( | 380 std::vector<GURL> StartupBrowserCreator::GetURLsFromCommandLine( |
383 const CommandLine& command_line, | 381 const CommandLine& command_line, |
384 const base::FilePath& cur_dir, | 382 const base::FilePath& cur_dir, |
385 Profile* profile) { | 383 Profile* profile) { |
386 std::vector<GURL> urls; | 384 std::vector<GURL> urls; |
| 385 |
387 const CommandLine::StringVector& params = command_line.GetArgs(); | 386 const CommandLine::StringVector& params = command_line.GetArgs(); |
388 | |
389 for (size_t i = 0; i < params.size(); ++i) { | 387 for (size_t i = 0; i < params.size(); ++i) { |
390 base::FilePath param = base::FilePath(params[i]); | 388 base::FilePath param = base::FilePath(params[i]); |
391 // Handle Vista way of searching - "? <search-term>" | 389 // Handle Vista way of searching - "? <search-term>" |
392 if (param.value().size() > 2 && | 390 if ((param.value().size() > 2) && (param.value()[0] == '?') && |
393 param.value()[0] == '?' && param.value()[1] == ' ') { | 391 (param.value()[1] == ' ')) { |
394 const TemplateURL* default_provider = | 392 GURL url(GetDefaultSearchURLForSearchTerms( |
395 TemplateURLServiceFactory::GetForProfile(profile)-> | 393 profile, param.LossyDisplayName().substr(2))); |
396 GetDefaultSearchProvider(); | 394 if (url.is_valid()) { |
397 if (default_provider) { | 395 urls.push_back(url); |
398 const TemplateURLRef& search_url = default_provider->url_ref(); | |
399 DCHECK(search_url.SupportsReplacement()); | |
400 string16 search_term = param.LossyDisplayName().substr(2); | |
401 urls.push_back(GURL(search_url.ReplaceSearchTerms( | |
402 TemplateURLRef::SearchTermsArgs(search_term)))); | |
403 continue; | 396 continue; |
404 } | 397 } |
405 } | 398 } |
406 | 399 |
407 // Otherwise, fall through to treating it as a URL. | 400 // Otherwise, fall through to treating it as a URL. |
408 | 401 |
409 // This will create a file URL or a regular URL. | 402 // This will create a file URL or a regular URL. |
410 // This call can (in rare circumstances) block the UI thread. | 403 // This call can (in rare circumstances) block the UI thread. |
411 // Allow it until this bug is fixed. | 404 // Allow it until this bug is fixed. |
412 // http://code.google.com/p/chromium/issues/detail?id=60641 | 405 // http://code.google.com/p/chromium/issues/detail?id=60641 |
(...skipping 16 matching lines...) Expand all Loading... |
429 (url.spec().compare(content::kAboutBlankURL) == 0)) { | 422 (url.spec().compare(content::kAboutBlankURL) == 0)) { |
430 urls.push_back(url); | 423 urls.push_back(url); |
431 } | 424 } |
432 } | 425 } |
433 } | 426 } |
434 #if defined(OS_WIN) | 427 #if defined(OS_WIN) |
435 if (urls.empty()) { | 428 if (urls.empty()) { |
436 // If we are in Windows 8 metro mode and were launched as a result of the | 429 // If we are in Windows 8 metro mode and were launched as a result of the |
437 // search charm or via a url navigation in metro, then fetch the | 430 // search charm or via a url navigation in metro, then fetch the |
438 // corresponding url. | 431 // corresponding url. |
439 GURL url = chrome::GetURLToOpen(profile); | 432 GURL url(chrome::GetURLToOpen(profile)); |
440 if (url.is_valid()) | 433 if (url.is_valid()) |
441 urls.push_back(GURL(url)); | 434 urls.push_back(url); |
442 } | 435 } |
443 #endif // OS_WIN | 436 #endif // OS_WIN |
444 return urls; | 437 return urls; |
445 } | 438 } |
446 | 439 |
447 // static | 440 // static |
448 bool StartupBrowserCreator::ProcessCmdLineImpl( | 441 bool StartupBrowserCreator::ProcessCmdLineImpl( |
449 const CommandLine& command_line, | 442 const CommandLine& command_line, |
450 const base::FilePath& cur_dir, | 443 const base::FilePath& cur_dir, |
451 bool process_startup, | 444 bool process_startup, |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 | 738 |
746 // static | 739 // static |
747 bool StartupBrowserCreator::ActivatedProfile() { | 740 bool StartupBrowserCreator::ActivatedProfile() { |
748 return profile_launch_observer.Get().activated_profile(); | 741 return profile_launch_observer.Get().activated_profile(); |
749 } | 742 } |
750 | 743 |
751 bool HasPendingUncleanExit(Profile* profile) { | 744 bool HasPendingUncleanExit(Profile* profile) { |
752 return profile->GetLastSessionExitType() == Profile::EXIT_CRASHED && | 745 return profile->GetLastSessionExitType() == Profile::EXIT_CRASHED && |
753 !profile_launch_observer.Get().HasBeenLaunched(profile); | 746 !profile_launch_observer.Get().HasBeenLaunched(profile); |
754 } | 747 } |
OLD | NEW |