Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/ui/webui/options/browser_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/browser_options_handler.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 562 | 562 |
| 563 values->SetString("username", username); | 563 values->SetString("username", username); |
| 564 #endif | 564 #endif |
| 565 // Pass along sync status early so it will be available during page init. | 565 // Pass along sync status early so it will be available during page init. |
| 566 values->Set("syncData", GetSyncStateDictionary().release()); | 566 values->Set("syncData", GetSyncStateDictionary().release()); |
| 567 | 567 |
| 568 values->SetString("privacyLearnMoreURL", chrome::kPrivacyLearnMoreURL); | 568 values->SetString("privacyLearnMoreURL", chrome::kPrivacyLearnMoreURL); |
| 569 | 569 |
| 570 values->SetString("doNotTrackLearnMoreURL", chrome::kDoNotTrackLearnMoreURL); | 570 values->SetString("doNotTrackLearnMoreURL", chrome::kDoNotTrackLearnMoreURL); |
| 571 | 571 |
| 572 #if !defined(OS_CHROMEOS) | |
| 573 values->SetBoolean( | 572 values->SetBoolean( |
| 574 "metricsReportingEnabledAtStart", | 573 "metricsReportingEnabledAtStart", |
| 575 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()); | 574 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()); |
| 576 #endif | |
| 577 | 575 |
| 578 #if defined(OS_CHROMEOS) | 576 #if defined(OS_CHROMEOS) |
| 579 // TODO(pastarmovj): replace this with a call to the CrosSettings list | 577 // TODO(pastarmovj): replace this with a call to the CrosSettings list |
| 580 // handling functionality to come. | 578 // handling functionality to come. |
| 581 values->Set("timezoneList", chromeos::system::GetTimezoneList().release()); | 579 values->Set("timezoneList", chromeos::system::GetTimezoneList().release()); |
| 582 | 580 |
| 583 values->SetString("accessibilityLearnMoreURL", | 581 values->SetString("accessibilityLearnMoreURL", |
| 584 chrome::kChromeAccessibilityHelpURL); | 582 chrome::kChromeAccessibilityHelpURL); |
| 585 | 583 |
| 586 std::string settings_url = std::string("chrome-extension://") + | 584 std::string settings_url = std::string("chrome-extension://") + |
| (...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2140 extension = extensions::GetExtensionOverridingProxy( | 2138 extension = extensions::GetExtensionOverridingProxy( |
| 2141 Profile::FromWebUI(web_ui())); | 2139 Profile::FromWebUI(web_ui())); |
| 2142 AppendExtensionData("proxy", extension, &extension_controlled); | 2140 AppendExtensionData("proxy", extension, &extension_controlled); |
| 2143 | 2141 |
| 2144 web_ui()->CallJavascriptFunction("BrowserOptions.toggleExtensionIndicators", | 2142 web_ui()->CallJavascriptFunction("BrowserOptions.toggleExtensionIndicators", |
| 2145 extension_controlled); | 2143 extension_controlled); |
| 2146 #endif // defined(OS_WIN) | 2144 #endif // defined(OS_WIN) |
| 2147 } | 2145 } |
| 2148 | 2146 |
| 2149 void BrowserOptionsHandler::SetupMetricsReportingCheckbox() { | 2147 void BrowserOptionsHandler::SetupMetricsReportingCheckbox() { |
| 2150 // This function does not work for ChromeOS and non-official builds. | 2148 // This function works for official builds. |
|
Alexei Svitkine (slow)
2015/10/16 21:27:16
This is a weird comment. Please give some context
gayane -on leave until 09-2017
2015/10/19 21:32:39
Done.
| |
| 2151 #if !defined(OS_CHROMEOS) && defined(GOOGLE_CHROME_BUILD) | 2149 #if defined(GOOGLE_CHROME_BUILD) |
| 2152 bool checked = | 2150 bool checked = |
| 2153 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); | 2151 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); |
| 2154 bool disabled = !IsMetricsReportingUserChangable(); | 2152 bool policy_managed = IsMetricsReportingPolicyManaged(); |
| 2155 | 2153 bool owner_managed = false; |
| 2156 SetMetricsReportingCheckbox(checked, disabled); | 2154 #if defined(OS_CHROMEOS) |
| 2157 #endif | 2155 owner_managed = IsMetricsReportingOwnerManaged(); |
| 2156 #endif // defined(OS_CHROMEOS) | |
| 2157 SetMetricsReportingCheckbox(checked, policy_managed, owner_managed); | |
| 2158 #endif // defined(GOOGLE_CHROME_BUILD) | |
| 2158 } | 2159 } |
| 2159 | 2160 |
| 2160 void BrowserOptionsHandler::HandleMetricsReportingChange( | 2161 void BrowserOptionsHandler::HandleMetricsReportingChange( |
| 2161 const base::ListValue* args) { | 2162 const base::ListValue* args) { |
| 2162 bool enable; | 2163 bool enable; |
| 2163 if (!args->GetBoolean(0, &enable)) | 2164 if (!args->GetBoolean(0, &enable)) |
| 2164 return; | 2165 return; |
| 2166 if (IsMetricsReportingOwnerManaged() || IsMetricsReportingPolicyManaged()) { | |
| 2167 MetricsReportingChangeCallback( | |
| 2168 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()); | |
|
Alexei Svitkine (slow)
2015/10/16 21:27:16
Nit: Indent 2 more - or just use git cl format.
gayane -on leave until 09-2017
2015/10/19 21:32:39
Done.
| |
| 2169 return; | |
| 2170 } | |
| 2165 | 2171 |
| 2166 InitiateMetricsReportingChange( | 2172 InitiateMetricsReportingChange( |
| 2167 enable, | 2173 enable, |
| 2168 base::Bind(&BrowserOptionsHandler::MetricsReportingChangeCallback, | 2174 base::Bind(&BrowserOptionsHandler::MetricsReportingChangeCallback, |
| 2169 base::Unretained(this))); | 2175 base::Unretained(this))); |
| 2170 } | 2176 } |
| 2171 | 2177 |
| 2172 void BrowserOptionsHandler::MetricsReportingChangeCallback(bool enabled) { | 2178 void BrowserOptionsHandler::MetricsReportingChangeCallback(bool enabled) { |
| 2173 SetMetricsReportingCheckbox(enabled, !IsMetricsReportingUserChangable()); | 2179 SetMetricsReportingCheckbox(enabled, IsMetricsReportingPolicyManaged(), |
| 2180 IsMetricsReportingOwnerManaged()); | |
| 2174 } | 2181 } |
| 2175 | 2182 |
| 2176 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked, | 2183 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked, |
| 2177 bool disabled) { | 2184 bool policy_managed, |
| 2185 bool owner_managed) { | |
| 2178 web_ui()->CallJavascriptFunction( | 2186 web_ui()->CallJavascriptFunction( |
| 2179 "BrowserOptions.setMetricsReportingCheckboxState", | 2187 "BrowserOptions.setMetricsReportingCheckboxState", |
| 2180 base::FundamentalValue(checked), | 2188 base::FundamentalValue(checked), base::FundamentalValue(policy_managed), |
| 2181 base::FundamentalValue(disabled)); | 2189 base::FundamentalValue(owner_managed)); |
| 2182 } | 2190 } |
| 2183 | 2191 |
| 2184 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, | 2192 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, |
| 2185 const policy::PolicyMap& previous, | 2193 const policy::PolicyMap& previous, |
| 2186 const policy::PolicyMap& current) { | 2194 const policy::PolicyMap& current) { |
| 2187 std::set<std::string> different_keys; | 2195 std::set<std::string> different_keys; |
| 2188 current.GetDifferingKeys(previous, &different_keys); | 2196 current.GetDifferingKeys(previous, &different_keys); |
| 2189 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) | 2197 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) |
| 2190 SetupMetricsReportingCheckbox(); | 2198 SetupMetricsReportingCheckbox(); |
| 2191 } | 2199 } |
| 2192 | 2200 |
| 2201 bool BrowserOptionsHandler::IsMetricsReportingOwnerManaged() { | |
| 2202 return !chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())); | |
| 2203 } | |
| 2204 | |
| 2193 } // namespace options | 2205 } // namespace options |
| OLD | NEW |