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

Side by Side Diff: chrome/browser/ui/webui/options/browser_options_handler.cc

Issue 1411863002: Use kMetricsReportingEnabled instead of kStatsReporingPref on metrics side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 years, 1 month 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
OLDNEW
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
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
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 to be set up for non-official builds.
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 = !IsDeviceOwnerProfile();
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 (!IsDeviceOwnerProfile() || IsMetricsReportingPolicyManaged()) {
Alexei Svitkine (slow) 2015/11/03 19:55:24 Add a comment please.
gayane -on leave until 09-2017 2015/11/03 21:54:22 Done.
2168 MetricsReportingChangeCallback(
2169 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled());
2170 return;
2171 }
2165 2172
2173 #if defined(OS_CHROMEOS)
2174 chromeos::CrosSettings::Get()->SetBoolean(chromeos::kStatsReportingPref,
2175 enable);
Alexei Svitkine (slow) 2015/11/03 19:55:25 How will MetricsReportingChangeCallback() be invok
gayane -on leave until 09-2017 2015/11/03 21:54:22 That's right I have lost the callback for chromeos
2176 #else
2166 InitiateMetricsReportingChange( 2177 InitiateMetricsReportingChange(
2167 enable, 2178 enable,
2168 base::Bind(&BrowserOptionsHandler::MetricsReportingChangeCallback, 2179 base::Bind(&BrowserOptionsHandler::MetricsReportingChangeCallback,
2169 base::Unretained(this))); 2180 base::Unretained(this)));
2181 #endif // defined(OS_CHROMEOS)
2170 } 2182 }
2171 2183
2172 void BrowserOptionsHandler::MetricsReportingChangeCallback(bool enabled) { 2184 void BrowserOptionsHandler::MetricsReportingChangeCallback(bool enabled) {
2173 SetMetricsReportingCheckbox(enabled, !IsMetricsReportingUserChangable()); 2185 SetMetricsReportingCheckbox(enabled, IsMetricsReportingPolicyManaged(),
2186 !IsDeviceOwnerProfile());
2174 } 2187 }
2175 2188
2176 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked, 2189 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked,
2177 bool disabled) { 2190 bool policy_managed,
2191 bool owner_managed) {
2178 web_ui()->CallJavascriptFunction( 2192 web_ui()->CallJavascriptFunction(
2179 "BrowserOptions.setMetricsReportingCheckboxState", 2193 "BrowserOptions.setMetricsReportingCheckboxState",
2180 base::FundamentalValue(checked), 2194 base::FundamentalValue(checked), base::FundamentalValue(policy_managed),
2181 base::FundamentalValue(disabled)); 2195 base::FundamentalValue(owner_managed));
2182 } 2196 }
2183 2197
2184 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, 2198 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns,
2185 const policy::PolicyMap& previous, 2199 const policy::PolicyMap& previous,
2186 const policy::PolicyMap& current) { 2200 const policy::PolicyMap& current) {
2187 std::set<std::string> different_keys; 2201 std::set<std::string> different_keys;
2188 current.GetDifferingKeys(previous, &different_keys); 2202 current.GetDifferingKeys(previous, &different_keys);
2189 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) 2203 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled))
2190 SetupMetricsReportingCheckbox(); 2204 SetupMetricsReportingCheckbox();
2191 } 2205 }
2192 2206
2207 bool BrowserOptionsHandler::IsDeviceOwnerProfile() {
2208 #if defined(OS_CHROMEOS)
2209 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui()));
2210 #else
2211 return true;
2212 #endif
2213 }
2214
2193 } // namespace options 2215 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698