Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / browser / metrics / variations / chrome_variations_service_client.cc
blob68a6576439eede65c372d1def7b9a5196a3052cd
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/metrics/variations/chrome_variations_service_client.h"
7 #include "base/bind.h"
8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/metrics/variations/generated_resources_map.h"
10 #include "chrome/common/channel_info.h"
11 #include "components/version_info/version_info.h"
12 #include "content/public/browser/browser_thread.h"
13 #include "ui/base/resource/resource_bundle.h"
15 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
16 #include "chrome/browser/upgrade_detector_impl.h"
17 #endif
19 #if defined(OS_CHROMEOS)
20 #include "chrome/browser/chromeos/settings/cros_settings.h"
21 #endif
23 namespace {
25 // Gets the version number to use for variations seed simulation. Must be called
26 // on a thread where IO is allowed.
27 base::Version GetVersionForSimulation() {
28 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
29 const base::Version installed_version =
30 UpgradeDetectorImpl::GetCurrentlyInstalledVersion();
31 if (installed_version.IsValid())
32 return installed_version;
33 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
35 // TODO(asvitkine): Get the version that will be used on restart instead of
36 // the current version on Android, iOS and ChromeOS.
37 return base::Version(version_info::GetVersionNumber());
40 } // namespace
42 ChromeVariationsServiceClient::ChromeVariationsServiceClient() {}
44 ChromeVariationsServiceClient::~ChromeVariationsServiceClient() {}
46 std::string ChromeVariationsServiceClient::GetApplicationLocale() {
47 return g_browser_process->GetApplicationLocale();
50 base::SequencedWorkerPool* ChromeVariationsServiceClient::GetBlockingPool() {
51 return content::BrowserThread::GetBlockingPool();
54 base::Callback<base::Version(void)>
55 ChromeVariationsServiceClient::GetVersionForSimulationCallback() {
56 return base::Bind(&GetVersionForSimulation);
59 net::URLRequestContextGetter*
60 ChromeVariationsServiceClient::GetURLRequestContext() {
61 return g_browser_process->system_request_context();
64 network_time::NetworkTimeTracker*
65 ChromeVariationsServiceClient::GetNetworkTimeTracker() {
66 return g_browser_process->network_time_tracker();
69 version_info::Channel ChromeVariationsServiceClient::GetChannel() {
70 return chrome::GetChannel();
73 bool ChromeVariationsServiceClient::OverridesRestrictParameter(
74 std::string* parameter) {
75 #if defined(OS_CHROMEOS)
76 chromeos::CrosSettings::Get()->GetString(
77 chromeos::kVariationsRestrictParameter, parameter);
78 return true;
79 #else
80 return false;
81 #endif
84 void ChromeVariationsServiceClient::OverrideUIString(
85 uint32_t hash,
86 const base::string16& string) {
87 int resource_id = chrome_variations::GetResourceIndex(hash);
88 if (resource_id == -1)
89 return;
91 ui::ResourceBundle::GetSharedInstance().OverrideLocaleStringResource(
92 resource_id, string);
95 void ChromeVariationsServiceClient::OnInitialStartup() {
96 #if defined(OS_WIN)
97 StartGoogleUpdateRegistrySync();
98 #endif
101 #if defined(OS_WIN)
102 void ChromeVariationsServiceClient::StartGoogleUpdateRegistrySync() {
103 registry_syncer_.RequestRegistrySync();
105 #endif