| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/webui/settings/md_settings_ui.h" | 5 #include "chrome/browser/ui/webui/settings/md_settings_ui.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/webui/settings/appearance_handler.h" | 13 #include "chrome/browser/ui/webui/settings/appearance_handler.h" |
| 14 #include "chrome/browser/ui/webui/settings/downloads_handler.h" | 14 #include "chrome/browser/ui/webui/settings/downloads_handler.h" |
| 15 #include "chrome/browser/ui/webui/settings/font_handler.h" | 15 #include "chrome/browser/ui/webui/settings/font_handler.h" |
| 16 #include "chrome/browser/ui/webui/settings/languages_handler.h" | 16 #include "chrome/browser/ui/webui/settings/languages_handler.h" |
| 17 #include "chrome/browser/ui/webui/settings/md_settings_localized_strings_provide
r.h" | 17 #include "chrome/browser/ui/webui/settings/md_settings_localized_strings_provide
r.h" |
| 18 #include "chrome/browser/ui/webui/settings/people_handler.h" | 18 #include "chrome/browser/ui/webui/settings/people_handler.h" |
| 19 #include "chrome/browser/ui/webui/settings/reset_settings_handler.h" | 19 #include "chrome/browser/ui/webui/settings/reset_settings_handler.h" |
| 20 #include "chrome/browser/ui/webui/settings/search_engines_handler.h" | 20 #include "chrome/browser/ui/webui/settings/search_engines_handler.h" |
| 21 #include "chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.
h" | 21 #include "chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.
h" |
| 22 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" |
| 22 #include "chrome/browser/ui/webui/settings/settings_startup_pages_handler.h" | 23 #include "chrome/browser/ui/webui/settings/settings_startup_pages_handler.h" |
| 23 #include "chrome/browser/ui/webui/settings/site_settings_handler.h" | 24 #include "chrome/browser/ui/webui/settings/site_settings_handler.h" |
| 24 #include "chrome/browser/ui/webui/settings/system_handler.h" | 25 #include "chrome/browser/ui/webui/settings/system_handler.h" |
| 25 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
| 26 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| 27 #include "content/public/browser/web_ui.h" | 28 #include "content/public/browser/web_ui.h" |
| 28 #include "content/public/browser/web_ui_data_source.h" | 29 #include "content/public/browser/web_ui_data_source.h" |
| 29 #include "grit/settings_resources.h" | 30 #include "grit/settings_resources.h" |
| 30 #include "grit/settings_resources_map.h" | 31 #include "grit/settings_resources_map.h" |
| 31 | 32 |
| 32 #if defined(OS_CHROMEOS) | 33 #if defined(OS_CHROMEOS) |
| 33 #include "chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h" | 34 #include "chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h" |
| 34 #include "chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h" | 35 #include "chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h" |
| 35 #include "chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler
.h" | 36 #include "chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler
.h" |
| 36 #else // !defined(OS_CHROMEOS) | 37 #else // !defined(OS_CHROMEOS) |
| 37 #include "chrome/browser/ui/webui/settings/settings_default_browser_handler.h" | 38 #include "chrome/browser/ui/webui/settings/settings_default_browser_handler.h" |
| 38 #include "chrome/browser/ui/webui/settings/settings_manage_profile_handler.h" | 39 #include "chrome/browser/ui/webui/settings/settings_manage_profile_handler.h" |
| 39 #endif // defined(OS_CHROMEOS) | 40 #endif // defined(OS_CHROMEOS) |
| 40 | 41 |
| 41 #if defined(USE_NSS_CERTS) | 42 #if defined(USE_NSS_CERTS) |
| 42 #include "chrome/browser/ui/webui/settings/certificates_handler.h" | 43 #include "chrome/browser/ui/webui/settings/certificates_handler.h" |
| 43 #endif // defined(USE_NSS_CERTS) | 44 #endif // defined(USE_NSS_CERTS) |
| 44 | 45 |
| 45 namespace settings { | 46 namespace settings { |
| 46 | 47 |
| 47 SettingsPageUIHandler::SettingsPageUIHandler() { | |
| 48 } | |
| 49 | |
| 50 SettingsPageUIHandler::~SettingsPageUIHandler() { | |
| 51 } | |
| 52 | |
| 53 void SettingsPageUIHandler::ResolveJavascriptCallback( | |
| 54 const base::Value& callback_id, | |
| 55 const base::Value& response) { | |
| 56 // cr.webUIResponse is a global JS function exposed from cr.js. | |
| 57 web_ui()->CallJavascriptFunction( | |
| 58 "cr.webUIResponse", callback_id, | |
| 59 base::FundamentalValue(true), response); | |
| 60 } | |
| 61 | |
| 62 void SettingsPageUIHandler::RejectJavascriptCallback( | |
| 63 const base::Value& callback_id, | |
| 64 const base::Value& response) { | |
| 65 // cr.webUIResponse is a global JS function exposed from cr.js. | |
| 66 web_ui()->CallJavascriptFunction( | |
| 67 "cr.webUIResponse", callback_id, | |
| 68 base::FundamentalValue(false), response); | |
| 69 } | |
| 70 | |
| 71 MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) | 48 MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) |
| 72 : content::WebUIController(web_ui), | 49 : content::WebUIController(web_ui), |
| 73 WebContentsObserver(web_ui->GetWebContents()) { | 50 WebContentsObserver(web_ui->GetWebContents()) { |
| 74 Profile* profile = Profile::FromWebUI(web_ui); | 51 Profile* profile = Profile::FromWebUI(web_ui); |
| 75 AddSettingsPageUIHandler(new AppearanceHandler(web_ui)); | 52 AddSettingsPageUIHandler(new AppearanceHandler(web_ui)); |
| 76 | 53 |
| 77 #if defined(USE_NSS_CERTS) | 54 #if defined(USE_NSS_CERTS) |
| 78 AddSettingsPageUIHandler(new CertificatesHandler(false)); | 55 AddSettingsPageUIHandler(new CertificatesHandler(false)); |
| 79 #endif // defined(USE_NSS_CERTS) | 56 #endif // defined(USE_NSS_CERTS) |
| 80 | 57 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 UMA_HISTOGRAM_TIMES("Settings.LoadDocumentTime.MD", | 127 UMA_HISTOGRAM_TIMES("Settings.LoadDocumentTime.MD", |
| 151 base::Time::Now() - load_start_time_); | 128 base::Time::Now() - load_start_time_); |
| 152 } | 129 } |
| 153 | 130 |
| 154 void MdSettingsUI::DocumentOnLoadCompletedInMainFrame() { | 131 void MdSettingsUI::DocumentOnLoadCompletedInMainFrame() { |
| 155 UMA_HISTOGRAM_TIMES("Settings.LoadCompletedTime.MD", | 132 UMA_HISTOGRAM_TIMES("Settings.LoadCompletedTime.MD", |
| 156 base::Time::Now() - load_start_time_); | 133 base::Time::Now() - load_start_time_); |
| 157 } | 134 } |
| 158 | 135 |
| 159 } // namespace settings | 136 } // namespace settings |
| OLD | NEW |