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_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 protected: | 328 protected: |
329 // Cover method for the method of the same name on the HistoryService. | 329 // Cover method for the method of the same name on the HistoryService. |
330 // url is the one that was visited with the given search terms. | 330 // url is the one that was visited with the given search terms. |
331 // | 331 // |
332 // This exists and is virtual for testing. | 332 // This exists and is virtual for testing. |
333 virtual void SetKeywordSearchTermsForURL(const TemplateURL* t_url, | 333 virtual void SetKeywordSearchTermsForURL(const TemplateURL* t_url, |
334 const GURL& url, | 334 const GURL& url, |
335 const string16& term); | 335 const string16& term); |
336 | 336 |
337 private: | 337 private: |
338 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, BuildQueryTerms); | |
339 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, TestManagedDefaultSearch); | 338 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, TestManagedDefaultSearch); |
340 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, | 339 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, |
341 UpdateKeywordSearchTermsForURL); | 340 UpdateKeywordSearchTermsForURL); |
342 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, | 341 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, |
343 DontUpdateKeywordSearchForNonReplaceable); | 342 DontUpdateKeywordSearchForNonReplaceable); |
344 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, ChangeGoogleBaseValue); | 343 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, ChangeGoogleBaseValue); |
345 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, MergeDeletesUnusedProviders); | 344 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, MergeDeletesUnusedProviders); |
346 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, | 345 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, |
347 CreateSyncDataFromTemplateURL); | 346 CreateSyncDataFromTemplateURL); |
348 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, | 347 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 | 457 |
459 // Iterates through the TemplateURLs to see if one matches the visited url. | 458 // Iterates through the TemplateURLs to see if one matches the visited url. |
460 // For each TemplateURL whose url matches the visited url | 459 // For each TemplateURL whose url matches the visited url |
461 // SetKeywordSearchTermsForURL is invoked. | 460 // SetKeywordSearchTermsForURL is invoked. |
462 void UpdateKeywordSearchTermsForURL( | 461 void UpdateKeywordSearchTermsForURL( |
463 const history::URLVisitedDetails& details); | 462 const history::URLVisitedDetails& details); |
464 | 463 |
465 // If necessary, generates a visit for the site http:// + t_url.keyword(). | 464 // If necessary, generates a visit for the site http:// + t_url.keyword(). |
466 void AddTabToSearchVisit(const TemplateURL& t_url); | 465 void AddTabToSearchVisit(const TemplateURL& t_url); |
467 | 466 |
468 // Adds each of the query terms in the specified url whose key and value are | |
469 // non-empty to query_terms. If a query key appears multiple times, the value | |
470 // is set to an empty string. Returns true if there is at least one key that | |
471 // does not occur multiple times. | |
472 static bool BuildQueryTerms( | |
473 const GURL& url, | |
474 std::map<std::string, std::string>* query_terms); | |
475 | |
476 // Invoked when the Google base URL has changed. Updates the mapping for all | 467 // Invoked when the Google base URL has changed. Updates the mapping for all |
477 // TemplateURLs that have a replacement term of {google:baseURL} or | 468 // TemplateURLs that have a replacement term of {google:baseURL} or |
478 // {google:baseSuggestURL}. | 469 // {google:baseSuggestURL}. |
479 void GoogleBaseURLChanged(const GURL& old_base_url); | 470 void GoogleBaseURLChanged(const GURL& old_base_url); |
480 | 471 |
481 // Update the default search. Called at initialization or when a managed | 472 // Update the default search. Called at initialization or when a managed |
482 // preference has changed. | 473 // preference has changed. |
483 void UpdateDefaultSearch(); | 474 void UpdateDefaultSearch(); |
484 | 475 |
485 // Set the default search provider even if it is managed. |url| may be null. | 476 // Set the default search provider even if it is managed. |url| may be null. |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 | 667 |
677 // This is used to log the origin of changes to the default search provider. | 668 // This is used to log the origin of changes to the default search provider. |
678 // We set this value to increasingly specific values when we know what is the | 669 // We set this value to increasingly specific values when we know what is the |
679 // cause/origin of a default search change. | 670 // cause/origin of a default search change. |
680 DefaultSearchChangeOrigin dsp_change_origin_; | 671 DefaultSearchChangeOrigin dsp_change_origin_; |
681 | 672 |
682 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); | 673 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); |
683 }; | 674 }; |
684 | 675 |
685 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 676 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
OLD | NEW |