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/ssl/ssl_blocking_page.h" | 5 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 6 | 6 |
| 7 #include "base/build_time.h" | 7 #include "base/build_time.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
| 11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/process/launch.h" | |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
| 15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 18 #include "base/values.h" | 19 #include "base/values.h" |
| 19 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
| 20 #include "chrome/browser/history/history_service_factory.h" | 21 #include "chrome/browser/history/history_service_factory.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/renderer_preferences_util.h" | 23 #include "chrome/browser/renderer_preferences_util.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 44 #include "ui/base/resource/resource_bundle.h" | 45 #include "ui/base/resource/resource_bundle.h" |
| 45 #include "ui/base/webui/jstemplate_builder.h" | 46 #include "ui/base/webui/jstemplate_builder.h" |
| 46 #include "ui/base/webui/web_ui_util.h" | 47 #include "ui/base/webui/web_ui_util.h" |
| 47 | 48 |
| 48 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 49 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 49 #include "chrome/browser/captive_portal/captive_portal_service.h" | 50 #include "chrome/browser/captive_portal/captive_portal_service.h" |
| 50 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" | 51 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" |
| 51 #endif | 52 #endif |
| 52 | 53 |
| 53 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
| 55 #include "base/base_paths_win.h" | |
| 56 #include "base/path_service.h" | |
| 54 #include "base/win/windows_version.h" | 57 #include "base/win/windows_version.h" |
| 55 #endif | 58 #endif |
| 56 | 59 |
| 60 #if defined(OS_CHROMEOS) | |
| 61 #include "chrome/browser/profiles/profile_manager.h" | |
| 62 #include "chrome/common/url_constants.h" | |
| 63 #endif | |
| 64 | |
| 57 using base::ASCIIToUTF16; | 65 using base::ASCIIToUTF16; |
| 58 using base::TimeTicks; | 66 using base::TimeTicks; |
| 59 using content::InterstitialPage; | 67 using content::InterstitialPage; |
| 60 using content::NavigationController; | 68 using content::NavigationController; |
| 61 using content::NavigationEntry; | 69 using content::NavigationEntry; |
| 62 | 70 |
| 63 namespace { | 71 namespace { |
| 64 | 72 |
| 65 // Constants for the M37 Finch trial. | 73 // Constants for the M37 Finch trial. |
| 66 const char kInterstitialTrialName[] = "SSLInterstitialVersion"; | 74 const char kInterstitialTrialName[] = "SSLInterstitialVersion"; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 else | 217 else |
| 210 RecordSSLBlockingPageEventStats(DONT_PROCEED_AUTHORITY); | 218 RecordSSLBlockingPageEventStats(DONT_PROCEED_AUTHORITY); |
| 211 break; | 219 break; |
| 212 } | 220 } |
| 213 default: { | 221 default: { |
| 214 break; | 222 break; |
| 215 } | 223 } |
| 216 } | 224 } |
| 217 } | 225 } |
| 218 | 226 |
| 227 void LaunchDateAndTimeSettings() { | |
| 228 #if defined(OS_CHROMEOS) | |
| 229 std::string sub_page = std::string(chrome::kSearchSubPage) + "#" + | |
| 230 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME); | |
| 231 chrome::ShowSettingsSubPageForProfile( | |
| 232 ProfileManager::GetActiveUserProfile(), sub_page); | |
| 233 return; | |
| 234 #elif defined(OS_ANDROID) | |
| 235 CommandLine command(base::FilePath("/system/bin/am")); | |
| 236 command.AppendArg("start"); | |
| 237 command.AppendArg( | |
| 238 "'com.android.settings/.Settings$DateTimeSettingsActivity'"); | |
| 239 #elif defined(OS_IOS) | |
| 240 // TODO(palmer) | |
| 241 return; | |
| 242 #elif defined(OS_LINUX) | |
| 243 struct ClockCommand { | |
| 244 const char* pathname; | |
| 245 const char* argument; | |
| 246 }; | |
| 247 static const ClockCommand kClockCommands[] = { | |
| 248 // GNOME | |
| 249 // | |
| 250 // NOTE: On old Ubuntu, naming control panels doesn't work, so it | |
| 251 // opens the overview. This will have to be good enough. | |
| 252 { "/usr/bin/gnome-control-center", "datetime" }, | |
| 253 { "/usr/local/bin/gnome-control-center", "datetime" }, | |
| 254 { "/opt/bin/gnome-control-center", "datetime" }, | |
| 255 // KDE | |
| 256 { "/usr/bin/kcmshell4", "clock" }, | |
| 257 { "/usr/local/bin/kcmshell4", "clock" }, | |
| 258 { "/opt/bin/kcmshell4", "clock" }, | |
| 259 }; | |
| 260 | |
| 261 CommandLine command(base::FilePath("")); | |
| 262 for (size_t i = 0; i < arraysize(kClockCommands); ++i) { | |
| 263 base::FilePath pathname(kClockCommands[i].pathname); | |
| 264 if (base::PathExists(pathname)) { | |
| 265 command.SetProgram(pathname); | |
| 266 command.AppendArg(kClockCommands[i].argument); | |
| 267 break; | |
| 268 } | |
| 269 } | |
| 270 if (command.GetProgram().empty()) { | |
| 271 // Alas, there is nothing we can do. | |
| 272 return; | |
| 273 } | |
| 274 #elif defined(OS_MACOSX) | |
| 275 CommandLine command(base::FilePath("/usr/bin/open")); | |
| 276 command.AppendArg("/System/Library/PreferencePanes/DateAndTime.prefPane"); | |
| 277 #elif defined(OS_WIN) | |
| 278 base::FilePath path; | |
| 279 PathService::Get(base::DIR_SYSTEM, &path); | |
| 280 path = path.Append(std::wstring(L"control.exe")); | |
| 281 CommandLine command(path); | |
| 282 command.AppendArg(std::string("/name")); | |
| 283 command.AppendArg(std::string("Microsoft.DateAndTime")); | |
| 284 #else | |
| 285 return; | |
| 286 #endif | |
| 287 | |
| 288 VLOG(1) << "Running " << command.GetCommandLineString(); | |
|
felt
2014/07/17 22:26:07
was this VLOG for testing or meant to stay?
palmer
2014/07/18 01:23:21
I'll whack it, it isn't necessary.
| |
| 289 base::LaunchOptions options; | |
| 290 options.wait = false; | |
| 291 #if defined(OS_LINUX) | |
| 292 options.allow_new_privs = true; | |
| 293 #endif | |
| 294 base::LaunchProcess(command, options, NULL); | |
| 295 } | |
| 296 | |
| 219 } // namespace | 297 } // namespace |
| 220 | 298 |
| 221 // Note that we always create a navigation entry with SSL errors. | 299 // Note that we always create a navigation entry with SSL errors. |
| 222 // No error happening loading a sub-resource triggers an interstitial so far. | 300 // No error happening loading a sub-resource triggers an interstitial so far. |
| 223 SSLBlockingPage::SSLBlockingPage( | 301 SSLBlockingPage::SSLBlockingPage( |
| 224 content::WebContents* web_contents, | 302 content::WebContents* web_contents, |
| 225 int cert_error, | 303 int cert_error, |
| 226 const net::SSLInfo& ssl_info, | 304 const net::SSLInfo& ssl_info, |
| 227 const GURL& request_url, | 305 const GURL& request_url, |
| 228 bool overridable, | 306 bool overridable, |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 web_contents_->GetController().Reload(true); | 682 web_contents_->GetController().Reload(true); |
| 605 break; | 683 break; |
| 606 } | 684 } |
| 607 case CMD_HELP: { | 685 case CMD_HELP: { |
| 608 content::NavigationController::LoadURLParams help_page_params(GURL( | 686 content::NavigationController::LoadURLParams help_page_params(GURL( |
| 609 "https://support.google.com/chrome/answer/4454607")); | 687 "https://support.google.com/chrome/answer/4454607")); |
| 610 web_contents_->GetController().LoadURLWithParams(help_page_params); | 688 web_contents_->GetController().LoadURLWithParams(help_page_params); |
| 611 break; | 689 break; |
| 612 } | 690 } |
| 613 case CMD_CLOCK: { | 691 case CMD_CLOCK: { |
| 614 content::NavigationController::LoadURLParams help_page_params(GURL( | 692 LaunchDateAndTimeSettings(); |
| 615 "https://support.google.com/chrome/?p=ui_system_clock")); | |
| 616 web_contents_->GetController().LoadURLWithParams(help_page_params); | |
| 617 break; | 693 break; |
| 618 } | 694 } |
| 619 default: { | 695 default: { |
| 620 NOTREACHED(); | 696 NOTREACHED(); |
| 621 } | 697 } |
| 622 } | 698 } |
| 623 } | 699 } |
| 624 | 700 |
| 625 void SSLBlockingPage::OverrideRendererPrefs( | 701 void SSLBlockingPage::OverrideRendererPrefs( |
| 626 content::RendererPreferences* prefs) { | 702 content::RendererPreferences* prefs) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 721 // sure we don't clear the captive portal flag, since the interstitial was | 797 // sure we don't clear the captive portal flag, since the interstitial was |
| 722 // potentially caused by the captive portal. | 798 // potentially caused by the captive portal. |
| 723 captive_portal_detected_ = captive_portal_detected_ || | 799 captive_portal_detected_ = captive_portal_detected_ || |
| 724 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 800 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
| 725 // Also keep track of non-HTTP portals and error cases. | 801 // Also keep track of non-HTTP portals and error cases. |
| 726 captive_portal_no_response_ = captive_portal_no_response_ || | 802 captive_portal_no_response_ = captive_portal_no_response_ || |
| 727 (results->result == captive_portal::RESULT_NO_RESPONSE); | 803 (results->result == captive_portal::RESULT_NO_RESPONSE); |
| 728 } | 804 } |
| 729 #endif | 805 #endif |
| 730 } | 806 } |
| OLD | NEW |