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 #include "extensions/common/features/feature.h" | 11 #include "extensions/common/features/feature.h" |
12 #include "extensions/common/features/feature_provider.h" | 12 #include "extensions/common/features/feature_provider.h" |
13 | 13 |
14 #if defined(OS_ANDROID) | 14 #if defined(OS_ANDROID) |
15 #include "base/android/build_info.h" | 15 #include "base/android/build_info.h" |
16 #endif | 16 #endif |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 const char kFieldTrialName[] = "EnhancedBookmarks"; | 20 const char kFieldTrialName[] = "EnhancedBookmarks"; |
21 | 21 |
22 } // namespace | 22 } // namespace |
23 | 23 |
24 bool GetBookmarksExperimentExtensionID(std::string* extension_id) { | 24 bool GetBookmarksExperimentExtensionID(std::string* extension_id) { |
Mike Wittman
2015/03/25 17:52:58
Can you move this function into the anonymous name
noyau (Ping after 24h)
2015/03/26 10:19:41
Done.
| |
25 *extension_id = variations::GetVariationParamValue(kFieldTrialName, "id"); | 25 *extension_id = variations::GetVariationParamValue(kFieldTrialName, "id"); |
26 if (extension_id->empty()) | 26 if (extension_id->empty()) |
27 return false; | 27 return false; |
28 | 28 |
29 #if defined(OS_ANDROID) | 29 #if defined(OS_ANDROID) |
30 return true; | 30 return true; |
31 #else | 31 #else |
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(*extension_id); | 35 return feature && feature->IsIdInWhitelist(*extension_id); |
36 #endif | 36 #endif |
37 } | 37 } |
38 | 38 |
39 #if defined(OS_ANDROID) | 39 #if defined(OS_ANDROID) |
40 bool IsEnhancedBookmarkImageFetchingEnabled(const PrefService* user_prefs) { | 40 bool IsEnhancedBookmarkImageFetchingEnabled(const PrefService* user_prefs) { |
41 if (IsEnhancedBookmarksEnabled()) | 41 if (IsEnhancedBookmarksEnabled()) |
42 return true; | 42 return true; |
43 | 43 |
44 // Salient images are collected from visited bookmarked pages even if the | 44 // Salient images are collected from visited bookmarked pages even if the |
45 // enhanced bookmark feature is turned off. This is to have some images | 45 // 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 | 46 // 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 | 47 // 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. | 48 // measure it is possible to disable this collection of images from finch. |
49 std::string disable_fetching = variations::GetVariationParamValue( | 49 std::string disable_fetching = variations::GetVariationParamValue( |
50 kFieldTrialName, "DisableImagesFetching"); | 50 kFieldTrialName, "DisableImagesFetching"); |
51 return disable_fetching.empty(); | 51 return disable_fetching.empty(); |
52 } | 52 } |
53 #endif | |
53 | 54 |
54 bool IsEnhancedBookmarksEnabled() { | 55 bool IsEnhancedBookmarksEnabled() { |
55 std::string extension_id; | 56 std::string extension_id; |
56 return IsEnhancedBookmarksEnabled(&extension_id); | 57 return IsEnhancedBookmarksEnabled(&extension_id); |
57 } | 58 } |
58 #endif | |
59 | 59 |
60 bool IsEnhancedBookmarksEnabled(std::string* extension_id) { | 60 bool IsEnhancedBookmarksEnabled(std::string* extension_id) { |
61 // kEnhancedBookmarksExperiment flag could have values "", "1" and "0". | 61 // kEnhancedBookmarksExperiment flag could have values "", "1" and "0". |
62 // "0" - user opted out. | 62 // "0" - user opted out. |
63 bool opt_out = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 63 bool opt_out = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
64 switches::kEnhancedBookmarksExperiment) == "0"; | 64 switches::kEnhancedBookmarksExperiment) == "0"; |
65 | 65 |
66 #if defined(OS_ANDROID) | 66 #if defined(OS_ANDROID) |
67 opt_out |= base::android::BuildInfo::GetInstance()->sdk_int() < | 67 opt_out |= base::android::BuildInfo::GetInstance()->sdk_int() < |
68 base::android::SdkVersion::SDK_VERSION_ICE_CREAM_SANDWICH_MR1; | 68 base::android::SdkVersion::SDK_VERSION_ICE_CREAM_SANDWICH_MR1; |
69 | 69 #endif |
70 // Android tests use command line flag to force enhanced bookmark to be on. | 70 // Tests use command line flag to force enhanced bookmark to be on. |
71 bool opt_in = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 71 bool opt_in = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
72 switches::kEnhancedBookmarksExperiment) == "1"; | 72 switches::kEnhancedBookmarksExperiment) == "1"; |
73 if (opt_in) | 73 if (opt_in) |
74 return true; | 74 return true; |
75 #endif | |
76 | 75 |
77 if (opt_out) | 76 if (opt_out) |
78 return false; | 77 return false; |
79 | 78 |
80 return GetBookmarksExperimentExtensionID(extension_id); | 79 return GetBookmarksExperimentExtensionID(extension_id); |
81 } | 80 } |
82 | 81 |
83 bool IsEnableDomDistillerSet() { | 82 bool IsEnableDomDistillerSet() { |
84 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 83 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
85 switches::kEnableDomDistiller)) { | 84 switches::kEnableDomDistiller)) { |
(...skipping 10 matching lines...) Expand all Loading... | |
96 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 95 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
97 switches::kEnableSyncArticles)) { | 96 switches::kEnableSyncArticles)) { |
98 return true; | 97 return true; |
99 } | 98 } |
100 if (variations::GetVariationParamValue( | 99 if (variations::GetVariationParamValue( |
101 kFieldTrialName, "enable-sync-articles") == "1") | 100 kFieldTrialName, "enable-sync-articles") == "1") |
102 return true; | 101 return true; |
103 | 102 |
104 return false; | 103 return false; |
105 } | 104 } |
OLD | NEW |