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" | 11 #include "components/offline_pages/offline_page_feature.h" |
jianli
2015/12/03 23:30:04
nit: you can include this include
jianli
2015/12/03 23:30:38
sorry, I mean to remove this include
Kibeom Kim (inactive)
2015/12/03 23:36:39
Done.
| |
12 #include "components/variations/variations_associated_data.h" | 12 #include "components/variations/variations_associated_data.h" |
13 | 13 |
14 #if defined(OS_IOS) || defined(OS_ANDROID) | |
15 | |
16 namespace enhanced_bookmarks { | 14 namespace enhanced_bookmarks { |
17 namespace { | 15 namespace { |
18 const char kFieldTrialName[] = "EnhancedBookmarks"; | 16 const char kFieldTrialName[] = "EnhancedBookmarks"; |
19 } // namespace | 17 } // namespace |
20 | 18 |
21 bool IsEnhancedBookmarksEnabled() { | 19 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". "" - | 20 // kEnhancedBookmarksExperiment flag could have values "", "1" and "0". "" - |
30 // default, "0" - user opted out, "1" - user opted in. Tests also use the | 21 // default, "0" - user opted out, "1" - user opted in. Tests also use the |
31 // command line flag to force enhanced bookmark to be on. | 22 // command line flag to force enhanced bookmark to be on. |
32 std::string switch_value = | 23 std::string switch_value = |
33 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 24 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
34 switches::kEnhancedBookmarksExperiment); | 25 switches::kEnhancedBookmarksExperiment); |
35 if (switch_value == "1") | 26 if (switch_value == "1") |
36 return true; | 27 return true; |
37 if (switch_value == "0") | 28 if (switch_value == "0") |
38 return false; | 29 return false; |
39 | 30 |
40 // Check that the "id" param is present. This is a legacy of the desktop | 31 // 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 | 32 // implementation providing the extension id via param. This probably should |
42 // be replaced with code that checks the experiment name instead. | 33 // be replaced with code that checks the experiment name instead. |
43 return !variations::GetVariationParamValue(kFieldTrialName, "id").empty(); | 34 return !variations::GetVariationParamValue(kFieldTrialName, "id").empty(); |
44 } | 35 } |
45 | 36 |
46 } // namespace enhanced_bookmarks | 37 } // namespace enhanced_bookmarks |
47 | |
48 #endif | |
OLD | NEW |