| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_UI_WEBUI_SETTINGS_SEARCH_ENGINES_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_SEARCH_ENGINES_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_SEARCH_ENGINES_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_SEARCH_ENGINES_HANDLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "chrome/browser/ui/search_engines/edit_search_engine_controller.h" | 11 #include "chrome/browser/ui/search_engines/edit_search_engine_controller.h" |
| 12 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" |
| 12 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" | 13 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" |
| 13 #include "ui/base/models/table_model_observer.h" | 14 #include "ui/base/models/table_model_observer.h" |
| 14 | 15 |
| 15 class KeywordEditorController; | |
| 16 class Profile; | 16 class Profile; |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 class Extension; | 19 class Extension; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace settings { | 22 namespace settings { |
| 23 | 23 |
| 24 class SearchEnginesHandler : public SettingsPageUIHandler, | 24 class SearchEnginesHandler : public SettingsPageUIHandler, |
| 25 public ui::TableModelObserver, | 25 public ui::TableModelObserver, |
| 26 public EditSearchEngineControllerDelegate { | 26 public EditSearchEngineControllerDelegate { |
| 27 public: | 27 public: |
| 28 explicit SearchEnginesHandler(Profile* profile); | 28 explicit SearchEnginesHandler(Profile* profile); |
| 29 ~SearchEnginesHandler() override; | 29 ~SearchEnginesHandler() override; |
| 30 | 30 |
| 31 // ui::TableModelObserver implementation. | 31 // ui::TableModelObserver implementation. |
| 32 void OnModelChanged() override; | 32 void OnModelChanged() override; |
| 33 void OnItemsChanged(int start, int length) override; | 33 void OnItemsChanged(int start, int length) override; |
| 34 void OnItemsAdded(int start, int length) override; | 34 void OnItemsAdded(int start, int length) override; |
| 35 void OnItemsRemoved(int start, int length) override; | 35 void OnItemsRemoved(int start, int length) override; |
| 36 | 36 |
| 37 // EditSearchEngineControllerDelegate implementation. | 37 // EditSearchEngineControllerDelegate implementation. |
| 38 void OnEditedKeyword(TemplateURL* template_url, | 38 void OnEditedKeyword(TemplateURL* template_url, |
| 39 const base::string16& title, | 39 const base::string16& title, |
| 40 const base::string16& keyword, | 40 const base::string16& keyword, |
| 41 const std::string& url) override; | 41 const std::string& url) override; |
| 42 | 42 |
| 43 // SettingsPageUIHandler implementation. |
| 43 void RegisterMessages() override; | 44 void RegisterMessages() override; |
| 45 void OnJavascriptAllowed() override; |
| 46 void OnJavascriptDisallowed() override; |
| 44 | 47 |
| 45 private: | 48 private: |
| 46 std::unique_ptr<KeywordEditorController> list_controller_; | |
| 47 std::unique_ptr<EditSearchEngineController> edit_controller_; | |
| 48 | |
| 49 // Retrieves all search engines and returns the to WebUI. | 49 // Retrieves all search engines and returns the to WebUI. |
| 50 void HandleGetSearchEnginesList(const base::ListValue* args); | 50 void HandleGetSearchEnginesList(const base::ListValue* args); |
| 51 | 51 |
| 52 std::unique_ptr<base::DictionaryValue> GetSearchEnginesList(); | 52 std::unique_ptr<base::DictionaryValue> GetSearchEnginesList(); |
| 53 | 53 |
| 54 // Removes the search engine at the given index. Called from WebUI. | 54 // Removes the search engine at the given index. Called from WebUI. |
| 55 void HandleRemoveSearchEngine(const base::ListValue* args); | 55 void HandleRemoveSearchEngine(const base::ListValue* args); |
| 56 | 56 |
| 57 // Sets the search engine at the given index to be default. Called from WebUI. | 57 // Sets the search engine at the given index to be default. Called from WebUI. |
| 58 void HandleSetDefaultSearchEngine(const base::ListValue* args); | 58 void HandleSetDefaultSearchEngine(const base::ListValue* args); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 84 | 84 |
| 85 // Returns a dictionary to pass to WebUI representing the given search engine. | 85 // Returns a dictionary to pass to WebUI representing the given search engine. |
| 86 base::DictionaryValue* CreateDictionaryForEngine(int index, bool is_default); | 86 base::DictionaryValue* CreateDictionaryForEngine(int index, bool is_default); |
| 87 | 87 |
| 88 // Returns a dictionary to pass to WebUI representing the extension. | 88 // Returns a dictionary to pass to WebUI representing the extension. |
| 89 base::DictionaryValue* CreateDictionaryForExtension( | 89 base::DictionaryValue* CreateDictionaryForExtension( |
| 90 const extensions::Extension& extension); | 90 const extensions::Extension& extension); |
| 91 | 91 |
| 92 Profile* const profile_; | 92 Profile* const profile_; |
| 93 | 93 |
| 94 KeywordEditorController list_controller_; |
| 95 std::unique_ptr<EditSearchEngineController> edit_controller_; |
| 96 |
| 94 DISALLOW_COPY_AND_ASSIGN(SearchEnginesHandler); | 97 DISALLOW_COPY_AND_ASSIGN(SearchEnginesHandler); |
| 95 }; | 98 }; |
| 96 | 99 |
| 97 } // namespace settings | 100 } // namespace settings |
| 98 | 101 |
| 99 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SEARCH_ENGINES_HANDLER_H_ | 102 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SEARCH_ENGINES_HANDLER_H_ |
| OLD | NEW |