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_TEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_ |
6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_ | 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "components/search_engines/template_url.h" | |
16 #include "components/search_engines/template_url_data.h" | 15 #include "components/search_engines/template_url_data.h" |
17 #include "components/search_engines/template_url_service_observer.h" | 16 #include "components/search_engines/template_url_service_observer.h" |
18 | 17 |
19 class GURL; | 18 class GURL; |
20 class KeywordWebDataService; | 19 class KeywordWebDataService; |
21 class TemplateURLService; | 20 class TemplateURLService; |
22 class TestingProfile; | 21 class TestingProfile; |
23 class TestingSearchTermsData; | 22 class TestingSearchTermsData; |
24 | 23 |
25 // Sets the managed preferences for the default search provider. | 24 // Sets the managed preferences for the default search provider. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Creates a new TemplateURLService. | 58 // Creates a new TemplateURLService. |
60 void ResetModel(bool verify_load); | 59 void ResetModel(bool verify_load); |
61 | 60 |
62 // Returns the search term from the last invocation of | 61 // Returns the search term from the last invocation of |
63 // TemplateURLService::SetKeywordSearchTermsForURL and clears the search term. | 62 // TemplateURLService::SetKeywordSearchTermsForURL and clears the search term. |
64 base::string16 GetAndClearSearchTerm(); | 63 base::string16 GetAndClearSearchTerm(); |
65 | 64 |
66 // Sets the google base url. |base_url| must be valid. | 65 // Sets the google base url. |base_url| must be valid. |
67 void SetGoogleBaseURL(const GURL& base_url); | 66 void SetGoogleBaseURL(const GURL& base_url); |
68 | 67 |
69 // Adds extension controlled TemplateURL to the model and overrides default | |
70 // search pref in an extension controlled preferences, if extension wants to | |
71 // be default. | |
72 TemplateURL* AddExtensionControlledTURL( | |
73 std::unique_ptr<TemplateURL> extension_turl, | |
74 std::unique_ptr<TemplateURL::AssociatedExtensionInfo> info); | |
75 | |
76 // Removes a TemplateURL controlled by |extension_id| from the model, and, | |
77 // if necessary, from the extension-controlled default search preference. | |
78 // This TemplateURL must exist. | |
79 void RemoveExtensionControlledTURL(const std::string& extension_id); | |
80 | |
81 KeywordWebDataService* web_data_service() { return web_data_service_.get(); } | 68 KeywordWebDataService* web_data_service() { return web_data_service_.get(); } |
82 TemplateURLService* model() { return model_.get(); } | 69 TemplateURLService* model() { return model_.get(); } |
83 TestingProfile* profile() { return profile_.get(); } | 70 TestingProfile* profile() { return profile_.get(); } |
84 | 71 |
85 private: | 72 private: |
86 std::unique_ptr<TestingProfile> profile_; | 73 std::unique_ptr<TestingProfile> profile_; |
87 base::ScopedTempDir temp_dir_; | 74 base::ScopedTempDir temp_dir_; |
88 int changed_count_; | 75 int changed_count_; |
89 base::string16 search_term_; | 76 base::string16 search_term_; |
90 scoped_refptr<KeywordWebDataService> web_data_service_; | 77 scoped_refptr<KeywordWebDataService> web_data_service_; |
91 TestingSearchTermsData* search_terms_data_; | 78 TestingSearchTermsData* search_terms_data_; |
92 std::unique_ptr<TemplateURLService> model_; | 79 std::unique_ptr<TemplateURLService> model_; |
93 | 80 |
94 DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceTestUtil); | 81 DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceTestUtil); |
95 }; | 82 }; |
96 | 83 |
97 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_ | 84 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_ |
OLD | NEW |