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