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 <memory> | 10 #include <memory> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "base/lazy_instance.h" | 22 #include "base/lazy_instance.h" |
23 #include "base/logging.h" | 23 #include "base/logging.h" |
24 #include "base/macros.h" | 24 #include "base/macros.h" |
25 #include "base/metrics/histogram_macros.h" | 25 #include "base/metrics/histogram_macros.h" |
26 #include "base/metrics/statistics_recorder.h" | 26 #include "base/metrics/statistics_recorder.h" |
27 #include "base/metrics/user_metrics.h" | 27 #include "base/metrics/user_metrics.h" |
28 #include "base/metrics/user_metrics_action.h" | 28 #include "base/metrics/user_metrics_action.h" |
29 #include "base/strings/string_number_conversions.h" | 29 #include "base/strings/string_number_conversions.h" |
30 #include "base/strings/string_split.h" | 30 #include "base/strings/string_split.h" |
31 #include "base/strings/string_tokenizer.h" | 31 #include "base/strings/string_tokenizer.h" |
| 32 #include "base/strings/string_util.h" |
32 #include "base/strings/utf_string_conversions.h" | 33 #include "base/strings/utf_string_conversions.h" |
33 #include "base/threading/thread_restrictions.h" | 34 #include "base/threading/thread_restrictions.h" |
34 #include "base/trace_event/trace_event.h" | 35 #include "base/trace_event/trace_event.h" |
35 #include "build/build_config.h" | 36 #include "build/build_config.h" |
36 #include "chrome/browser/app_mode/app_mode_utils.h" | 37 #include "chrome/browser/app_mode/app_mode_utils.h" |
37 #include "chrome/browser/browser_process.h" | 38 #include "chrome/browser/browser_process.h" |
38 #include "chrome/browser/chrome_notification_types.h" | 39 #include "chrome/browser/chrome_notification_types.h" |
39 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 40 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
40 #include "chrome/browser/extensions/startup_helper.h" | 41 #include "chrome/browser/extensions/startup_helper.h" |
41 #include "chrome/browser/extensions/unpacked_installer.h" | 42 #include "chrome/browser/extensions/unpacked_installer.h" |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 GURL url = GURL(param.MaybeAsASCII()); | 515 GURL url = GURL(param.MaybeAsASCII()); |
515 | 516 |
516 // http://crbug.com/371030: Only use URLFixerUpper if we don't have a valid | 517 // http://crbug.com/371030: Only use URLFixerUpper if we don't have a valid |
517 // URL, otherwise we will look in the current directory for a file named | 518 // URL, otherwise we will look in the current directory for a file named |
518 // 'about' if the browser was started with a about:foo argument. | 519 // 'about' if the browser was started with a about:foo argument. |
519 if (!url.is_valid()) { | 520 if (!url.is_valid()) { |
520 base::ThreadRestrictions::ScopedAllowIO allow_io; | 521 base::ThreadRestrictions::ScopedAllowIO allow_io; |
521 url = url_formatter::FixupRelativeFile(cur_dir, param); | 522 url = url_formatter::FixupRelativeFile(cur_dir, param); |
522 } | 523 } |
523 // Exclude dangerous schemes. | 524 // Exclude dangerous schemes. |
524 if (url.is_valid()) { | 525 if (!url.is_valid()) |
525 ChildProcessSecurityPolicy* policy = | 526 continue; |
526 ChildProcessSecurityPolicy::GetInstance(); | 527 |
527 if (policy->IsWebSafeScheme(url.scheme()) || | 528 ChildProcessSecurityPolicy* policy = |
528 url.SchemeIs(url::kFileScheme) || | 529 ChildProcessSecurityPolicy::GetInstance(); |
| 530 if (policy->IsWebSafeScheme(url.scheme()) || |
| 531 url.SchemeIs(url::kFileScheme) || |
529 #if defined(OS_CHROMEOS) | 532 #if defined(OS_CHROMEOS) |
530 // In ChromeOS, allow any settings page to be specified on the command | 533 // In ChromeOS, allow any settings page to be specified on the command |
531 // line. See ExistingUserController::OnLoginSuccess. | 534 // line. See ExistingUserController::OnLoginSuccess. |
532 (url.spec().find(chrome::kChromeUISettingsURL) == 0) || | 535 base::StartsWith(url.spec(), chrome::kChromeUISettingsURL, |
| 536 base::CompareCase::SENSITIVE) || |
533 #else | 537 #else |
534 // Exposed for external cleaners to offer a settings reset to the | 538 // Exposed for external cleaners to offer a settings reset to the |
535 // user. So the URL must match exactly, without any param or prefix. | 539 // user. So the URL must match exactly, without any param or prefix. |
536 (url.spec() == | 540 (url.spec() == |
537 std::string(chrome::kChromeUISettingsURL) + | 541 std::string(chrome::kChromeUISettingsURL) + |
538 chrome::kResetProfileSettingsSubPage) || | 542 chrome::kResetProfileSettingsSubPage) || |
539 #endif | 543 #endif |
540 (url.spec().compare(url::kAboutBlankURL) == 0)) { | 544 (url.spec().compare(url::kAboutBlankURL) == 0)) { |
541 urls.push_back(url); | 545 urls.push_back(url); |
542 } | |
543 } | 546 } |
544 } | 547 } |
545 return urls; | 548 return urls; |
546 } | 549 } |
547 | 550 |
548 bool StartupBrowserCreator::ProcessCmdLineImpl( | 551 bool StartupBrowserCreator::ProcessCmdLineImpl( |
549 const base::CommandLine& command_line, | 552 const base::CommandLine& command_line, |
550 const base::FilePath& cur_dir, | 553 const base::FilePath& cur_dir, |
551 bool process_startup, | 554 bool process_startup, |
552 Profile* last_used_profile, | 555 Profile* last_used_profile, |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 #if defined(ENABLE_APP_LIST) | 880 #if defined(ENABLE_APP_LIST) |
878 // If we are showing the app list then chrome isn't shown so load the app | 881 // If we are showing the app list then chrome isn't shown so load the app |
879 // list's profile rather than chrome's. | 882 // list's profile rather than chrome's. |
880 if (command_line.HasSwitch(switches::kShowAppList)) | 883 if (command_line.HasSwitch(switches::kShowAppList)) |
881 return AppListService::Get()->GetProfilePath(user_data_dir); | 884 return AppListService::Get()->GetProfilePath(user_data_dir); |
882 #endif | 885 #endif |
883 | 886 |
884 return g_browser_process->profile_manager()->GetLastUsedProfileDir( | 887 return g_browser_process->profile_manager()->GetLastUsedProfileDir( |
885 user_data_dir); | 888 user_data_dir); |
886 } | 889 } |
OLD | NEW |