Chromium Code Reviews| 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 12 matching lines...) Expand all Loading... | |
| 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/string_util.h" |
| 33 #include "base/strings/stringprintf.h" | |
|
Dan Beam
2016/09/16 19:48:29
not needed any more
alito
2016/09/16 20:16:15
Done.
| |
| 33 #include "base/strings/utf_string_conversions.h" | 34 #include "base/strings/utf_string_conversions.h" |
| 34 #include "base/threading/thread_restrictions.h" | 35 #include "base/threading/thread_restrictions.h" |
| 35 #include "base/trace_event/trace_event.h" | 36 #include "base/trace_event/trace_event.h" |
| 36 #include "build/build_config.h" | 37 #include "build/build_config.h" |
| 37 #include "chrome/browser/app_mode/app_mode_utils.h" | 38 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 38 #include "chrome/browser/browser_process.h" | 39 #include "chrome/browser/browser_process.h" |
| 39 #include "chrome/browser/chrome_notification_types.h" | 40 #include "chrome/browser/chrome_notification_types.h" |
| 40 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 41 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 41 #include "chrome/browser/extensions/startup_helper.h" | 42 #include "chrome/browser/extensions/startup_helper.h" |
| 42 #include "chrome/browser/extensions/unpacked_installer.h" | 43 #include "chrome/browser/extensions/unpacked_installer.h" |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 // URL, otherwise we will look in the current directory for a file named | 515 // URL, otherwise we will look in the current directory for a file named |
| 515 // 'about' if the browser was started with a about:foo argument. | 516 // 'about' if the browser was started with a about:foo argument. |
| 516 if (!url.is_valid()) { | 517 if (!url.is_valid()) { |
| 517 base::ThreadRestrictions::ScopedAllowIO allow_io; | 518 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 518 url = url_formatter::FixupRelativeFile(cur_dir, param); | 519 url = url_formatter::FixupRelativeFile(cur_dir, param); |
| 519 } | 520 } |
| 520 // Exclude dangerous schemes. | 521 // Exclude dangerous schemes. |
| 521 if (!url.is_valid()) | 522 if (!url.is_valid()) |
| 522 continue; | 523 continue; |
| 523 | 524 |
| 525 const GURL settings_url = GURL(chrome::kChromeUISettingsURL); | |
| 526 bool url_points_to_an_approved_settings_page = false; | |
| 527 #if defined(OS_CHROMEOS) | |
| 528 // In ChromeOS, allow any settings page to be specified on the command | |
| 529 // line. See ExistingUserController::OnLoginSuccess. | |
| 530 url_points_to_an_approved_settings_page = | |
| 531 url.GetOrigin() == settings_url.GetOrigin(); | |
|
Dan Beam
2016/09/16 19:48:29
this also looks much better! yay!
alito
2016/09/16 20:16:16
Always a good feeling.
| |
| 532 #else | |
| 533 // Exposed for external cleaners to offer a settings reset to the | |
| 534 // user. The allowed URLs must match exactly. | |
| 535 const GURL reset_settings_url = | |
| 536 settings_url.Resolve(chrome::kResetProfileSettingsSubPage); | |
| 537 url_points_to_an_approved_settings_page = url == reset_settings_url; | |
| 538 #if defined(OS_WIN) | |
| 539 // On Windows, also allow a hash for the Chrome Cleanup Tool. | |
| 540 url_points_to_an_approved_settings_page = | |
| 541 url_points_to_an_approved_settings_page || | |
| 542 url == reset_settings_url.Resolve("#cct"); | |
| 543 #endif // defined(OS_WIN) | |
| 544 #endif // defined(OS_CHROMEOS) | |
| 545 | |
| 524 ChildProcessSecurityPolicy* policy = | 546 ChildProcessSecurityPolicy* policy = |
| 525 ChildProcessSecurityPolicy::GetInstance(); | 547 ChildProcessSecurityPolicy::GetInstance(); |
| 526 if (policy->IsWebSafeScheme(url.scheme()) || | 548 if (policy->IsWebSafeScheme(url.scheme()) || |
| 527 url.SchemeIs(url::kFileScheme) || | 549 url.SchemeIs(url::kFileScheme) || |
| 528 #if defined(OS_CHROMEOS) | 550 url_points_to_an_approved_settings_page || |
| 529 // In ChromeOS, allow any settings page to be specified on the command | |
| 530 // line. See ExistingUserController::OnLoginSuccess. | |
| 531 base::StartsWith(url.spec(), chrome::kChromeUISettingsURL, | |
| 532 base::CompareCase::SENSITIVE) || | |
| 533 #else | |
| 534 // Exposed for external cleaners to offer a settings reset to the | |
| 535 // user. So the URL must match exactly, without any param or prefix. | |
| 536 (url.spec() == | |
| 537 std::string(chrome::kChromeUISettingsURL) + | |
| 538 chrome::kResetProfileSettingsSubPage) || | |
| 539 #endif | |
| 540 (url.spec().compare(url::kAboutBlankURL) == 0)) { | 551 (url.spec().compare(url::kAboutBlankURL) == 0)) { |
| 541 urls.push_back(url); | 552 urls.push_back(url); |
| 542 } | 553 } |
| 543 } | 554 } |
| 544 return urls; | 555 return urls; |
| 545 } | 556 } |
| 546 | 557 |
| 547 bool StartupBrowserCreator::ProcessCmdLineImpl( | 558 bool StartupBrowserCreator::ProcessCmdLineImpl( |
| 548 const base::CommandLine& command_line, | 559 const base::CommandLine& command_line, |
| 549 const base::FilePath& cur_dir, | 560 const base::FilePath& cur_dir, |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 934 if (!entry->IsSigninRequired()) { | 945 if (!entry->IsSigninRequired()) { |
| 935 Profile* profile = profile_manager->GetProfile(entry->GetPath()); | 946 Profile* profile = profile_manager->GetProfile(entry->GetPath()); |
| 936 if (profile) | 947 if (profile) |
| 937 return profile; | 948 return profile; |
| 938 } | 949 } |
| 939 } | 950 } |
| 940 | 951 |
| 941 return nullptr; | 952 return nullptr; |
| 942 } | 953 } |
| 943 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 954 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
| OLD | NEW |