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 // As the Metrics and crash reporting checkbox only exists for official builds |
2151 #if !defined(OS_CHROMEOS) && defined(GOOGLE_CHROME_BUILD) | 2149 // it doesn't need setup for non-official builds. |
Alexei Svitkine (slow)
2015/10/29 17:04:14
Nit: "setup" -> "to be set up"
gayane -on leave until 09-2017
2015/11/02 19:23:52
Done.
| |
2150 #if defined(GOOGLE_CHROME_BUILD) | |
2152 bool checked = | 2151 bool checked = |
2153 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); | 2152 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); |
2154 bool disabled = !IsMetricsReportingUserChangable(); | 2153 bool policy_managed = IsMetricsReportingPolicyManaged(); |
2155 | 2154 bool owner_managed = false; |
2156 SetMetricsReportingCheckbox(checked, disabled); | 2155 #if defined(OS_CHROMEOS) |
2157 #endif | 2156 owner_managed = IsMetricsReportingOwnerManaged(); |
2157 #endif // defined(OS_CHROMEOS) | |
2158 SetMetricsReportingCheckbox(checked, policy_managed, owner_managed); | |
2159 #endif // defined(GOOGLE_CHROME_BUILD) | |
2158 } | 2160 } |
2159 | 2161 |
2160 void BrowserOptionsHandler::HandleMetricsReportingChange( | 2162 void BrowserOptionsHandler::HandleMetricsReportingChange( |
2161 const base::ListValue* args) { | 2163 const base::ListValue* args) { |
2162 bool enable; | 2164 bool enable; |
2163 if (!args->GetBoolean(0, &enable)) | 2165 if (!args->GetBoolean(0, &enable)) |
2164 return; | 2166 return; |
2167 if (IsMetricsReportingOwnerManaged() || IsMetricsReportingPolicyManaged()) { | |
2168 MetricsReportingChangeCallback( | |
2169 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()); | |
2170 return; | |
2171 } | |
2165 | 2172 |
2166 InitiateMetricsReportingChange( | 2173 InitiateMetricsReportingChange( |
2167 enable, | 2174 enable, |
2168 base::Bind(&BrowserOptionsHandler::MetricsReportingChangeCallback, | 2175 base::Bind(&BrowserOptionsHandler::MetricsReportingChangeCallback, |
2169 base::Unretained(this))); | 2176 base::Unretained(this))); |
2177 #if defined(OS_CHROMEOS) | |
2178 chromeos::CrosSettings::Get()->SetBoolean(chromeos::kStatsReportingPref, | |
2179 enable); | |
2180 #endif // defined(OS_CHROMEOS) | |
2170 } | 2181 } |
2171 | 2182 |
2172 void BrowserOptionsHandler::MetricsReportingChangeCallback(bool enabled) { | 2183 void BrowserOptionsHandler::MetricsReportingChangeCallback(bool enabled) { |
2173 SetMetricsReportingCheckbox(enabled, !IsMetricsReportingUserChangable()); | 2184 SetMetricsReportingCheckbox(enabled, IsMetricsReportingPolicyManaged(), |
2185 IsMetricsReportingOwnerManaged()); | |
2174 } | 2186 } |
2175 | 2187 |
2176 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked, | 2188 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked, |
2177 bool disabled) { | 2189 bool policy_managed, |
2190 bool owner_managed) { | |
2178 web_ui()->CallJavascriptFunction( | 2191 web_ui()->CallJavascriptFunction( |
2179 "BrowserOptions.setMetricsReportingCheckboxState", | 2192 "BrowserOptions.setMetricsReportingCheckboxState", |
2180 base::FundamentalValue(checked), | 2193 base::FundamentalValue(checked), base::FundamentalValue(policy_managed), |
2181 base::FundamentalValue(disabled)); | 2194 base::FundamentalValue(owner_managed)); |
2182 } | 2195 } |
2183 | 2196 |
2184 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, | 2197 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, |
2185 const policy::PolicyMap& previous, | 2198 const policy::PolicyMap& previous, |
2186 const policy::PolicyMap& current) { | 2199 const policy::PolicyMap& current) { |
2187 std::set<std::string> different_keys; | 2200 std::set<std::string> different_keys; |
2188 current.GetDifferingKeys(previous, &different_keys); | 2201 current.GetDifferingKeys(previous, &different_keys); |
2189 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) | 2202 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) |
2190 SetupMetricsReportingCheckbox(); | 2203 SetupMetricsReportingCheckbox(); |
2191 } | 2204 } |
2192 | 2205 |
2206 bool BrowserOptionsHandler::IsMetricsReportingOwnerManaged() { | |
Alexei Svitkine (slow)
2015/10/29 17:04:14
This method name is confusing.
I think you're try
gayane -on leave until 09-2017
2015/11/02 19:23:52
Couldn't come up with nice name with negation in t
| |
2207 #if defined(OS_CHROMEOS) | |
2208 return !chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())); | |
2209 #else | |
2210 return false; | |
2211 #endif | |
2212 } | |
2213 | |
2193 } // namespace options | 2214 } // namespace options |
OLD | NEW |