Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: chrome/browser/ui/webui/settings/search_engines_handler.h

Issue 2507363002: MD Settings: Add Hotword (OK Google) section to search_page (Closed)
Patch Set: Self Review Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/memory/weak_ptr.h"
11 #include "chrome/browser/ui/search_engines/edit_search_engine_controller.h" 12 #include "chrome/browser/ui/search_engines/edit_search_engine_controller.h"
12 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" 13 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h"
13 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" 14 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
15 #include "components/prefs/pref_change_registrar.h"
14 #include "ui/base/models/table_model_observer.h" 16 #include "ui/base/models/table_model_observer.h"
15 17
16 class Profile; 18 class Profile;
17 19
20 namespace base {
21 class DictionaryValue;
22 class ListValue;
23 class Value;
24 }
25
18 namespace extensions { 26 namespace extensions {
19 class Extension; 27 class Extension;
20 } 28 }
21 29
22 namespace settings { 30 namespace settings {
23 31
24 class SearchEnginesHandler : public SettingsPageUIHandler, 32 class SearchEnginesHandler : public SettingsPageUIHandler,
25 public ui::TableModelObserver, 33 public ui::TableModelObserver,
26 public EditSearchEngineControllerDelegate { 34 public EditSearchEngineControllerDelegate {
27 public: 35 public:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 72
65 // Validates the given search engine values, and reports the results back 73 // Validates the given search engine values, and reports the results back
66 // to WebUI. Called from WebUI. 74 // to WebUI. Called from WebUI.
67 void HandleValidateSearchEngineInput(const base::ListValue* args); 75 void HandleValidateSearchEngineInput(const base::ListValue* args);
68 76
69 // Checks whether the given user input field (searchEngine, keyword, queryUrl) 77 // Checks whether the given user input field (searchEngine, keyword, queryUrl)
70 // is populated with a valid value. 78 // is populated with a valid value.
71 bool CheckFieldValidity(const std::string& field_name, 79 bool CheckFieldValidity(const std::string& field_name,
72 const std::string& field_value); 80 const std::string& field_value);
73 81
74 // Called when an edit is cancelled. 82 // Called when an edit is canceled.
75 // Called from WebUI. 83 // Called from WebUI.
76 void HandleSearchEngineEditCancelled(const base::ListValue* args); 84 void HandleSearchEngineEditCancelled(const base::ListValue* args);
77 85
78 // Called when an edit is finished and should be saved. 86 // Called when an edit is finished and should be saved.
79 // Called from WebUI. 87 // Called from WebUI.
80 void HandleSearchEngineEditCompleted(const base::ListValue* args); 88 void HandleSearchEngineEditCompleted(const base::ListValue* args);
81 89
82 // Returns a dictionary to pass to WebUI representing the given search engine. 90 // Returns a dictionary to pass to WebUI representing the given search engine.
83 std::unique_ptr<base::DictionaryValue> CreateDictionaryForEngine( 91 std::unique_ptr<base::DictionaryValue> CreateDictionaryForEngine(
84 int index, 92 int index,
85 bool is_default); 93 bool is_default);
86 94
87 // Returns a dictionary to pass to WebUI representing the extension. 95 // Returns a dictionary to pass to WebUI representing the extension.
88 base::DictionaryValue* CreateDictionaryForExtension( 96 base::DictionaryValue* CreateDictionaryForExtension(
89 const extensions::Extension& extension); 97 const extensions::Extension& extension);
90 98
99 // WebUI call to request a dictionary of hotword related properties.
100 void HandleGetHotwordInfo(const base::ListValue* args);
101
102 // Constructs a SearchPageHotwordInfo dictionary.
103 std::unique_ptr<base::DictionaryValue> GetHotwordInfo();
104
105 // Callback for HotwordService::AudioHistoryHandler::GetAudioHistoryEnabled.
106 void OnGetHotwordAudioHistoryEnabled(
107 std::unique_ptr<base::Value> callback_id,
108 std::unique_ptr<base::DictionaryValue> status,
109 bool success,
110 bool logging_enabled);
111
112 // Calls either ResolveJavascriptCallback or CallJavascriptFunction.
113 void HotwordInfoComplete(const base::Value* callback_id,
114 const base::DictionaryValue& status);
115
116 // Calls WebUI to send hotword search info updates.
117 void SendHotwordInfo();
118
119 // WebUI call to enable hotword search.
120 void HandleSetHotwordSearchEnabled(const base::ListValue* args);
121
91 Profile* const profile_; 122 Profile* const profile_;
92 123
93 KeywordEditorController list_controller_; 124 KeywordEditorController list_controller_;
94 std::unique_ptr<EditSearchEngineController> edit_controller_; 125 std::unique_ptr<EditSearchEngineController> edit_controller_;
126 PrefChangeRegistrar pref_change_registrar_;
127 base::WeakPtrFactory<SearchEnginesHandler> weak_ptr_factory_;
95 128
96 DISALLOW_COPY_AND_ASSIGN(SearchEnginesHandler); 129 DISALLOW_COPY_AND_ASSIGN(SearchEnginesHandler);
97 }; 130 };
98 131
99 } // namespace settings 132 } // namespace settings
100 133
101 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SEARCH_ENGINES_HANDLER_H_ 134 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SEARCH_ENGINES_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698