| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/system_handler.h" | 5 #include "chrome/browser/ui/webui/settings/system_handler.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) |
| 8 #include <windows.h> |
| 9 #endif |
| 10 |
| 7 #include "base/bind.h" | 11 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 9 #include "base/metrics/user_metrics.h" | 13 #include "base/metrics/user_metrics.h" |
| 10 #include "base/metrics/user_metrics_action.h" | 14 #include "base/metrics/user_metrics_action.h" |
| 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/gpu/gpu_mode_manager.h" |
| 17 #include "chrome/browser/lifetime/application_lifetime.h" |
| 18 #include "chrome/browser/ui/webui/settings_utils.h" |
| 11 #include "content/public/browser/web_ui.h" | 19 #include "content/public/browser/web_ui.h" |
| 20 #include "content/public/browser/web_ui_data_source.h" |
| 12 | 21 |
| 13 #if !defined(OS_CHROMEOS) | 22 #if defined(OS_WIN) |
| 14 #include "chrome/browser/ui/webui/settings_utils.h" | 23 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| 24 #include "chrome/common/chrome_constants.h" |
| 15 #endif | 25 #endif |
| 16 | 26 |
| 17 namespace settings { | 27 namespace settings { |
| 18 | 28 |
| 19 SystemHandler::SystemHandler() {} | 29 SystemHandler::SystemHandler() {} |
| 20 | 30 |
| 21 SystemHandler::~SystemHandler() {} | 31 SystemHandler::~SystemHandler() {} |
| 22 | 32 |
| 33 // static |
| 34 void SystemHandler::AddLoadTimeData(content::WebUIDataSource* data_source) { |
| 35 data_source->AddBoolean("hardwareAccelerationEnabledAtStartup", |
| 36 g_browser_process->gpu_mode_manager()->initial_gpu_mode_pref()); |
| 37 } |
| 38 |
| 23 void SystemHandler::RegisterMessages() { | 39 void SystemHandler::RegisterMessages() { |
| 24 web_ui()->RegisterMessageCallback("changeProxySettings", | 40 web_ui()->RegisterMessageCallback("changeProxySettings", |
| 25 base::Bind(&SystemHandler::HandleChangeProxySettings, | 41 base::Bind(&SystemHandler::HandleChangeProxySettings, |
| 26 base::Unretained(this))); | 42 base::Unretained(this))); |
| 43 web_ui()->RegisterMessageCallback("restartBrowser", |
| 44 base::Bind(&SystemHandler::HandleRestartBrowser, |
| 45 base::Unretained(this))); |
| 27 } | 46 } |
| 28 | 47 |
| 29 void SystemHandler::HandleChangeProxySettings(const base::ListValue* /*args*/) { | 48 void SystemHandler::HandleChangeProxySettings(const base::ListValue* /*args*/) { |
| 30 base::RecordAction(base::UserMetricsAction("Options_ShowProxySettings")); | 49 base::RecordAction(base::UserMetricsAction("Options_ShowProxySettings")); |
| 31 #if defined(OS_CHROMEOS) | |
| 32 NOTREACHED(); | |
| 33 #else | |
| 34 settings_utils::ShowNetworkProxySettings(web_ui()->GetWebContents()); | 50 settings_utils::ShowNetworkProxySettings(web_ui()->GetWebContents()); |
| 51 } |
| 52 |
| 53 void SystemHandler::HandleRestartBrowser(const base::ListValue* /*args*/) { |
| 54 #if defined(OS_WIN) |
| 55 // On Windows Breakpad will upload crash reports if the breakpad pipe name |
| 56 // environment variable is defined. So we undefine this environment variable |
| 57 // before restarting, as the restarted processes will inherit their |
| 58 // environment variables from ours, thus suppressing crash uploads. |
| 59 if (!ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()) { |
| 60 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
| 61 if (exe_module) { |
| 62 typedef void (__cdecl *ClearBreakpadPipeEnvVar)(); |
| 63 ClearBreakpadPipeEnvVar clear = reinterpret_cast<ClearBreakpadPipeEnvVar>( |
| 64 GetProcAddress(exe_module, "ClearBreakpadPipeEnvironmentVariable")); |
| 65 if (clear) |
| 66 clear(); |
| 67 } |
| 68 } |
| 35 #endif | 69 #endif |
| 70 |
| 71 chrome::AttemptRestart(); |
| 36 } | 72 } |
| 37 | 73 |
| 38 } // namespace settings | 74 } // namespace settings |
| OLD | NEW |