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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_SEARCH_ENGINE_MANAGER_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_SEARCH_ENGINE_MANAGER_HANDLER_H_
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"
12 class KeywordEditorController
;
14 namespace extensions
{
20 class SearchEngineManagerHandler
: public OptionsPageUIHandler
,
21 public ui::TableModelObserver
,
22 public EditSearchEngineControllerDelegate
{
24 SearchEngineManagerHandler();
25 ~SearchEngineManagerHandler() override
;
27 // OptionsPageUIHandler implementation.
28 void GetLocalizedValues(base::DictionaryValue
* localized_strings
) override
;
29 void InitializeHandler() override
;
30 void InitializePage() override
;
32 // ui::TableModelObserver implementation.
33 void OnModelChanged() override
;
34 void OnItemsChanged(int start
, int length
) override
;
35 void OnItemsAdded(int start
, int length
) override
;
36 void OnItemsRemoved(int start
, int length
) override
;
38 // EditSearchEngineControllerDelegate implementation.
39 void OnEditedKeyword(TemplateURL
* template_url
,
40 const base::string16
& title
,
41 const base::string16
& keyword
,
42 const std::string
& url
) override
;
44 void RegisterMessages() override
;
47 scoped_ptr
<KeywordEditorController
> list_controller_
;
48 scoped_ptr
<EditSearchEngineController
> edit_controller_
;
50 // Removes the search engine at the given index. Called from WebUI.
51 void RemoveSearchEngine(const base::ListValue
* args
);
53 // Sets the search engine at the given index to be default. Called from WebUI.
54 void SetDefaultSearchEngine(const base::ListValue
* args
);
56 // Starts an edit session for the search engine at the given index. If the
57 // index is -1, starts editing a new search engine instead of an existing one.
59 void EditSearchEngine(const base::ListValue
* args
);
61 // Validates the given search engine values, and reports the results back
62 // to WebUI. Called from WebUI.
63 void CheckSearchEngineInfoValidity(const base::ListValue
* args
);
65 // Called when an edit is cancelled.
67 void EditCancelled(const base::ListValue
* args
);
69 // Called when an edit is finished and should be saved.
71 void EditCompleted(const base::ListValue
* args
);
73 // Returns a dictionary to pass to WebUI representing the given search engine.
74 base::DictionaryValue
* CreateDictionaryForEngine(int index
, bool is_default
);
76 // Returns a dictionary to pass to WebUI representing the extension.
77 base::DictionaryValue
* CreateDictionaryForExtension(
78 const extensions::Extension
& extension
);
80 DISALLOW_COPY_AND_ASSIGN(SearchEngineManagerHandler
);
83 } // namespace options
85 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_SEARCH_ENGINE_MANAGER_HANDLER_H_