| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/enhanced_bookmarks/enhanced_bookmark_features.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "base/command_line.h" | |
| 10 #include "build/build_config.h" | |
| 11 #include "components/enhanced_bookmarks/enhanced_bookmark_switches.h" | |
| 12 #include "components/offline_pages/offline_page_feature.h" | |
| 13 #include "components/variations/variations_associated_data.h" | |
| 14 | |
| 15 #if defined(OS_IOS) || defined(OS_ANDROID) | |
| 16 | |
| 17 namespace enhanced_bookmarks { | |
| 18 namespace { | |
| 19 const char kFieldTrialName[] = "EnhancedBookmarks"; | |
| 20 } // namespace | |
| 21 | |
| 22 bool IsEnhancedBookmarksEnabled() { | |
| 23 #if defined(OS_ANDROID) | |
| 24 // If offline pages feature is enabled, also enable enhanced bookmarks feature | |
| 25 // regardless its state. | |
| 26 if (offline_pages::IsOfflinePagesEnabled()) | |
| 27 return true; | |
| 28 #endif | |
| 29 | |
| 30 // kEnhancedBookmarksExperiment flag could have values "", "1" and "0". "" - | |
| 31 // default, "0" - user opted out, "1" - user opted in. Tests also use the | |
| 32 // command line flag to force enhanced bookmark to be on. | |
| 33 std::string switch_value = | |
| 34 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
| 35 switches::kEnhancedBookmarksExperiment); | |
| 36 if (switch_value == "1") | |
| 37 return true; | |
| 38 if (switch_value == "0") | |
| 39 return false; | |
| 40 | |
| 41 // Check that the "id" param is present. This is a legacy of the desktop | |
| 42 // implementation providing the extension id via param. This probably should | |
| 43 // be replaced with code that checks the experiment name instead. | |
| 44 return !variations::GetVariationParamValue(kFieldTrialName, "id").empty(); | |
| 45 } | |
| 46 | |
| 47 } // namespace enhanced_bookmarks | |
| 48 | |
| 49 #endif | |
| OLD | NEW |