| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_SEARCH_ENGINE_MANAGER_HANDLER_H_ | |
| 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_SEARCH_ENGINE_MANAGER_HANDLER_H_ | |
| 7 | |
| 8 #include "chrome/browser/ui/search_engines/edit_search_engine_controller.h" | |
| 9 #include "chrome/browser/ui/webui/options2/options_ui.h" | |
| 10 #include "ui/base/models/table_model_observer.h" | |
| 11 | |
| 12 class KeywordEditorController; | |
| 13 | |
| 14 namespace extensions { | |
| 15 class Extension; | |
| 16 } | |
| 17 | |
| 18 namespace options { | |
| 19 | |
| 20 class SearchEngineManagerHandler : public OptionsPageUIHandler, | |
| 21 public ui::TableModelObserver, | |
| 22 public EditSearchEngineControllerDelegate { | |
| 23 public: | |
| 24 SearchEngineManagerHandler(); | |
| 25 virtual ~SearchEngineManagerHandler(); | |
| 26 | |
| 27 // OptionsPageUIHandler implementation. | |
| 28 virtual void GetLocalizedValues( | |
| 29 base::DictionaryValue* localized_strings) OVERRIDE; | |
| 30 virtual void InitializeHandler() OVERRIDE; | |
| 31 virtual void InitializePage() OVERRIDE; | |
| 32 | |
| 33 // ui::TableModelObserver implementation. | |
| 34 virtual void OnModelChanged() OVERRIDE; | |
| 35 virtual void OnItemsChanged(int start, int length) OVERRIDE; | |
| 36 virtual void OnItemsAdded(int start, int length) OVERRIDE; | |
| 37 virtual void OnItemsRemoved(int start, int length) OVERRIDE; | |
| 38 | |
| 39 // EditSearchEngineControllerDelegate implementation. | |
| 40 virtual void OnEditedKeyword(TemplateURL* template_url, | |
| 41 const string16& title, | |
| 42 const string16& keyword, | |
| 43 const std::string& url) OVERRIDE; | |
| 44 | |
| 45 virtual void RegisterMessages() OVERRIDE; | |
| 46 | |
| 47 private: | |
| 48 scoped_ptr<KeywordEditorController> list_controller_; | |
| 49 scoped_ptr<EditSearchEngineController> edit_controller_; | |
| 50 | |
| 51 // Removes the search engine at the given index. Called from WebUI. | |
| 52 void RemoveSearchEngine(const base::ListValue* args); | |
| 53 | |
| 54 // Sets the search engine at the given index to be default. Called from WebUI. | |
| 55 void SetDefaultSearchEngine(const base::ListValue* args); | |
| 56 | |
| 57 // Starts an edit session for the search engine at the given index. If the | |
| 58 // index is -1, starts editing a new search engine instead of an existing one. | |
| 59 // Called from WebUI. | |
| 60 void EditSearchEngine(const base::ListValue* args); | |
| 61 | |
| 62 // Validates the given search engine values, and reports the results back | |
| 63 // to WebUI. Called from WebUI. | |
| 64 void CheckSearchEngineInfoValidity(const base::ListValue* args); | |
| 65 | |
| 66 // Called when an edit is cancelled. | |
| 67 // Called from WebUI. | |
| 68 void EditCancelled(const base::ListValue* args); | |
| 69 | |
| 70 // Called when an edit is finished and should be saved. | |
| 71 // Called from WebUI. | |
| 72 void EditCompleted(const base::ListValue* args); | |
| 73 | |
| 74 // Returns a dictionary to pass to WebUI representing the given search engine. | |
| 75 base::DictionaryValue* CreateDictionaryForEngine(int index, bool is_default); | |
| 76 | |
| 77 // Returns a dictionary to pass to WebUI representing the extension. | |
| 78 base::DictionaryValue* CreateDictionaryForExtension( | |
| 79 const extensions::Extension& extension); | |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(SearchEngineManagerHandler); | |
| 82 }; | |
| 83 | |
| 84 } // namespace options | |
| 85 | |
| 86 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_SEARCH_ENGINE_MANAGER_HANDLER_H_ | |
| OLD | NEW |