diff options
27 files changed, 222 insertions, 174 deletions
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index 40eea9e..a80c3b5 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -42,6 +42,7 @@ include_rules = [ "+components/pref_registry", "+components/query_parser", "+components/rappor", + "+components/search_engines", "+components/search_provider_logos", "+components/sessions", "+components/signin", diff --git a/chrome/browser/history/DEPS b/chrome/browser/history/DEPS index d4c6391..4e3f080 100644 --- a/chrome/browser/history/DEPS +++ b/chrome/browser/history/DEPS @@ -34,7 +34,6 @@ include_rules = [ "!chrome/browser/profiles/incognito_helpers.h", "!chrome/browser/profiles/profile.h", "!chrome/browser/profiles/profile_manager.h", - "!chrome/browser/search_engines/template_url_id.h", "!chrome/browser/signin/oauth2_token_service.h", "!chrome/browser/signin/profile_oauth2_token_service.h", "!chrome/browser/signin/profile_oauth2_token_service_factory.h", diff --git a/chrome/browser/history/android/android_history_types.h b/chrome/browser/history/android/android_history_types.h index 8bef571e..2f92316 100644 --- a/chrome/browser/history/android/android_history_types.h +++ b/chrome/browser/history/android/android_history_types.h @@ -9,7 +9,7 @@ #include "base/memory/scoped_ptr.h" #include "chrome/browser/history/history_types.h" -#include "chrome/browser/search_engines/template_url_id.h" +#include "components/search_engines/template_url_id.h" #include "sql/statement.h" namespace sql { diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h index ebae0b0..20c6bcb 100644 --- a/chrome/browser/history/history_backend.h +++ b/chrome/browser/history/history_backend.h @@ -21,7 +21,7 @@ #include "chrome/browser/history/history_types.h" #include "chrome/browser/history/thumbnail_database.h" #include "chrome/browser/history/visit_tracker.h" -#include "chrome/browser/search_engines/template_url_id.h" +#include "components/search_engines/template_url_id.h" #include "sql/init_status.h" #include "ui/base/layout.h" diff --git a/chrome/browser/history/history_notifications.h b/chrome/browser/history/history_notifications.h index 8f77028..465b9b2 100644 --- a/chrome/browser/history/history_notifications.h +++ b/chrome/browser/history/history_notifications.h @@ -11,7 +11,7 @@ #include "chrome/browser/history/history_details.h" #include "chrome/browser/history/history_types.h" -#include "chrome/browser/search_engines/template_url_id.h" +#include "components/search_engines/template_url_id.h" #include "url/gurl.h" namespace history { diff --git a/chrome/browser/history/history_service.h b/chrome/browser/history/history_service.h index 00c17e9..da5803a 100644 --- a/chrome/browser/history/history_service.h +++ b/chrome/browser/history/history_service.h @@ -25,11 +25,11 @@ #include "chrome/browser/history/delete_directive_handler.h" #include "chrome/browser/history/history_types.h" #include "chrome/browser/history/typed_url_syncable_service.h" -#include "chrome/browser/search_engines/template_url_id.h" #include "chrome/common/ref_counted_util.h" #include "components/favicon_base/favicon_callback.h" #include "components/history/core/browser/history_client.h" #include "components/keyed_service/core/keyed_service.h" +#include "components/search_engines/template_url_id.h" #include "components/visitedlink/browser/visitedlink_delegate.h" #include "content/public/browser/download_manager_delegate.h" #include "content/public/browser/notification_observer.h" diff --git a/chrome/browser/history/history_types.h b/chrome/browser/history/history_types.h index a7eb39e..b986aa9 100644 --- a/chrome/browser/history/history_types.h +++ b/chrome/browser/history/history_types.h @@ -17,11 +17,11 @@ #include "base/memory/scoped_vector.h" #include "base/strings/string16.h" #include "base/time/time.h" -#include "chrome/browser/search_engines/template_url_id.h" #include "chrome/common/ref_counted_util.h" #include "chrome/common/thumbnail_score.h" #include "components/favicon_base/favicon_types.h" #include "components/query_parser/snippet.h" +#include "components/search_engines/template_url_id.h" #include "content/public/common/page_transition_types.h" #include "ui/gfx/image/image.h" #include "ui/gfx/size.h" diff --git a/chrome/browser/history/url_database.h b/chrome/browser/history/url_database.h index a80219e..06db0b0 100644 --- a/chrome/browser/history/url_database.h +++ b/chrome/browser/history/url_database.h @@ -7,8 +7,8 @@ #include "base/basictypes.h" #include "chrome/browser/history/history_types.h" -#include "chrome/browser/search_engines/template_url_id.h" #include "components/query_parser/query_parser.h" +#include "components/search_engines/template_url_id.h" #include "sql/statement.h" class GURL; diff --git a/chrome/browser/search_engines/default_search_manager.cc b/chrome/browser/search_engines/default_search_manager.cc index 75dd93e..da6a341 100644 --- a/chrome/browser/search_engines/default_search_manager.cc +++ b/chrome/browser/search_engines/default_search_manager.cc @@ -20,12 +20,12 @@ #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" -#include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_prepopulate_data.h" #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/search_engines/util.h" #include "chrome/common/pref_names.h" #include "components/pref_registry/pref_registry_syncable.h" +#include "components/search_engines/template_url_data.h" // A dictionary to hold all data related to the Default Search Engine. // Eventually, this should replace all the data stored in the diff --git a/chrome/browser/search_engines/default_search_manager_unittest.cc b/chrome/browser/search_engines/default_search_manager_unittest.cc index 482f2ba..5e21c99 100644 --- a/chrome/browser/search_engines/default_search_manager_unittest.cc +++ b/chrome/browser/search_engines/default_search_manager_unittest.cc @@ -9,11 +9,11 @@ #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" #include "chrome/browser/search_engines/default_search_manager.h" -#include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_prepopulate_data.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_pref_service_syncable.h" #include "components/pref_registry/pref_registry_syncable.h" +#include "components/search_engines/template_url_data.h" #include "testing/gtest/include/gtest/gtest.h" namespace { diff --git a/chrome/browser/search_engines/default_search_pref_migration.cc b/chrome/browser/search_engines/default_search_pref_migration.cc index 0424194..3435bc1 100644 --- a/chrome/browser/search_engines/default_search_pref_migration.cc +++ b/chrome/browser/search_engines/default_search_pref_migration.cc @@ -11,9 +11,9 @@ #include "base/metrics/histogram.h" #include "base/prefs/pref_service.h" #include "chrome/browser/search_engines/default_search_manager.h" -#include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/common/pref_names.h" +#include "components/search_engines/template_url_data.h" namespace { diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc index 8dd8e65..b9f34ac 100644 --- a/chrome/browser/search_engines/template_url.cc +++ b/chrome/browser/search_engines/template_url.cc @@ -10,8 +10,6 @@ #include "base/basictypes.h" #include "base/command_line.h" #include "base/format_macros.h" -#include "base/guid.h" -#include "base/i18n/case_conversion.h" #include "base/i18n/icu_string_conversions.h" #include "base/i18n/rtl.h" #include "base/logging.h" @@ -1066,39 +1064,6 @@ std::string TemplateURLRef::HandleReplacements( } -// TemplateURLData ------------------------------------------------------------ - -TemplateURLData::TemplateURLData() - : show_in_default_list(false), - safe_for_autoreplace(false), - id(0), - date_created(base::Time::Now()), - last_modified(base::Time::Now()), - created_by_policy(false), - usage_count(0), - prepopulate_id(0), - sync_guid(base::GenerateGUID()), - keyword_(base::ASCIIToUTF16("dummy")), - url_("x") { -} - -TemplateURLData::~TemplateURLData() { -} - -void TemplateURLData::SetKeyword(const base::string16& keyword) { - DCHECK(!keyword.empty()); - - // Case sensitive keyword matching is confusing. As such, we force all - // keywords to be lower case. - keyword_ = base::i18n::ToLower(keyword); -} - -void TemplateURLData::SetURL(const std::string& url) { - DCHECK(!url.empty()); - url_ = url; -} - - // TemplateURL ---------------------------------------------------------------- TemplateURL::TemplateURL(Profile* profile, const TemplateURLData& data) diff --git a/chrome/browser/search_engines/template_url.h b/chrome/browser/search_engines/template_url.h index 29a38f6..293642d 100644 --- a/chrome/browser/search_engines/template_url.h +++ b/chrome/browser/search_engines/template_url.h @@ -13,7 +13,8 @@ #include "base/memory/scoped_ptr.h" #include "base/time/time.h" #include "chrome/browser/autocomplete/autocomplete_input.h" -#include "chrome/browser/search_engines/template_url_id.h" +#include "components/search_engines/template_url_data.h" +#include "components/search_engines/template_url_id.h" #include "ui/gfx/size.h" #include "url/gurl.h" #include "url/url_parse.h" @@ -420,114 +421,6 @@ class TemplateURLRef { }; -// TemplateURLData ------------------------------------------------------------ - -// The data for the TemplateURL. Separating this into its own class allows most -// users to do SSA-style usage of TemplateURL: construct a TemplateURLData with -// whatever fields are desired, then create an immutable TemplateURL from it. -struct TemplateURLData { - TemplateURLData(); - ~TemplateURLData(); - - // A short description of the template. This is the name we show to the user - // in various places that use TemplateURLs. For example, the location bar - // shows this when the user selects a substituting match. - base::string16 short_name; - - // The shortcut for this TemplateURL. |keyword| must be non-empty. - void SetKeyword(const base::string16& keyword); - const base::string16& keyword() const { return keyword_; } - - // The raw URL for the TemplateURL, which may not be valid as-is (e.g. because - // it requires substitutions first). This must be non-empty. - void SetURL(const std::string& url); - const std::string& url() const { return url_; } - - // Optional additional raw URLs. - std::string suggestions_url; - std::string instant_url; - std::string image_url; - std::string new_tab_url; - - // The following post_params are comma-separated lists used to specify the - // post parameters for the corresponding URL. - std::string search_url_post_params; - std::string suggestions_url_post_params; - std::string instant_url_post_params; - std::string image_url_post_params; - - // Optional favicon for the TemplateURL. - GURL favicon_url; - - // URL to the OSD file this came from. May be empty. - GURL originating_url; - - // Whether this TemplateURL is shown in the default list of search providers. - // This is just a property and does not indicate whether the TemplateURL has a - // TemplateURLRef that supports replacement. Use - // TemplateURL::ShowInDefaultList() to test both. - bool show_in_default_list; - - // Whether it's safe for auto-modification code (the autogenerator and the - // code that imports data from other browsers) to replace the TemplateURL. - // This should be set to false for any TemplateURL the user edits, or any - // TemplateURL that the user clearly manually edited in the past, like a - // bookmark keyword from another browser. - bool safe_for_autoreplace; - - // The list of supported encodings for the search terms. This may be empty, - // which indicates the terms should be encoded with UTF-8. - std::vector<std::string> input_encodings; - - // Unique identifier of this TemplateURL. The unique ID is set by the - // TemplateURLService when the TemplateURL is added to it. - TemplateURLID id; - - // Date this TemplateURL was created. - // - // NOTE: this may be 0, which indicates the TemplateURL was created before we - // started tracking creation time. - base::Time date_created; - - // The last time this TemplateURL was modified by a user, since creation. - // - // NOTE: Like date_created above, this may be 0. - base::Time last_modified; - - // True if this TemplateURL was automatically created by the administrator via - // group policy. - bool created_by_policy; - - // Number of times this TemplateURL has been explicitly used to load a URL. - // We don't increment this for uses as the "default search engine" since - // that's not really "explicit" usage and incrementing would result in pinning - // the user's default search engine(s) to the top of the list of searches on - // the New Tab page, de-emphasizing the omnibox as "where you go to search". - int usage_count; - - // If this TemplateURL comes from prepopulated data the prepopulate_id is > 0. - int prepopulate_id; - - // The primary unique identifier for Sync. This set on all TemplateURLs - // regardless of whether they have been associated with Sync. - std::string sync_guid; - - // A list of URL patterns that can be used, in addition to |url_|, to extract - // search terms from a URL. - std::vector<std::string> alternate_urls; - - // A parameter that, if present in the query or ref parameters of a search_url - // or instant_url, causes Chrome to replace the URL with the search term. - std::string search_terms_replacement_key; - - private: - // Private so we can enforce using the setters and thus enforce that these - // fields are never empty. - base::string16 keyword_; - std::string url_; -}; - - // AssociatedExtensionInfo ---------------------------------------------------- // An AssociatedExtensionInfo represents information about the extension that diff --git a/chrome/browser/search_engines/template_url_id.h b/chrome/browser/search_engines/template_url_id.h deleted file mode 100644 index 13dd862..0000000 --- a/chrome/browser/search_engines/template_url_id.h +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_ID_H_ -#define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_ID_H_ - -#include "base/basictypes.h" - -typedef int64 TemplateURLID; - -const TemplateURLID kInvalidTemplateURLID = 0; - -#endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_ID_H_ diff --git a/chrome/browser/search_engines/template_url_service.h b/chrome/browser/search_engines/template_url_service.h index c99bc88..fa3fba9 100644 --- a/chrome/browser/search_engines/template_url_service.h +++ b/chrome/browser/search_engines/template_url_service.h @@ -17,10 +17,10 @@ #include "base/observer_list.h" #include "base/prefs/pref_change_registrar.h" #include "chrome/browser/search_engines/default_search_manager.h" -#include "chrome/browser/search_engines/template_url_id.h" #include "chrome/browser/webdata/web_data_service.h" #include "components/google/core/browser/google_url_tracker.h" #include "components/keyed_service/core/keyed_service.h" +#include "components/search_engines/template_url_id.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" #include "sync/api/sync_change.h" diff --git a/chrome/browser/webdata/DEPS b/chrome/browser/webdata/DEPS index 1a1711f..3f316e7 100644 --- a/chrome/browser/webdata/DEPS +++ b/chrome/browser/webdata/DEPS @@ -38,7 +38,6 @@ specific_include_rules = { "!chrome/browser/history/history_database.h", "!chrome/browser/search_engines/search_terms_data.h", "!chrome/browser/search_engines/template_url.h", - "!chrome/browser/search_engines/template_url_id.h", "!chrome/browser/search_engines/template_url_service.h", ], diff --git a/chrome/browser/webdata/keyword_table.h b/chrome/browser/webdata/keyword_table.h index 70c1ac5..883f12f 100644 --- a/chrome/browser/webdata/keyword_table.h +++ b/chrome/browser/webdata/keyword_table.h @@ -11,7 +11,7 @@ #include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "base/strings/string16.h" -#include "chrome/browser/search_engines/template_url_id.h" +#include "components/search_engines/template_url_id.h" #include "components/webdata/common/web_database_table.h" struct TemplateURLData; diff --git a/chrome/browser/webdata/keyword_table_unittest.cc b/chrome/browser/webdata/keyword_table_unittest.cc index f2a440b..c5b91d0 100644 --- a/chrome/browser/webdata/keyword_table_unittest.cc +++ b/chrome/browser/webdata/keyword_table_unittest.cc @@ -11,8 +11,8 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" -#include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/webdata/keyword_table.h" +#include "components/search_engines/template_url_data.h" #include "components/webdata/common/web_database.h" #include "sql/statement.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/webdata/web_data_service.h b/chrome/browser/webdata/web_data_service.h index c19e22e..1ea36a4 100644 --- a/chrome/browser/webdata/web_data_service.h +++ b/chrome/browser/webdata/web_data_service.h @@ -19,8 +19,8 @@ #include "base/memory/ref_counted.h" #include "base/sequenced_task_runner_helpers.h" #include "chrome/browser/search_engines/template_url.h" -#include "chrome/browser/search_engines/template_url_id.h" #include "chrome/browser/webdata/keyword_table.h" +#include "components/search_engines/template_url_id.h" #include "components/webdata/common/web_data_results.h" #include "components/webdata/common/web_data_service_base.h" #include "components/webdata/common/web_data_service_consumer.h" diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index d141ac7d..9c86b68 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -53,6 +53,7 @@ '../components/components.gyp:precache_core', '../components/components.gyp:query_parser', '../components/components.gyp:rappor', + '../components/components.gyp:search_engines', '../components/components.gyp:search_provider_logos', '../components/components.gyp:signin_core_browser', '../components/components.gyp:startup_metric_utils', @@ -2012,7 +2013,6 @@ 'browser/search_engines/template_url_fetcher_callbacks.h', 'browser/search_engines/template_url_fetcher_factory.cc', 'browser/search_engines/template_url_fetcher_factory.h', - 'browser/search_engines/template_url_id.h', 'browser/search_engines/template_url_parser.cc', 'browser/search_engines/template_url_parser.h', 'browser/search_engines/template_url_prepopulate_data.cc', diff --git a/components/OWNERS b/components/OWNERS index 3e5a2cc..150588c 100644 --- a/components/OWNERS +++ b/components/OWNERS @@ -122,6 +122,9 @@ per-file query_parser*=droger@chromium.org per-file rappor*=asvitkine@chromium.org # OWNER-to-be: per-file rappor*=holte@chromium.org +per-file search_engines.gypi=pkasting@chromium.org +per-file search_engines.gypi=stevet@chromium.org + per-file search_provider_logos*=newt@chromium.org per-file search_provider_logos*=justincohen@chromium.org diff --git a/components/components.gyp b/components/components.gyp index c879fb6..fc6bd76 100644 --- a/components/components.gyp +++ b/components/components.gyp @@ -40,6 +40,7 @@ 'pref_registry.gypi', 'query_parser.gypi', 'rappor.gypi', + 'search_engines.gypi', 'search_provider_logos.gypi', 'signin.gypi', 'startup_metric_utils.gypi', diff --git a/components/search_engines.gypi b/components/search_engines.gypi new file mode 100644 index 0000000..3456fdd --- /dev/null +++ b/components/search_engines.gypi @@ -0,0 +1,24 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'targets': [ + { + 'target_name': 'search_engines', + 'type': 'static_library', + 'dependencies': [ + '../base/base.gyp:base', + '../url/url.gyp:url_lib', + ], + 'include_dirs': [ + '..', + ], + 'sources': [ + 'search_engines/template_url_data.cc', + 'search_engines/template_url_data.h', + 'search_engines/template_url_id.h', + ], + }, + ], +} diff --git a/components/search_engines/OWNERS b/components/search_engines/OWNERS new file mode 100644 index 0000000..c19e61b --- /dev/null +++ b/components/search_engines/OWNERS @@ -0,0 +1,2 @@ +pkasting@chromium.org +stevet@chromium.org diff --git a/components/search_engines/template_url_data.cc b/components/search_engines/template_url_data.cc new file mode 100644 index 0000000..fdbec7d --- /dev/null +++ b/components/search_engines/template_url_data.cc @@ -0,0 +1,40 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/search_engines/template_url_data.h" + +#include "base/guid.h" +#include "base/i18n/case_conversion.h" +#include "base/logging.h" +#include "base/strings/utf_string_conversions.h" + +TemplateURLData::TemplateURLData() + : show_in_default_list(false), + safe_for_autoreplace(false), + id(0), + date_created(base::Time::Now()), + last_modified(base::Time::Now()), + created_by_policy(false), + usage_count(0), + prepopulate_id(0), + sync_guid(base::GenerateGUID()), + keyword_(base::ASCIIToUTF16("dummy")), + url_("x") { +} + +TemplateURLData::~TemplateURLData() { +} + +void TemplateURLData::SetKeyword(const base::string16& keyword) { + DCHECK(!keyword.empty()); + + // Case sensitive keyword matching is confusing. As such, we force all + // keywords to be lower case. + keyword_ = base::i18n::ToLower(keyword); +} + +void TemplateURLData::SetURL(const std::string& url) { + DCHECK(!url.empty()); + url_ = url; +} diff --git a/components/search_engines/template_url_data.h b/components/search_engines/template_url_data.h new file mode 100644 index 0000000..4479e84 --- /dev/null +++ b/components/search_engines/template_url_data.h @@ -0,0 +1,121 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_DATA_H_ +#define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_DATA_H_ + +#include <string> +#include <vector> + +#include "base/strings/string16.h" +#include "base/time/time.h" +#include "components/search_engines/template_url_id.h" +#include "url/gurl.h" + +// The data for the TemplateURL. Separating this into its own class allows most +// users to do SSA-style usage of TemplateURL: construct a TemplateURLData with +// whatever fields are desired, then create an immutable TemplateURL from it. +struct TemplateURLData { + TemplateURLData(); + ~TemplateURLData(); + + // A short description of the template. This is the name we show to the user + // in various places that use TemplateURLs. For example, the location bar + // shows this when the user selects a substituting match. + base::string16 short_name; + + // The shortcut for this TemplateURL. |keyword| must be non-empty. + void SetKeyword(const base::string16& keyword); + const base::string16& keyword() const { return keyword_; } + + // The raw URL for the TemplateURL, which may not be valid as-is (e.g. because + // it requires substitutions first). This must be non-empty. + void SetURL(const std::string& url); + const std::string& url() const { return url_; } + + // Optional additional raw URLs. + std::string suggestions_url; + std::string instant_url; + std::string image_url; + std::string new_tab_url; + + // The following post_params are comma-separated lists used to specify the + // post parameters for the corresponding URL. + std::string search_url_post_params; + std::string suggestions_url_post_params; + std::string instant_url_post_params; + std::string image_url_post_params; + + // Optional favicon for the TemplateURL. + GURL favicon_url; + + // URL to the OSD file this came from. May be empty. + GURL originating_url; + + // Whether this TemplateURL is shown in the default list of search providers. + // This is just a property and does not indicate whether the TemplateURL has a + // TemplateURLRef that supports replacement. Use + // TemplateURL::ShowInDefaultList() to test both. + bool show_in_default_list; + + // Whether it's safe for auto-modification code (the autogenerator and the + // code that imports data from other browsers) to replace the TemplateURL. + // This should be set to false for any TemplateURL the user edits, or any + // TemplateURL that the user clearly manually edited in the past, like a + // bookmark keyword from another browser. + bool safe_for_autoreplace; + + // The list of supported encodings for the search terms. This may be empty, + // which indicates the terms should be encoded with UTF-8. + std::vector<std::string> input_encodings; + + // Unique identifier of this TemplateURL. The unique ID is set by the + // TemplateURLService when the TemplateURL is added to it. + TemplateURLID id; + + // Date this TemplateURL was created. + // + // NOTE: this may be 0, which indicates the TemplateURL was created before we + // started tracking creation time. + base::Time date_created; + + // The last time this TemplateURL was modified by a user, since creation. + // + // NOTE: Like date_created above, this may be 0. + base::Time last_modified; + + // True if this TemplateURL was automatically created by the administrator via + // group policy. + bool created_by_policy; + + // Number of times this TemplateURL has been explicitly used to load a URL. + // We don't increment this for uses as the "default search engine" since + // that's not really "explicit" usage and incrementing would result in pinning + // the user's default search engine(s) to the top of the list of searches on + // the New Tab page, de-emphasizing the omnibox as "where you go to search". + int usage_count; + + // If this TemplateURL comes from prepopulated data the prepopulate_id is > 0. + int prepopulate_id; + + // The primary unique identifier for Sync. This set on all TemplateURLs + // regardless of whether they have been associated with Sync. + std::string sync_guid; + + // A list of URL patterns that can be used, in addition to |url_|, to extract + // search terms from a URL. + std::vector<std::string> alternate_urls; + + // A parameter that, if present in the query or ref parameters of a search_url + // or instant_url, causes Chrome to replace the URL with the search term. + std::string search_terms_replacement_key; + + private: + // Private so we can enforce using the setters and thus enforce that these + // fields are never empty. + base::string16 keyword_; + std::string url_; +}; + +#endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_DATA_H_ diff --git a/components/search_engines/template_url_id.h b/components/search_engines/template_url_id.h new file mode 100644 index 0000000..d16f5b8 --- /dev/null +++ b/components/search_engines/template_url_id.h @@ -0,0 +1,14 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_ID_H_ +#define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_ID_H_ + +#include "base/basictypes.h" + +typedef int64 TemplateURLID; + +const TemplateURLID kInvalidTemplateURLID = 0; + +#endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_ID_H_ |