#include "components/search_engines/enterprise/site_search_policy_handler.h"
#include "base/containers/flat_set.h"
#include "base/feature_list.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "base/values.h"
#include "components/omnibox/common/omnibox_features.h"
#include "components/policy/core/browser/policy_error_map.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/policy_constants.h"
#include "components/prefs/pref_value_map.h"
#include "components/search_engines/default_search_manager.h"
#include "components/search_engines/enterprise/enterprise_site_search_manager.h"
#include "components/search_engines/search_terms_data.h"
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_data.h"
#include "components/strings/grit/components_strings.h"
namespace policy {
namespace {
bool IsSiteSearchPolicyEnabled() { … }
base::Value SiteSearchDictFromPolicyValue(const base::Value::Dict& policy_dict,
bool featured) { … }
const std::string& GetField(const base::Value& provider,
const char* field_name) { … }
const std::string& GetShortcut(const base::Value& provider) { … }
const std::string& GetName(const base::Value& provider) { … }
const std::string& GetUrl(const base::Value& provider) { … }
bool ShortcutIsEmpty(const std::string& policy_name,
const std::string& shortcut,
PolicyErrorMap* errors) { … }
bool NameIsEmpty(const std::string& policy_name,
const std::string& name,
PolicyErrorMap* errors) { … }
bool UrlIsEmpty(const std::string& policy_name,
const std::string& url,
PolicyErrorMap* errors) { … }
bool ShortcutHasWhitespace(const std::string& policy_name,
const std::string& shortcut,
PolicyErrorMap* errors) { … }
bool ShortcutStartsWithAtSymbol(const std::string& policy_name,
const std::string& shortcut,
PolicyErrorMap* errors) { … }
bool ShortcutEqualsDefaultSearchProviderKeyword(const std::string& policy_name,
const std::string& shortcut,
const PolicyMap& policies,
PolicyErrorMap* errors) { … }
bool ReplacementStringIsMissingFromUrl(const std::string& policy_name,
const std::string& url,
PolicyErrorMap* errors) { … }
void WarnIfNonHttpsUrl(const std::string& policy_name,
const std::string& url,
PolicyErrorMap* errors) { … }
bool ShortcutAlreadySeen(
const std::string& policy_name,
const std::string& shortcut,
const base::flat_set<std::string>& shortcuts_already_seen,
PolicyErrorMap* errors,
base::flat_set<std::string>* duplicated_shortcuts) { … }
}
const char SiteSearchPolicyHandler::kName[] = …;
const char SiteSearchPolicyHandler::kShortcut[] = …;
const char SiteSearchPolicyHandler::kUrl[] = …;
const char SiteSearchPolicyHandler::kFeatured[] = …;
const int SiteSearchPolicyHandler::kMaxSiteSearchProviders = …;
const int SiteSearchPolicyHandler::kMaxFeaturedProviders = …;
SiteSearchPolicyHandler::SiteSearchPolicyHandler(Schema schema)
: … { … }
SiteSearchPolicyHandler::~SiteSearchPolicyHandler() = default;
bool SiteSearchPolicyHandler::CheckPolicySettings(const PolicyMap& policies,
PolicyErrorMap* errors) { … }
void SiteSearchPolicyHandler::ApplyPolicySettings(const PolicyMap& policies,
PrefValueMap* prefs) { … }
}