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 bool ExternalComponentLoader::IsEnhancedBookmarksExperimentEnabled() { | |
25 const char kFieldTrialDefaultGroupName[] = "Default"; | |
26 std::string field_trial_group_name = | |
27 base::FieldTrialList::FindFullName(kFieldTrialName); | |
28 if (field_trial_group_name.empty() || | |
29 field_trial_group_name == kFieldTrialDefaultGroupName) { | |
30 return false; | |
31 } | |
32 std::string app_id = | |
33 chrome_variations::GetVariationParamValue(kFieldTrialName, "id"); | |
34 FeatureProvider* feature_provider = FeatureProvider::GetPermissionFeatures(); | |
35 Feature* feature = feature_provider->GetFeature("metricsPrivate"); | |
Yaron
2013/11/21 23:47:01
Actually, in thinking about this, I don't know if
yefimt
2013/11/21 23:50:54
Command line flag should work, it will get paramet
| |
36 return (feature && feature->IsIdInWhitelist(app_id)); | |
37 } | |
38 | |
16 void ExternalComponentLoader::StartLoading() { | 39 void ExternalComponentLoader::StartLoading() { |
17 prefs_.reset(new base::DictionaryValue()); | 40 prefs_.reset(new base::DictionaryValue()); |
18 std::string appId = extension_misc::kInAppPaymentsSupportAppId; | 41 std::string appId = extension_misc::kInAppPaymentsSupportAppId; |
19 prefs_->SetString(appId + ".external_update_url", | 42 prefs_->SetString(appId + ".external_update_url", |
20 extension_urls::GetWebstoreUpdateUrl().spec()); | 43 extension_urls::GetWebstoreUpdateUrl().spec()); |
44 | |
45 if (IsEnhancedBookmarksExperimentEnabled() && | |
46 (CommandLine::ForCurrentProcess()-> | |
47 GetSwitchValueASCII(switches::kEnableEnhancedBookmarks) != "0")) { | |
48 std::string app_id = | |
49 chrome_variations::GetVariationParamValue(kFieldTrialName, "id"); | |
50 prefs_->SetString(app_id + ".external_update_url", | |
51 extension_urls::GetWebstoreUpdateUrl().spec()); | |
52 } | |
21 LoadFinished(); | 53 LoadFinished(); |
22 } | 54 } |
23 | 55 |
24 } // namespace extensions | 56 } // namespace extensions |
OLD | NEW |