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