| 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 | |
| 11 #include "base/bind.h" | 7 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 13 #include "base/metrics/user_metrics.h" | 9 #include "base/metrics/user_metrics.h" |
| 14 #include "base/metrics/user_metrics_action.h" | 10 #include "base/metrics/user_metrics_action.h" |
| 15 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/gpu/gpu_mode_manager.h" | 12 #include "chrome/browser/gpu/gpu_mode_manager.h" |
| 17 #include "chrome/browser/lifetime/application_lifetime.h" | 13 #include "chrome/browser/lifetime/application_lifetime.h" |
| 18 #include "chrome/browser/ui/webui/settings_utils.h" | 14 #include "chrome/browser/ui/webui/settings_utils.h" |
| 19 #include "content/public/browser/web_ui.h" | 15 #include "content/public/browser/web_ui.h" |
| 20 #include "content/public/browser/web_ui_data_source.h" | 16 #include "content/public/browser/web_ui_data_source.h" |
| 21 | 17 |
| 22 #if defined(OS_WIN) | |
| 23 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | |
| 24 #include "chrome/common/chrome_constants.h" | |
| 25 #endif | |
| 26 | |
| 27 namespace settings { | 18 namespace settings { |
| 28 | 19 |
| 29 SystemHandler::SystemHandler() {} | 20 SystemHandler::SystemHandler() {} |
| 30 | 21 |
| 31 SystemHandler::~SystemHandler() {} | 22 SystemHandler::~SystemHandler() {} |
| 32 | 23 |
| 33 // static | 24 // static |
| 34 void SystemHandler::AddLoadTimeData(content::WebUIDataSource* data_source) { | 25 void SystemHandler::AddLoadTimeData(content::WebUIDataSource* data_source) { |
| 35 data_source->AddBoolean("hardwareAccelerationEnabledAtStartup", | 26 data_source->AddBoolean("hardwareAccelerationEnabledAtStartup", |
| 36 g_browser_process->gpu_mode_manager()->initial_gpu_mode_pref()); | 27 g_browser_process->gpu_mode_manager()->initial_gpu_mode_pref()); |
| 37 } | 28 } |
| 38 | 29 |
| 39 void SystemHandler::RegisterMessages() { | 30 void SystemHandler::RegisterMessages() { |
| 40 web_ui()->RegisterMessageCallback("changeProxySettings", | 31 web_ui()->RegisterMessageCallback("changeProxySettings", |
| 41 base::Bind(&SystemHandler::HandleChangeProxySettings, | 32 base::Bind(&SystemHandler::HandleChangeProxySettings, |
| 42 base::Unretained(this))); | 33 base::Unretained(this))); |
| 43 web_ui()->RegisterMessageCallback("restartBrowser", | 34 web_ui()->RegisterMessageCallback("restartBrowser", |
| 44 base::Bind(&SystemHandler::HandleRestartBrowser, | 35 base::Bind(&SystemHandler::HandleRestartBrowser, |
| 45 base::Unretained(this))); | 36 base::Unretained(this))); |
| 46 } | 37 } |
| 47 | 38 |
| 48 void SystemHandler::HandleChangeProxySettings(const base::ListValue* /*args*/) { | 39 void SystemHandler::HandleChangeProxySettings(const base::ListValue* /*args*/) { |
| 49 base::RecordAction(base::UserMetricsAction("Options_ShowProxySettings")); | 40 base::RecordAction(base::UserMetricsAction("Options_ShowProxySettings")); |
| 50 settings_utils::ShowNetworkProxySettings(web_ui()->GetWebContents()); | 41 settings_utils::ShowNetworkProxySettings(web_ui()->GetWebContents()); |
| 51 } | 42 } |
| 52 | 43 |
| 53 void SystemHandler::HandleRestartBrowser(const base::ListValue* /*args*/) { | 44 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 } | |
| 69 #endif | |
| 70 | |
| 71 chrome::AttemptRestart(); | 45 chrome::AttemptRestart(); |
| 72 } | 46 } |
| 73 | 47 |
| 74 } // namespace settings | 48 } // namespace settings |
| OLD | NEW |