Chromium Code Reviews| 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/variations/variations_associated_data.h" | 10 #include "components/variations/variations_associated_data.h" |
| 11 | |
| 12 #if !defined(OS_ANDROID) && !defined(OS_IOS) | |
| 11 #include "extensions/common/features/feature.h" | 13 #include "extensions/common/features/feature.h" |
| 12 #include "extensions/common/features/feature_provider.h" | 14 #include "extensions/common/features/feature_provider.h" |
| 15 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | |
| 13 | 16 |
| 14 #if defined(OS_ANDROID) | 17 #if defined(OS_ANDROID) |
| 15 #include "base/android/build_info.h" | 18 #include "base/android/build_info.h" |
| 16 #endif | 19 #endif // defined(OS_ANDROID) |
| 17 | 20 |
| 18 namespace { | 21 namespace { |
| 19 | 22 |
| 20 const char kFieldTrialName[] = "EnhancedBookmarks"; | 23 const char kFieldTrialName[] = "EnhancedBookmarks"; |
| 21 | 24 |
| 22 } // namespace | |
| 23 | |
| 24 bool GetBookmarksExperimentExtensionID(std::string* extension_id) { | 25 bool GetBookmarksExperimentExtensionID(std::string* extension_id) { |
| 25 *extension_id = variations::GetVariationParamValue(kFieldTrialName, "id"); | 26 *extension_id = variations::GetVariationParamValue(kFieldTrialName, "id"); |
| 26 if (extension_id->empty()) | 27 if (extension_id->empty()) |
| 27 return false; | 28 return false; |
| 28 | 29 |
| 29 #if defined(OS_ANDROID) | 30 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 30 return true; | 31 return true; |
| 31 #else | 32 #else |
| 32 const extensions::FeatureProvider* feature_provider = | 33 const extensions::FeatureProvider* feature_provider = |
| 33 extensions::FeatureProvider::GetPermissionFeatures(); | 34 extensions::FeatureProvider::GetPermissionFeatures(); |
| 34 extensions::Feature* feature = feature_provider->GetFeature("metricsPrivate"); | 35 extensions::Feature* feature = feature_provider->GetFeature("metricsPrivate"); |
| 35 return feature && feature->IsIdInWhitelist(*extension_id); | 36 return feature && feature->IsIdInWhitelist(*extension_id); |
| 36 #endif | 37 #endif // defined(OS_ANDROID) || defined(OS_IOS) |
| 37 } | 38 } |
| 38 | 39 |
| 40 } // namespace | |
| 41 | |
| 39 #if defined(OS_ANDROID) | 42 #if defined(OS_ANDROID) |
| 40 bool IsEnhancedBookmarkImageFetchingEnabled(const PrefService* user_prefs) { | 43 bool IsEnhancedBookmarkImageFetchingEnabled(const PrefService* user_prefs) { |
| 41 if (IsEnhancedBookmarksEnabled()) | 44 if (IsEnhancedBookmarksEnabled()) |
| 42 return true; | 45 return true; |
| 43 | 46 |
| 44 // Salient images are collected from visited bookmarked pages even if the | 47 // Salient images are collected from visited bookmarked pages even if the |
| 45 // enhanced bookmark feature is turned off. This is to have some images | 48 // enhanced bookmark feature is turned off. This is to have some images |
| 46 // available so that in the future, when the feature is turned on, the user | 49 // available so that in the future, when the feature is turned on, the user |
| 47 // experience is not a big list of flat colors. However as a precautionary | 50 // experience is not a big list of flat colors. However as a precautionary |
| 48 // measure it is possible to disable this collection of images from finch. | 51 // measure it is possible to disable this collection of images from finch. |
| 49 std::string disable_fetching = variations::GetVariationParamValue( | 52 std::string disable_fetching = variations::GetVariationParamValue( |
| 50 kFieldTrialName, "DisableImagesFetching"); | 53 kFieldTrialName, "DisableImagesFetching"); |
| 51 return disable_fetching.empty(); | 54 return disable_fetching.empty(); |
| 52 } | 55 } |
| 56 #endif // defined(OS_ANDROID) | |
| 53 | 57 |
| 54 bool IsEnhancedBookmarksEnabled() { | 58 bool IsEnhancedBookmarksEnabled() { |
| 55 std::string extension_id; | 59 std::string extension_id; |
| 56 return IsEnhancedBookmarksEnabled(&extension_id); | 60 return IsEnhancedBookmarksEnabled(&extension_id); |
| 57 } | 61 } |
| 58 #endif | |
| 59 | 62 |
| 60 bool IsEnhancedBookmarksEnabled(std::string* extension_id) { | 63 bool IsEnhancedBookmarksEnabled(std::string* extension_id) { |
| 61 // kEnhancedBookmarksExperiment flag could have values "", "1" and "0". | 64 // kEnhancedBookmarksExperiment flag could have values "", "1" and "0". |
| 62 // "0" - user opted out. | 65 // "0" - user opted out. "1" is only possible on mobile as desktop needs a |
|
Mike Wittman
2015/03/26 16:35:43
possible => supported
| |
| 63 bool opt_out = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 66 // extension id that would not be available by just using the flag. |
| 64 switches::kEnhancedBookmarksExperiment) == "0"; | |
| 65 | 67 |
| 66 #if defined(OS_ANDROID) | 68 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 67 opt_out |= base::android::BuildInfo::GetInstance()->sdk_int() < | 69 // Tests use command line flag to force enhanced bookmark to be on. |
| 68 base::android::SdkVersion::SDK_VERSION_ICE_CREAM_SANDWICH_MR1; | |
| 69 | |
| 70 // Android tests use command line flag to force enhanced bookmark to be on. | |
| 71 bool opt_in = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 70 bool opt_in = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 72 switches::kEnhancedBookmarksExperiment) == "1"; | 71 switches::kEnhancedBookmarksExperiment) == "1"; |
| 73 if (opt_in) | 72 if (opt_in) |
| 74 return true; | 73 return true; |
| 75 #endif | 74 #endif // defined(OS_ANDROID) || defined(OS_IOS) |
| 75 | |
| 76 bool opt_out = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
| 77 switches::kEnhancedBookmarksExperiment) == "0"; | |
| 78 #if defined(OS_ANDROID) | |
| 79 opt_out |= base::android::BuildInfo::GetInstance()->sdk_int() < | |
| 80 base::android::SdkVersion::SDK_VERSION_ICE_CREAM_SANDWICH_MR1; | |
| 81 #endif // defined(OS_ANDROID) | |
| 76 | 82 |
| 77 if (opt_out) | 83 if (opt_out) |
| 78 return false; | 84 return false; |
| 79 | 85 |
| 80 return GetBookmarksExperimentExtensionID(extension_id); | 86 return GetBookmarksExperimentExtensionID(extension_id); |
| 81 } | 87 } |
| 82 | 88 |
| 83 bool IsEnableDomDistillerSet() { | 89 bool IsEnableDomDistillerSet() { |
| 84 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 90 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 85 switches::kEnableDomDistiller)) { | 91 switches::kEnableDomDistiller)) { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 96 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 102 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 97 switches::kEnableSyncArticles)) { | 103 switches::kEnableSyncArticles)) { |
| 98 return true; | 104 return true; |
| 99 } | 105 } |
| 100 if (variations::GetVariationParamValue( | 106 if (variations::GetVariationParamValue( |
| 101 kFieldTrialName, "enable-sync-articles") == "1") | 107 kFieldTrialName, "enable-sync-articles") == "1") |
| 102 return true; | 108 return true; |
| 103 | 109 |
| 104 return false; | 110 return false; |
| 105 } | 111 } |
| OLD | NEW |