OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_SEARCH_SEARCH_H_ | 5 #ifndef CHROME_BROWSER_UI_SEARCH_SEARCH_H_ |
6 #define CHROME_BROWSER_UI_SEARCH_SEARCH_H_ | 6 #define CHROME_BROWSER_UI_SEARCH_SEARCH_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 | 13 |
14 class GURL; | 14 class GURL; |
15 class Profile; | 15 class Profile; |
16 | 16 |
17 namespace chrome { | 17 namespace chrome { |
18 namespace search { | 18 namespace search { |
19 | 19 |
| 20 enum InstantExtendedDefault { |
| 21 INSTANT_FORCE_ON, // Force the setting on if no other setting exists. |
| 22 INSTANT_USE_EXISTING, // Use same the value of the old instant.enabled pref. |
| 23 INSTANT_FORCE_OFF, // Force the setting off if no other setting exists. |
| 24 }; |
| 25 |
| 26 // Returns an enum value indicating which mode to set the new |
| 27 // instant_extended.enabled pref to by default. |
| 28 InstantExtendedDefault GetInstantExtendedDefaultSetting(); |
| 29 |
20 // Returns whether the Instant extended API is enabled for the given |profile|. | 30 // Returns whether the Instant extended API is enabled for the given |profile|. |
21 // |profile| may not be NULL. | 31 // |profile| may not be NULL. |
22 bool IsInstantExtendedAPIEnabled(Profile* profile); | 32 bool IsInstantExtendedAPIEnabled(Profile* profile); |
23 | 33 |
24 // Returns the value to pass to the &espv cgi parameter when loading the | 34 // Returns the value to pass to the &espv cgi parameter when loading the |
25 // embedded search page from the user's default search provider. Will be | 35 // embedded search page from the user's default search provider. Will be |
26 // 0 if the Instant Extended API is not enabled. | 36 // 0 if the Instant Extended API is not enabled. |
27 uint64 EmbeddedSearchPageVersion(Profile* profile); | 37 uint64 EmbeddedSearchPageVersion(Profile* profile); |
28 | 38 |
29 // Force the instant extended API to be enabled for tests. | 39 // Force the instant extended API to be enabled for tests. |
30 void EnableInstantExtendedAPIForTesting(); | 40 void EnableInstantExtendedAPIForTesting(); |
31 | 41 |
32 // Returns whether query extraction is enabled. If | 42 // Returns whether query extraction is enabled. If |
33 // |IsInstantExtendedAPIEnabled()| and the profile is not off the record, then | 43 // |IsInstantExtendedAPIEnabled()| and the profile is not off the record, then |
34 // this method will also return true. | 44 // this method will also return true. |
35 bool IsQueryExtractionEnabled(Profile* profile); | 45 bool IsQueryExtractionEnabled(Profile* profile); |
36 | 46 |
37 // Force query extraction to be enabled for tests. | 47 // Force query extraction to be enabled for tests. |
38 void EnableQueryExtractionForTesting(); | 48 void EnableQueryExtractionForTesting(); |
39 | 49 |
40 // Returns true if |url| has the same scheme, host, port and path as the | 50 // Returns true if |url| has the same scheme, host, port and path as the |
41 // Instant URL set via --instant-url. | 51 // Instant URL set via --instant-url. |
42 bool IsForcedInstantURL(const GURL& url); | 52 bool IsForcedInstantURL(const GURL& url); |
43 | 53 |
44 // Type for a collection of experiment configuration parameters. | 54 // Type for a collection of experiment configuration parameters. |
45 typedef std::vector<std::pair<std::string, std::string> > FieldTrialFlags; | 55 typedef std::vector<std::pair<std::string, std::string> > FieldTrialFlags; |
46 | 56 |
47 // Given a field trial group name, parses out the group number and configuration | 57 // Given a field trial group name, parses out the group number and configuration |
48 // flags. | 58 // flags. On success, |flags| will be filled with the field trial flags. |flags| |
| 59 // must not be NULL. If not NULL, |group_number| will receive the experiment |
| 60 // group number. |
| 61 // Returns true iff field trial info was successfully parsed out of |
| 62 // |group_name|. |
49 // Exposed for testing only. | 63 // Exposed for testing only. |
50 void GetFieldTrialInfo(const std::string& group_name, | 64 bool GetFieldTrialInfo(const std::string& group_name, |
51 FieldTrialFlags* flags, | 65 FieldTrialFlags* flags, |
52 uint64* group_number); | 66 uint64* group_number); |
53 | 67 |
54 // Given a FieldTrialFlags object, returns the string value of the provided | 68 // Given a FieldTrialFlags object, returns the string value of the provided |
55 // flag. | 69 // flag. |
56 // Exposed for testing only. | 70 // Exposed for testing only. |
57 std::string GetStringValueForFlagWithDefault( | 71 std::string GetStringValueForFlagWithDefault( |
58 const std::string& flag, | 72 const std::string& flag, |
59 const std::string& default_value, | 73 const std::string& default_value, |
60 FieldTrialFlags& flags); | 74 FieldTrialFlags& flags); |
61 | 75 |
62 // Given a FieldTrialFlags object, returns the uint64 value of the provided | 76 // Given a FieldTrialFlags object, returns the uint64 value of the provided |
63 // flag. | 77 // flag. |
64 // Exposed for testing only. | 78 // Exposed for testing only. |
65 uint64 GetUInt64ValueForFlagWithDefault( | 79 uint64 GetUInt64ValueForFlagWithDefault( |
66 const std::string& flag, uint64 default_value, FieldTrialFlags& flags); | 80 const std::string& flag, uint64 default_value, FieldTrialFlags& flags); |
67 | 81 |
68 // Given a FieldTrialFlags object, returns the bool value of the provided flag. | 82 // Given a FieldTrialFlags object, returns the bool value of the provided flag. |
69 // Exposed for testing only. | 83 // Exposed for testing only. |
70 bool GetBoolValueForFlagWithDefault( | 84 bool GetBoolValueForFlagWithDefault( |
71 const std::string& flag, bool default_value, FieldTrialFlags& flags); | 85 const std::string& flag, bool default_value, FieldTrialFlags& flags); |
72 | 86 |
73 } // namespace search | 87 } // namespace search |
74 } // namespace chrome | 88 } // namespace chrome |
75 | 89 |
76 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_H_ | 90 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_H_ |
OLD | NEW |