| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/bookmarks/enhanced_bookmarks_features.h" | 5 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
| 11 #include "base/sha1.h" | 11 #include "base/sha1.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 15 #include "components/sync_driver/pref_names.h" | 15 #include "components/sync_driver/pref_names.h" |
| 16 #include "components/variations/variations_associated_data.h" | 16 #include "components/variations/variations_associated_data.h" |
| 17 #include "extensions/common/features/feature.h" | 17 #include "extensions/common/features/feature.h" |
| 18 #include "extensions/common/features/feature_provider.h" | 18 #include "extensions/common/features/feature_provider.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 const char kFieldTrialName[] = "EnhancedBookmarks"; | 22 const char kFieldTrialName[] = "EnhancedBookmarks"; |
| 23 | 23 |
| 24 // Get extension id from Finch EnhancedBookmarks group parameters. | 24 // Get extension id from Finch EnhancedBookmarks group parameters. |
| 25 std::string GetEnhancedBookmarksExtensionIdFromFinch() { | 25 std::string GetEnhancedBookmarksExtensionIdFromFinch() { |
| 26 return chrome_variations::GetVariationParamValue(kFieldTrialName, "id"); | 26 return variations::GetVariationParamValue(kFieldTrialName, "id"); |
| 27 } | 27 } |
| 28 | 28 |
| 29 // Returns true if enhanced bookmarks experiment is enabled from Finch. | 29 // Returns true if enhanced bookmarks experiment is enabled from Finch. |
| 30 bool IsEnhancedBookmarksExperimentEnabledFromFinch() { | 30 bool IsEnhancedBookmarksExperimentEnabledFromFinch() { |
| 31 std::string ext_id = GetEnhancedBookmarksExtensionIdFromFinch(); | 31 std::string ext_id = GetEnhancedBookmarksExtensionIdFromFinch(); |
| 32 const extensions::FeatureProvider* feature_provider = | 32 const extensions::FeatureProvider* feature_provider = |
| 33 extensions::FeatureProvider::GetPermissionFeatures(); | 33 extensions::FeatureProvider::GetPermissionFeatures(); |
| 34 extensions::Feature* feature = feature_provider->GetFeature("metricsPrivate"); | 34 extensions::Feature* feature = feature_provider->GetFeature("metricsPrivate"); |
| 35 return feature && feature->IsIdInWhitelist(ext_id); | 35 return feature && feature->IsIdInWhitelist(ext_id); |
| 36 } | 36 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 #if defined(OS_ANDROID) | 177 #if defined(OS_ANDROID) |
| 178 bool IsEnhancedBookmarkImageFetchingEnabled() { | 178 bool IsEnhancedBookmarkImageFetchingEnabled() { |
| 179 if (IsEnhancedBookmarksExperimentEnabled()) | 179 if (IsEnhancedBookmarksExperimentEnabled()) |
| 180 return true; | 180 return true; |
| 181 | 181 |
| 182 // Salient images are collected from visited bookmarked pages even if the | 182 // Salient images are collected from visited bookmarked pages even if the |
| 183 // enhanced bookmark feature is turned off. This is to have some images | 183 // enhanced bookmark feature is turned off. This is to have some images |
| 184 // available so that in the future, when the feature is turned on, the user | 184 // available so that in the future, when the feature is turned on, the user |
| 185 // experience is not a big list of flat colors. However as a precautionary | 185 // experience is not a big list of flat colors. However as a precautionary |
| 186 // measure it is possible to disable this collection of images from finch. | 186 // measure it is possible to disable this collection of images from finch. |
| 187 std::string disable_fetching = chrome_variations::GetVariationParamValue( | 187 std::string disable_fetching = variations::GetVariationParamValue( |
| 188 kFieldTrialName, "DisableImagesFetching"); | 188 kFieldTrialName, "DisableImagesFetching"); |
| 189 return disable_fetching.empty(); | 189 return disable_fetching.empty(); |
| 190 } | 190 } |
| 191 #endif | 191 #endif |
| 192 | 192 |
| 193 bool IsEnableDomDistillerSet() { | 193 bool IsEnableDomDistillerSet() { |
| 194 if (CommandLine::ForCurrentProcess()-> | 194 if (CommandLine::ForCurrentProcess()-> |
| 195 HasSwitch(switches::kEnableDomDistiller)) { | 195 HasSwitch(switches::kEnableDomDistiller)) { |
| 196 return true; | 196 return true; |
| 197 } | 197 } |
| 198 if (chrome_variations::GetVariationParamValue( | 198 if (variations::GetVariationParamValue( |
| 199 kFieldTrialName, "enable-dom-distiller") == "1") | 199 kFieldTrialName, "enable-dom-distiller") == "1") |
| 200 return true; | 200 return true; |
| 201 | 201 |
| 202 return false; | 202 return false; |
| 203 } | 203 } |
| 204 | 204 |
| 205 bool IsEnableSyncArticlesSet() { | 205 bool IsEnableSyncArticlesSet() { |
| 206 if (CommandLine::ForCurrentProcess()-> | 206 if (CommandLine::ForCurrentProcess()-> |
| 207 HasSwitch(switches::kEnableSyncArticles)) { | 207 HasSwitch(switches::kEnableSyncArticles)) { |
| 208 return true; | 208 return true; |
| 209 } | 209 } |
| 210 if (chrome_variations::GetVariationParamValue( | 210 if (variations::GetVariationParamValue( |
| 211 kFieldTrialName, "enable-sync-articles") == "1") | 211 kFieldTrialName, "enable-sync-articles") == "1") |
| 212 return true; | 212 return true; |
| 213 | 213 |
| 214 return false; | 214 return false; |
| 215 } | 215 } |
| OLD | NEW |