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

Side by Side Diff: chrome/browser/ui/webui/settings/system_handler.cc

Issue 2971163002: Add local protection setting to chrome://settings/system
Patch Set: linux-only Created 3 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
« no previous file with comments | « chrome/browser/ui/webui/settings/system_handler.h ('k') | 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 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 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h"
9 #include "base/metrics/user_metrics.h" 10 #include "base/metrics/user_metrics.h"
10 #include "base/metrics/user_metrics_action.h" 11 #include "base/metrics/user_metrics_action.h"
12 #include "build/build_config.h"
11 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/gpu/gpu_mode_manager.h" 14 #include "chrome/browser/gpu/gpu_mode_manager.h"
13 #include "chrome/browser/ui/webui/settings_utils.h" 15 #include "chrome/browser/ui/webui/settings_utils.h"
16 #include "chrome/common/chrome_switches.h"
14 #include "content/public/browser/web_ui.h" 17 #include "content/public/browser/web_ui.h"
15 #include "content/public/browser/web_ui_data_source.h" 18 #include "content/public/browser/web_ui_data_source.h"
16 19
20 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
21 #include "base/files/file_path.h"
22 #include "chrome/common/chrome_paths_internal.h"
23 #include "components/os_crypt/key_storage_util_linux.h"
24 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS)
25
17 namespace settings { 26 namespace settings {
18 27
19 SystemHandler::SystemHandler() {} 28 SystemHandler::SystemHandler() {}
20 29
21 SystemHandler::~SystemHandler() {} 30 SystemHandler::~SystemHandler() {}
22 31
23 // static 32 // static
24 void SystemHandler::AddLoadTimeData(content::WebUIDataSource* data_source) { 33 void SystemHandler::AddLoadTimeData(content::WebUIDataSource* data_source) {
25 data_source->AddBoolean("hardwareAccelerationEnabledAtStartup", 34 data_source->AddBoolean("hardwareAccelerationEnabledAtStartup",
26 g_browser_process->gpu_mode_manager()->initial_gpu_mode_pref()); 35 g_browser_process->gpu_mode_manager()->initial_gpu_mode_pref());
36
37 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
38 data_source->AddBoolean("hideProtectionSetting",
39 !base::CommandLine::ForCurrentProcess()->HasSwitch(
40 switches::kEnableEncryptionSelection));
41 base::FilePath user_data_dir;
42 chrome::GetDefaultUserDataDirectory(&user_data_dir);
43 data_source->AddBoolean("protectionSetting",
44 !os_crypt::GetBackendUse(user_data_dir));
45 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS)
27 } 46 }
28 47
29 void SystemHandler::RegisterMessages() { 48 void SystemHandler::RegisterMessages() {
30 web_ui()->RegisterMessageCallback( 49 web_ui()->RegisterMessageCallback(
31 "showProxySettings", base::Bind(&SystemHandler::HandleShowProxySettings, 50 "showProxySettings", base::Bind(&SystemHandler::HandleShowProxySettings,
32 base::Unretained(this))); 51 base::Unretained(this)));
52 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
53 web_ui()->RegisterMessageCallback(
54 "updateProtectionSetting",
55 base::Bind(&SystemHandler::HandleUpdateProtectionSetting,
56 base::Unretained(this)));
57 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS)
33 } 58 }
34 59
35 void SystemHandler::HandleShowProxySettings(const base::ListValue* /*args*/) { 60 void SystemHandler::HandleShowProxySettings(const base::ListValue* /*args*/) {
36 base::RecordAction(base::UserMetricsAction("Options_ShowProxySettings")); 61 base::RecordAction(base::UserMetricsAction("Options_ShowProxySettings"));
37 settings_utils::ShowNetworkProxySettings(web_ui()->GetWebContents()); 62 settings_utils::ShowNetworkProxySettings(web_ui()->GetWebContents());
38 } 63 }
39 64
65 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
66 void SystemHandler::HandleUpdateProtectionSetting(const base::ListValue* args) {
67 bool disableEncryption = args->GetList()[0].GetBool();
68 base::FilePath user_data_dir;
69 chrome::GetDefaultUserDataDirectory(&user_data_dir);
70 os_crypt::WriteBackendUse(user_data_dir, !disableEncryption);
71 }
72 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS)
73
40 } // namespace settings 74 } // namespace settings
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/system_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698