Chromium Code Reviews| 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" | |
| 15 #include "components/search_engines/template_url_data.h" | 16 #include "components/search_engines/template_url_data.h" |
| 16 #include "components/search_engines/template_url_service_observer.h" | 17 #include "components/search_engines/template_url_service_observer.h" |
| 17 | 18 |
| 19 class ExtensionPrefValueMap; | |
| 18 class GURL; | 20 class GURL; |
| 19 class KeywordWebDataService; | 21 class KeywordWebDataService; |
| 20 class TemplateURLService; | 22 class TemplateURLService; |
| 21 class TestingProfile; | 23 class TestingProfile; |
| 22 class TestingSearchTermsData; | 24 class TestingSearchTermsData; |
| 23 | 25 |
| 24 // Sets the managed preferences for the default search provider. | 26 // Sets the managed preferences for the default search provider. |
| 25 // enabled arg enables/disables use of managed engine by DefaultSearchManager. | 27 // enabled arg enables/disables use of managed engine by DefaultSearchManager. |
| 26 void SetManagedDefaultSearchPreferences(const TemplateURLData& managed_data, | 28 void SetManagedDefaultSearchPreferences(const TemplateURLData& managed_data, |
| 27 bool enabled, | 29 bool enabled, |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 58 // Creates a new TemplateURLService. | 60 // Creates a new TemplateURLService. |
| 59 void ResetModel(bool verify_load); | 61 void ResetModel(bool verify_load); |
| 60 | 62 |
| 61 // Returns the search term from the last invocation of | 63 // Returns the search term from the last invocation of |
| 62 // TemplateURLService::SetKeywordSearchTermsForURL and clears the search term. | 64 // TemplateURLService::SetKeywordSearchTermsForURL and clears the search term. |
| 63 base::string16 GetAndClearSearchTerm(); | 65 base::string16 GetAndClearSearchTerm(); |
| 64 | 66 |
| 65 // Sets the google base url. |base_url| must be valid. | 67 // Sets the google base url. |base_url| must be valid. |
| 66 void SetGoogleBaseURL(const GURL& base_url); | 68 void SetGoogleBaseURL(const GURL& base_url); |
| 67 | 69 |
| 70 // Write DSE into extension controlled preference in test profile. | |
|
vasilii
2016/12/06 19:16:42
Please expand the DSE.
Alexander Yashkin
2016/12/09 08:19:52
Done
| |
| 71 void SetExtensionDefaultSearchInPrefs(const std::string& ext_id, | |
| 72 const TemplateURLData& ext_data); | |
| 73 // Remove extension controlled DSE preference from test profile. | |
| 74 void RemoveExtensionDefaultSearchFromPrefs(const std::string& ext_id); | |
| 75 | |
| 76 // Add extension turl to model and override default search preference if | |
| 77 // extension wants to be default. | |
| 78 TemplateURL* AddExtensionControlledTURL( | |
| 79 std::unique_ptr<TemplateURL> ext_dse, | |
| 80 std::unique_ptr<TemplateURL::AssociatedExtensionInfo> ext_info); | |
| 81 // Remove extension turl from preferences and model. | |
| 82 void RemoveExtensionControlledTURL(const std::string& ext_id); | |
| 83 | |
| 68 KeywordWebDataService* web_data_service() { return web_data_service_.get(); } | 84 KeywordWebDataService* web_data_service() { return web_data_service_.get(); } |
| 69 TemplateURLService* model() { return model_.get(); } | 85 TemplateURLService* model() { return model_.get(); } |
| 70 TestingProfile* profile() { return profile_.get(); } | 86 TestingProfile* profile() { return profile_.get(); } |
| 71 | 87 |
| 72 private: | 88 private: |
| 73 std::unique_ptr<TestingProfile> profile_; | 89 std::unique_ptr<TestingProfile> profile_; |
| 74 base::ScopedTempDir temp_dir_; | 90 base::ScopedTempDir temp_dir_; |
| 75 int changed_count_; | 91 int changed_count_; |
| 76 base::string16 search_term_; | 92 base::string16 search_term_; |
| 77 scoped_refptr<KeywordWebDataService> web_data_service_; | 93 scoped_refptr<KeywordWebDataService> web_data_service_; |
| 78 TestingSearchTermsData* search_terms_data_; | 94 TestingSearchTermsData* search_terms_data_; |
| 79 std::unique_ptr<TemplateURLService> model_; | 95 std::unique_ptr<TemplateURLService> model_; |
| 96 std::unique_ptr<ExtensionPrefValueMap> ext_pref_map_; | |
| 80 | 97 |
| 81 DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceTestUtil); | 98 DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceTestUtil); |
| 82 }; | 99 }; |
| 83 | 100 |
| 84 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_ | 101 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_ |
| OLD | NEW |