Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/extensions/external_component_loader.h" | 5 #include "chrome/browser/extensions/external_component_loader.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | |
| 8 #include "base/metrics/field_trial.h" | |
| 7 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/common/chrome_switches.h" | |
| 8 #include "chrome/common/extensions/extension_constants.h" | 11 #include "chrome/common/extensions/extension_constants.h" |
| 12 #include "components/variations/variations_associated_data.h" | |
| 13 #include "extensions/common/features/feature.h" | |
| 14 #include "extensions/common/features/feature_provider.h" | |
| 9 | 15 |
| 10 namespace extensions { | 16 namespace extensions { |
| 11 | 17 |
| 18 const char kFieldTrialName[] = "EnhancedBookmarks"; | |
| 19 | |
| 12 ExternalComponentLoader::ExternalComponentLoader() {} | 20 ExternalComponentLoader::ExternalComponentLoader() {} |
| 13 | 21 |
| 14 ExternalComponentLoader::~ExternalComponentLoader() {} | 22 ExternalComponentLoader::~ExternalComponentLoader() {} |
| 15 | 23 |
| 24 // This functione will be removed after experiment goes to all users or go away. | |
|
Yaron
2013/11/25 23:49:33
s/functione/function
yefimt
2013/11/26 00:14:48
Done.
| |
| 25 bool ExternalComponentLoader::IsEnhancedBookmarksExperimentEnabled() { | |
| 26 const char kFieldTrialDefaultGroupName[] = "Default"; | |
| 27 std::string field_trial_group_name = | |
| 28 base::FieldTrialList::FindFullName(kFieldTrialName); | |
| 29 if (field_trial_group_name.empty() || | |
| 30 field_trial_group_name == kFieldTrialDefaultGroupName) { | |
| 31 return false; | |
| 32 } | |
| 33 std::string app_id = | |
| 34 chrome_variations::GetVariationParamValue(kFieldTrialName, "id"); | |
| 35 FeatureProvider* feature_provider = FeatureProvider::GetPermissionFeatures(); | |
| 36 Feature* feature = feature_provider->GetFeature("metricsPrivate"); | |
| 37 return (feature && feature->IsIdInWhitelist(app_id)); | |
|
palmer
2013/11/26 01:03:38
Nit: don't need outer parentheses
| |
| 38 } | |
| 39 | |
| 16 void ExternalComponentLoader::StartLoading() { | 40 void ExternalComponentLoader::StartLoading() { |
| 17 prefs_.reset(new base::DictionaryValue()); | 41 prefs_.reset(new base::DictionaryValue()); |
| 18 std::string appId = extension_misc::kInAppPaymentsSupportAppId; | 42 std::string appId = extension_misc::kInAppPaymentsSupportAppId; |
| 19 prefs_->SetString(appId + ".external_update_url", | 43 prefs_->SetString(appId + ".external_update_url", |
| 20 extension_urls::GetWebstoreUpdateUrl().spec()); | 44 extension_urls::GetWebstoreUpdateUrl().spec()); |
| 45 | |
| 46 if (IsEnhancedBookmarksExperimentEnabled() && | |
| 47 (CommandLine::ForCurrentProcess()-> | |
| 48 GetSwitchValueASCII(switches::kEnableEnhancedBookmarks) != "0")) { | |
| 49 std::string app_id = | |
| 50 chrome_variations::GetVariationParamValue(kFieldTrialName, "id"); | |
| 51 prefs_->SetString(app_id + ".external_update_url", | |
| 52 extension_urls::GetWebstoreUpdateUrl().spec()); | |
| 53 } | |
| 21 LoadFinished(); | 54 LoadFinished(); |
| 22 } | 55 } |
| 23 | 56 |
| 24 } // namespace extensions | 57 } // namespace extensions |
| OLD | NEW |