| 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 "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
| 10 #include "base/sha1.h" | 10 #include "base/sha1.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 experiments_list->Remove( | 36 experiments_list->Remove( |
| 37 base::StringValue(switches::kManualEnhancedBookmarksOptout), &index); | 37 base::StringValue(switches::kManualEnhancedBookmarksOptout), &index); |
| 38 experiments_list->AppendIfNotPresent( | 38 experiments_list->AppendIfNotPresent( |
| 39 new base::StringValue(switches::kManualEnhancedBookmarks)); | 39 new base::StringValue(switches::kManualEnhancedBookmarks)); |
| 40 } else if (bookmarks_experiment_state == | 40 } else if (bookmarks_experiment_state == |
| 41 kBookmarksExperimentEnabledUserOptOut) { | 41 kBookmarksExperimentEnabledUserOptOut) { |
| 42 experiments_list->Remove( | 42 experiments_list->Remove( |
| 43 base::StringValue(switches::kManualEnhancedBookmarks), &index); | 43 base::StringValue(switches::kManualEnhancedBookmarks), &index); |
| 44 experiments_list->AppendIfNotPresent( | 44 experiments_list->AppendIfNotPresent( |
| 45 new base::StringValue(switches::kManualEnhancedBookmarksOptout)); | 45 new base::StringValue(switches::kManualEnhancedBookmarksOptout)); |
| 46 } else if (bookmarks_experiment_state == |
| 47 kBookmarksExperimentEnabledFromFinch) { |
| 48 experiments_list->Remove( |
| 49 base::StringValue(switches::kManualEnhancedBookmarks), &index); |
| 50 experiments_list->Remove( |
| 51 base::StringValue(switches::kManualEnhancedBookmarksOptout), &index); |
| 46 } | 52 } |
| 47 } | 53 } |
| 48 | 54 |
| 49 bool IsEnhancedBookmarksExperimentEnabled() { | 55 bool IsEnhancedBookmarksExperimentEnabled() { |
| 50 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 56 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 51 if (command_line->HasSwitch(switches::kManualEnhancedBookmarks) || | 57 if (command_line->HasSwitch(switches::kManualEnhancedBookmarks) || |
| 52 command_line->HasSwitch(switches::kManualEnhancedBookmarksOptout)) { | 58 command_line->HasSwitch(switches::kManualEnhancedBookmarksOptout)) { |
| 53 return true; | 59 return true; |
| 54 } | 60 } |
| 55 | 61 |
| 62 return IsEnhancedBookmarksExperimentEnabledFromFinch(); |
| 63 } |
| 64 |
| 65 bool IsEnhancedBookmarksExperimentEnabledFromFinch() { |
| 56 std::string ext_id = GetEnhancedBookmarksExtensionIdFromFinch(); | 66 std::string ext_id = GetEnhancedBookmarksExtensionIdFromFinch(); |
| 57 extensions::FeatureProvider* feature_provider = | 67 extensions::FeatureProvider* feature_provider = |
| 58 extensions::FeatureProvider::GetPermissionFeatures(); | 68 extensions::FeatureProvider::GetPermissionFeatures(); |
| 59 extensions::Feature* feature = feature_provider->GetFeature("metricsPrivate"); | 69 extensions::Feature* feature = feature_provider->GetFeature("metricsPrivate"); |
| 60 return feature && feature->IsIdInWhitelist(ext_id); | 70 return feature && feature->IsIdInWhitelist(ext_id); |
| 61 } | 71 } |
| 62 | 72 |
| 63 bool IsEnableDomDistillerSet() { | 73 bool IsEnableDomDistillerSet() { |
| 64 if (CommandLine::ForCurrentProcess()-> | 74 if (CommandLine::ForCurrentProcess()-> |
| 65 HasSwitch(switches::kEnableDomDistiller)) { | 75 HasSwitch(switches::kEnableDomDistiller)) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 80 if (chrome_variations::GetVariationParamValue( | 90 if (chrome_variations::GetVariationParamValue( |
| 81 kFieldTrialName, "enable-sync-articles") == "1") | 91 kFieldTrialName, "enable-sync-articles") == "1") |
| 82 return true; | 92 return true; |
| 83 | 93 |
| 84 return false; | 94 return false; |
| 85 } | 95 } |
| 86 | 96 |
| 87 std::string GetEnhancedBookmarksExtensionIdFromFinch() { | 97 std::string GetEnhancedBookmarksExtensionIdFromFinch() { |
| 88 return chrome_variations::GetVariationParamValue(kFieldTrialName, "id"); | 98 return chrome_variations::GetVariationParamValue(kFieldTrialName, "id"); |
| 89 } | 99 } |
| OLD | NEW |