Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: chrome/browser/bookmarks/enhanced_bookmarks_features.cc

Issue 1017913002: Force Enhanced Bookmark to be enabled if command line flags are set true (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up includes Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
9 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
10 #include "base/prefs/scoped_user_pref_update.h"
11 #include "base/sha1.h"
12 #include "base/strings/string_number_conversions.h"
13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/flags_storage.h"
15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/signin/signin_manager_factory.h"
17 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/pref_names.h"
19 #include "components/signin/core/browser/signin_manager.h"
20 #include "components/sync_driver/pref_names.h"
21 #include "components/variations/variations_associated_data.h" 10 #include "components/variations/variations_associated_data.h"
22 #include "extensions/common/features/feature.h" 11 #include "extensions/common/features/feature.h"
23 #include "extensions/common/features/feature_provider.h" 12 #include "extensions/common/features/feature_provider.h"
24 13
25 #if defined(OS_ANDROID) 14 #if defined(OS_ANDROID)
26 #include "base/android/build_info.h" 15 #include "base/android/build_info.h"
27 #endif 16 #endif
28 17
29 namespace { 18 namespace {
30 19
31 const char kFieldTrialName[] = "EnhancedBookmarks"; 20 const char kFieldTrialName[] = "EnhancedBookmarks";
32 21
33 } // namespace 22 } // namespace
34 23
35 bool GetBookmarksExperimentExtensionID(std::string* extension_id) { 24 bool GetBookmarksExperimentExtensionID(std::string* extension_id) {
36 *extension_id = variations::GetVariationParamValue(kFieldTrialName, "id"); 25 *extension_id = variations::GetVariationParamValue(kFieldTrialName, "id");
37 if (extension_id->empty()) 26 if (extension_id->empty())
38 return false; 27 return false;
39 28
40 // kEnhancedBookmarksExperiment flag could have values "", "1" and "0".
41 // "0" - user opted out.
42 bool opt_out = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
43 switches::kEnhancedBookmarksExperiment) == "0";
44
45 if (opt_out)
46 return false;
47
48 #if defined(OS_ANDROID) 29 #if defined(OS_ANDROID)
49 return base::android::BuildInfo::GetInstance()->sdk_int() > 30 return true;
50 base::android::SdkVersion::SDK_VERSION_ICE_CREAM_SANDWICH_MR1;
51 #else 31 #else
52 const extensions::FeatureProvider* feature_provider = 32 const extensions::FeatureProvider* feature_provider =
53 extensions::FeatureProvider::GetPermissionFeatures(); 33 extensions::FeatureProvider::GetPermissionFeatures();
54 extensions::Feature* feature = feature_provider->GetFeature("metricsPrivate"); 34 extensions::Feature* feature = feature_provider->GetFeature("metricsPrivate");
55 return feature && feature->IsIdInWhitelist(*extension_id); 35 return feature && feature->IsIdInWhitelist(*extension_id);
56 #endif 36 #endif
57 } 37 }
58 38
59 #if defined(OS_ANDROID) 39 #if defined(OS_ANDROID)
60 bool IsEnhancedBookmarkImageFetchingEnabled(const PrefService* user_prefs) { 40 bool IsEnhancedBookmarkImageFetchingEnabled(const PrefService* user_prefs) {
61 if (IsEnhancedBookmarksEnabled()) 41 if (IsEnhancedBookmarksEnabled())
62 return true; 42 return true;
63 43
64 // Salient images are collected from visited bookmarked pages even if the 44 // Salient images are collected from visited bookmarked pages even if the
65 // 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
66 // 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
67 // 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
68 // 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.
69 std::string disable_fetching = variations::GetVariationParamValue( 49 std::string disable_fetching = variations::GetVariationParamValue(
70 kFieldTrialName, "DisableImagesFetching"); 50 kFieldTrialName, "DisableImagesFetching");
71 return disable_fetching.empty(); 51 return disable_fetching.empty();
72 } 52 }
73 53
74 bool IsEnhancedBookmarksEnabled() { 54 bool IsEnhancedBookmarksEnabled() {
75 std::string extension_id; 55 std::string extension_id;
76 return GetBookmarksExperimentExtensionID(&extension_id); 56 return IsEnhancedBookmarksEnabled(&extension_id);
77 } 57 }
78 #endif 58 #endif
79 59
60 bool IsEnhancedBookmarksEnabled(std::string* extension_id) {
61 // kEnhancedBookmarksExperiment flag could have values "", "1" and "0".
62 // "0" - user opted out.
63 bool opt_out = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
64 switches::kEnhancedBookmarksExperiment) == "0";
65
66 #if defined(OS_ANDROID)
67 opt_out |= base::android::BuildInfo::GetInstance()->sdk_int() <
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(
72 switches::kEnhancedBookmarksExperiment) == "1";
73 if (opt_in)
74 return true;
75 #endif
76
77 if (opt_out)
78 return false;
79
80 return GetBookmarksExperimentExtensionID(extension_id);
81 }
82
80 bool IsEnableDomDistillerSet() { 83 bool IsEnableDomDistillerSet() {
81 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 84 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
82 switches::kEnableDomDistiller)) { 85 switches::kEnableDomDistiller)) {
83 return true; 86 return true;
84 } 87 }
85 if (variations::GetVariationParamValue( 88 if (variations::GetVariationParamValue(
86 kFieldTrialName, "enable-dom-distiller") == "1") 89 kFieldTrialName, "enable-dom-distiller") == "1")
87 return true; 90 return true;
88 91
89 return false; 92 return false;
90 } 93 }
91 94
92 bool IsEnableSyncArticlesSet() { 95 bool IsEnableSyncArticlesSet() {
93 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 96 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
94 switches::kEnableSyncArticles)) { 97 switches::kEnableSyncArticles)) {
95 return true; 98 return true;
96 } 99 }
97 if (variations::GetVariationParamValue( 100 if (variations::GetVariationParamValue(
98 kFieldTrialName, "enable-sync-articles") == "1") 101 kFieldTrialName, "enable-sync-articles") == "1")
99 return true; 102 return true;
100 103
101 return false; 104 return false;
102 } 105 }
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/enhanced_bookmarks_features.h ('k') | chrome/browser/extensions/external_component_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698