Home | History | Annotate | Download | only in search
      1 // Copyright 2014 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 #ifndef COMPONENTS_SEARCH_SEARCH_H_
      6 #define COMPONENTS_SEARCH_SEARCH_H_
      7 
      8 #include <string>
      9 #include <utility>
     10 #include <vector>
     11 
     12 #include "base/basictypes.h"
     13 #include "base/strings/string16.h"
     14 
     15 namespace chrome {
     16 
     17 // Returns whether the Instant Extended API is enabled.
     18 bool IsInstantExtendedAPIEnabled();
     19 
     20 // Returns the value to pass to the &espv CGI parameter when loading the
     21 // embedded search page from the user's default search provider. Returns 0 if
     22 // the Instant Extended API is not enabled.
     23 uint64 EmbeddedSearchPageVersion();
     24 
     25 // Type for a collection of experiment configuration parameters.
     26 typedef std::vector<std::pair<std::string, std::string> > FieldTrialFlags;
     27 
     28 // Finds the active field trial group name and parses out the configuration
     29 // flags. On success, |flags| will be filled with the field trial flags. |flags|
     30 // must not be NULL. Returns true iff the active field trial is successfully
     31 // parsed and not disabled.
     32 // Note that |flags| may be successfully populated in some cases when false is
     33 // returned - in these cases it should not be used.
     34 // Exposed for testing only.
     35 bool GetFieldTrialInfo(FieldTrialFlags* flags);
     36 
     37 // Given a FieldTrialFlags object, returns the string value of the provided
     38 // flag.
     39 // Exposed for testing only.
     40 std::string GetStringValueForFlagWithDefault(const std::string& flag,
     41                                              const std::string& default_value,
     42                                              const FieldTrialFlags& flags);
     43 
     44 // Given a FieldTrialFlags object, returns the uint64 value of the provided
     45 // flag.
     46 // Exposed for testing only.
     47 uint64 GetUInt64ValueForFlagWithDefault(const std::string& flag,
     48                                         uint64 default_value,
     49                                         const FieldTrialFlags& flags);
     50 
     51 // Given a FieldTrialFlags object, returns the bool value of the provided flag.
     52 // Exposed for testing only.
     53 bool GetBoolValueForFlagWithDefault(const std::string& flag,
     54                                     bool default_value,
     55                                     const FieldTrialFlags& flags);
     56 
     57 // Returns true if 'hide_verbatim' flag is enabled in field trials
     58 // to hide the top match in the native suggestions dropdown if it is a verbatim
     59 // match.  See comments on ShouldHideTopMatch in autocomplete_result.h.
     60 bool ShouldHideTopVerbatimMatch();
     61 
     62 }  // namespace chrome
     63 
     64 #endif  // COMPONENTS_SEARCH_SEARCH_H_
     65