Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: chrome/browser/ssl/ssl_blocking_page.cc

Issue 397713007: Provide an option to launch the date and time preferences. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the build on ChromeOS. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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"
57 #include "base/strings/string16.h"
54 #include "base/win/windows_version.h" 58 #include "base/win/windows_version.h"
55 #endif 59 #endif
56 60
61 #if defined(OS_CHROMEOS)
62 #include "chrome/browser/profiles/profile_manager.h"
63 #include "chrome/browser/ui/chrome_pages.h"
64 #include "chrome/common/url_constants.h"
65 #endif
66
57 using base::ASCIIToUTF16; 67 using base::ASCIIToUTF16;
58 using base::TimeTicks; 68 using base::TimeTicks;
59 using content::InterstitialPage; 69 using content::InterstitialPage;
60 using content::NavigationController; 70 using content::NavigationController;
61 using content::NavigationEntry; 71 using content::NavigationEntry;
62 72
63 namespace { 73 namespace {
64 74
65 // Constants for the M37 Finch trial. 75 // Constants for the M37 Finch trial.
66 const char kInterstitialTrialName[] = "SSLInterstitialVersion"; 76 const char kInterstitialTrialName[] = "SSLInterstitialVersion";
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 else 219 else
210 RecordSSLBlockingPageEventStats(DONT_PROCEED_AUTHORITY); 220 RecordSSLBlockingPageEventStats(DONT_PROCEED_AUTHORITY);
211 break; 221 break;
212 } 222 }
213 default: { 223 default: {
214 break; 224 break;
215 } 225 }
216 } 226 }
217 } 227 }
218 228
229 void LaunchDateAndTimeSettings() {
230 #if defined(OS_CHROMEOS)
231 std::string sub_page = std::string(chrome::kSearchSubPage) + "#" +
232 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME);
233 chrome::ShowSettingsSubPageForProfile(
234 ProfileManager::GetActiveUserProfile(), sub_page);
235 return;
236 #elif defined(OS_ANDROID)
237 CommandLine command(base::FilePath("/system/bin/am"));
238 command.AppendArg("start");
239 command.AppendArg(
240 "'com.android.settings/.Settings$DateTimeSettingsActivity'");
241 #elif defined(OS_IOS)
242 // Apparently, iOS really does not have a way to launch the date and time
243 // settings. Weird. TODO(palmer): Do something more graceful than ignoring
244 // the user's click! crbug.com/394993
245 return;
246 #elif defined(OS_LINUX)
247 struct ClockCommand {
248 const char* pathname;
249 const char* argument;
250 };
251 static const ClockCommand kClockCommands[] = {
252 // GNOME
253 //
254 // NOTE: On old Ubuntu, naming control panels doesn't work, so it
255 // opens the overview. This will have to be good enough.
256 { "/usr/bin/gnome-control-center", "datetime" },
257 { "/usr/local/bin/gnome-control-center", "datetime" },
258 { "/opt/bin/gnome-control-center", "datetime" },
259 // KDE
260 { "/usr/bin/kcmshell4", "clock" },
261 { "/usr/local/bin/kcmshell4", "clock" },
262 { "/opt/bin/kcmshell4", "clock" },
263 };
264
265 CommandLine command(base::FilePath(""));
266 for (size_t i = 0; i < arraysize(kClockCommands); ++i) {
267 base::FilePath pathname(kClockCommands[i].pathname);
268 if (base::PathExists(pathname)) {
269 command.SetProgram(pathname);
270 command.AppendArg(kClockCommands[i].argument);
271 break;
272 }
273 }
274 if (command.GetProgram().empty()) {
275 // Alas, there is nothing we can do.
276 return;
277 }
278 #elif defined(OS_MACOSX)
279 CommandLine command(base::FilePath("/usr/bin/open"));
280 command.AppendArg("/System/Library/PreferencePanes/DateAndTime.prefPane");
281 #elif defined(OS_WIN)
282 base::FilePath path;
283 PathService::Get(base::DIR_SYSTEM, &path);
284 static const base::char16 kControlPanelExe[] = L"control.exe";
285 path = path.Append(base::string16(kControlPanelExe));
286 CommandLine command(path);
287 command.AppendArg(std::string("/name"));
288 command.AppendArg(std::string("Microsoft.DateAndTime"));
289 #else
290 return;
291 #endif
292
293 #if !defined(OS_CHROMEOS)
294 base::LaunchOptions options;
295 options.wait = false;
296 #if defined(OS_LINUX)
297 options.allow_new_privs = true;
298 #endif
299 base::LaunchProcess(command, options, NULL);
300 #endif
301 }
302
219 } // namespace 303 } // namespace
220 304
221 // Note that we always create a navigation entry with SSL errors. 305 // Note that we always create a navigation entry with SSL errors.
222 // No error happening loading a sub-resource triggers an interstitial so far. 306 // No error happening loading a sub-resource triggers an interstitial so far.
223 SSLBlockingPage::SSLBlockingPage( 307 SSLBlockingPage::SSLBlockingPage(
224 content::WebContents* web_contents, 308 content::WebContents* web_contents,
225 int cert_error, 309 int cert_error,
226 const net::SSLInfo& ssl_info, 310 const net::SSLInfo& ssl_info,
227 const GURL& request_url, 311 const GURL& request_url,
228 bool overridable, 312 bool overridable,
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 web_contents_->GetController().Reload(true); 688 web_contents_->GetController().Reload(true);
605 break; 689 break;
606 } 690 }
607 case CMD_HELP: { 691 case CMD_HELP: {
608 content::NavigationController::LoadURLParams help_page_params(GURL( 692 content::NavigationController::LoadURLParams help_page_params(GURL(
609 "https://support.google.com/chrome/answer/4454607")); 693 "https://support.google.com/chrome/answer/4454607"));
610 web_contents_->GetController().LoadURLWithParams(help_page_params); 694 web_contents_->GetController().LoadURLWithParams(help_page_params);
611 break; 695 break;
612 } 696 }
613 case CMD_CLOCK: { 697 case CMD_CLOCK: {
614 content::NavigationController::LoadURLParams help_page_params(GURL( 698 LaunchDateAndTimeSettings();
615 "https://support.google.com/chrome/?p=ui_system_clock"));
616 web_contents_->GetController().LoadURLWithParams(help_page_params);
617 break; 699 break;
618 } 700 }
619 default: { 701 default: {
620 NOTREACHED(); 702 NOTREACHED();
621 } 703 }
622 } 704 }
623 } 705 }
624 706
625 void SSLBlockingPage::OverrideRendererPrefs( 707 void SSLBlockingPage::OverrideRendererPrefs(
626 content::RendererPreferences* prefs) { 708 content::RendererPreferences* prefs) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 // sure we don't clear the captive portal flag, since the interstitial was 803 // sure we don't clear the captive portal flag, since the interstitial was
722 // potentially caused by the captive portal. 804 // potentially caused by the captive portal.
723 captive_portal_detected_ = captive_portal_detected_ || 805 captive_portal_detected_ = captive_portal_detected_ ||
724 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); 806 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL);
725 // Also keep track of non-HTTP portals and error cases. 807 // Also keep track of non-HTTP portals and error cases.
726 captive_portal_no_response_ = captive_portal_no_response_ || 808 captive_portal_no_response_ = captive_portal_no_response_ ||
727 (results->result == captive_portal::RESULT_NO_RESPONSE); 809 (results->result == captive_portal::RESULT_NO_RESPONSE);
728 } 810 }
729 #endif 811 #endif
730 } 812 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698