| 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/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "components/enhanced_bookmarks/enhanced_bookmark_utils.h" |
| 10 #include "components/variations/variations_associated_data.h" | 11 #include "components/variations/variations_associated_data.h" |
| 11 | 12 |
| 12 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 13 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
| 13 #include "extensions/common/features/feature.h" | 14 #include "extensions/common/features/feature.h" |
| 14 #include "extensions/common/features/feature_provider.h" | 15 #include "extensions/common/features/feature_provider.h" |
| 15 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 16 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 const char kFieldTrialName[] = "EnhancedBookmarks"; | |
| 20 | |
| 21 bool GetBookmarksExperimentExtensionID(std::string* extension_id) { | 20 bool GetBookmarksExperimentExtensionID(std::string* extension_id) { |
| 22 *extension_id = variations::GetVariationParamValue(kFieldTrialName, "id"); | 21 *extension_id = variations::GetVariationParamValue( |
| 22 enhanced_bookmarks::kFieldTrialName, "id"); |
| 23 if (extension_id->empty()) | 23 if (extension_id->empty()) |
| 24 return false; | 24 return false; |
| 25 | 25 |
| 26 #if defined(OS_ANDROID) || defined(OS_IOS) | 26 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 27 return true; | 27 return true; |
| 28 #else | 28 #else |
| 29 const extensions::FeatureProvider* feature_provider = | 29 const extensions::FeatureProvider* feature_provider = |
| 30 extensions::FeatureProvider::GetPermissionFeatures(); | 30 extensions::FeatureProvider::GetPermissionFeatures(); |
| 31 extensions::Feature* feature = feature_provider->GetFeature("metricsPrivate"); | 31 extensions::Feature* feature = feature_provider->GetFeature("metricsPrivate"); |
| 32 return feature && feature->IsIdInWhitelist(*extension_id); | 32 return feature && feature->IsIdInWhitelist(*extension_id); |
| 33 #endif // defined(OS_ANDROID) || defined(OS_IOS) | 33 #endif // defined(OS_ANDROID) || defined(OS_IOS) |
| 34 } | 34 } |
| 35 | 35 |
| 36 } // namespace | 36 } // namespace |
| 37 | 37 |
| 38 #if defined(OS_ANDROID) | 38 #if defined(OS_ANDROID) |
| 39 bool IsEnhancedBookmarkImageFetchingEnabled(const PrefService* user_prefs) { | 39 bool IsEnhancedBookmarkImageFetchingEnabled(const PrefService* user_prefs) { |
| 40 if (IsEnhancedBookmarksEnabled()) | 40 if (IsEnhancedBookmarksEnabled()) |
| 41 return true; | 41 return true; |
| 42 | 42 |
| 43 // Salient images are collected from visited bookmarked pages even if the | 43 // Salient images are collected from visited bookmarked pages even if the |
| 44 // enhanced bookmark feature is turned off. This is to have some images | 44 // enhanced bookmark feature is turned off. This is to have some images |
| 45 // available so that in the future, when the feature is turned on, the user | 45 // available so that in the future, when the feature is turned on, the user |
| 46 // experience is not a big list of flat colors. However as a precautionary | 46 // experience is not a big list of flat colors. However as a precautionary |
| 47 // measure it is possible to disable this collection of images from finch. | 47 // measure it is possible to disable this collection of images from finch. |
| 48 std::string disable_fetching = variations::GetVariationParamValue( | 48 std::string disable_fetching = variations::GetVariationParamValue( |
| 49 kFieldTrialName, "DisableImagesFetching"); | 49 enhanced_bookmarks::kFieldTrialName, "DisableImagesFetching"); |
| 50 return disable_fetching.empty(); | 50 return disable_fetching.empty(); |
| 51 } | 51 } |
| 52 #endif // defined(OS_ANDROID) | 52 #endif // defined(OS_ANDROID) |
| 53 | 53 |
| 54 bool IsEnhancedBookmarksEnabled() { | 54 bool IsEnhancedBookmarksEnabled() { |
| 55 std::string extension_id; | 55 std::string extension_id; |
| 56 return IsEnhancedBookmarksEnabled(&extension_id); | 56 return IsEnhancedBookmarksEnabled(&extension_id); |
| 57 } | 57 } |
| 58 | 58 |
| 59 bool IsEnhancedBookmarksEnabled(std::string* extension_id) { | 59 bool IsEnhancedBookmarksEnabled(std::string* extension_id) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 76 return false; | 76 return false; |
| 77 | 77 |
| 78 return GetBookmarksExperimentExtensionID(extension_id); | 78 return GetBookmarksExperimentExtensionID(extension_id); |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool IsEnableDomDistillerSet() { | 81 bool IsEnableDomDistillerSet() { |
| 82 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 82 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 83 switches::kEnableDomDistiller)) { | 83 switches::kEnableDomDistiller)) { |
| 84 return true; | 84 return true; |
| 85 } | 85 } |
| 86 if (variations::GetVariationParamValue( | 86 if (variations::GetVariationParamValue(enhanced_bookmarks::kFieldTrialName, |
| 87 kFieldTrialName, "enable-dom-distiller") == "1") | 87 "enable-dom-distiller") == "1") |
| 88 return true; | 88 return true; |
| 89 | 89 |
| 90 return false; | 90 return false; |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool IsEnableSyncArticlesSet() { | 93 bool IsEnableSyncArticlesSet() { |
| 94 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 94 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 95 switches::kEnableSyncArticles)) { | 95 switches::kEnableSyncArticles)) { |
| 96 return true; | 96 return true; |
| 97 } | 97 } |
| 98 if (variations::GetVariationParamValue( | 98 if (variations::GetVariationParamValue(enhanced_bookmarks::kFieldTrialName, |
| 99 kFieldTrialName, "enable-sync-articles") == "1") | 99 "enable-sync-articles") == "1") |
| 100 return true; | 100 return true; |
| 101 | 101 |
| 102 return false; | 102 return false; |
| 103 } | 103 } |
| OLD | NEW |