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

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

Issue 2529543002: MD Settings: indicate extension controlled search engines (Closed)
Patch Set: merge Created 4 years 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 #include "chrome/browser/ui/webui/settings/search_engines_handler.h" 5 #include "chrome/browser/ui/webui/settings/search_engines_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
22 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
23 #include "chrome/grit/generated_resources.h" 23 #include "chrome/grit/generated_resources.h"
24 #include "components/prefs/pref_service.h" 24 #include "components/prefs/pref_service.h"
25 #include "components/search_engines/template_url.h" 25 #include "components/search_engines/template_url.h"
26 #include "components/search_engines/template_url_service.h" 26 #include "components/search_engines/template_url_service.h"
27 #include "components/signin/core/browser/signin_manager.h" 27 #include "components/signin/core/browser/signin_manager.h"
28 #include "content/public/browser/user_metrics.h" 28 #include "content/public/browser/user_metrics.h"
29 #include "content/public/browser/web_ui.h" 29 #include "content/public/browser/web_ui.h"
30 #include "extensions/browser/extension_registry.h" 30 #include "extensions/browser/extension_registry.h"
31 #include "extensions/browser/extension_system.h"
32 #include "extensions/browser/management_policy.h"
31 #include "extensions/common/extension.h" 33 #include "extensions/common/extension.h"
32 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
33 35
34 namespace { 36 namespace {
35 // The following strings need to match with the IDs of the paper-input elements 37 // The following strings need to match with the IDs of the paper-input elements
36 // at settings/search_engines_page/add_search_engine_dialog.html. 38 // at settings/search_engines_page/add_search_engine_dialog.html.
37 const char kSearchEngineField[] = "searchEngine"; 39 const char kSearchEngineField[] = "searchEngine";
38 const char kKeywordField[] = "keyword"; 40 const char kKeywordField[] = "keyword";
39 const char kQueryUrlField[] = "queryUrl"; 41 const char kQueryUrlField[] = "queryUrl";
40 42
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // in @typedef for SearchEngine. Please update it whenever you add or remove 210 // in @typedef for SearchEngine. Please update it whenever you add or remove
209 // any keys here. 211 // any keys here.
210 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 212 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
211 dict->SetString("name", template_url->short_name()); 213 dict->SetString("name", template_url->short_name());
212 dict->SetString("displayName", 214 dict->SetString("displayName",
213 table_model->GetText( 215 table_model->GetText(
214 index, IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN)); 216 index, IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN));
215 dict->SetString( 217 dict->SetString(
216 "keyword", 218 "keyword",
217 table_model->GetText(index, IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN)); 219 table_model->GetText(index, IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN));
218 dict->SetString("url", 220 Profile* profile = Profile::FromWebUI(web_ui());
219 template_url->url_ref().DisplayURL( 221 dict->SetString("url", template_url->url_ref().DisplayURL(
220 UIThreadSearchTermsData(Profile::FromWebUI(web_ui())))); 222 UIThreadSearchTermsData(profile)));
221 dict->SetBoolean("urlLocked", template_url->prepopulate_id() > 0); 223 dict->SetBoolean("urlLocked", template_url->prepopulate_id() > 0);
222 GURL icon_url = template_url->favicon_url(); 224 GURL icon_url = template_url->favicon_url();
223 if (icon_url.is_valid()) 225 if (icon_url.is_valid())
224 dict->SetString("iconURL", icon_url.spec()); 226 dict->SetString("iconURL", icon_url.spec());
225 dict->SetInteger("modelIndex", index); 227 dict->SetInteger("modelIndex", index);
226 228
227 dict->SetBoolean("canBeRemoved", list_controller_.CanRemove(template_url)); 229 dict->SetBoolean("canBeRemoved", list_controller_.CanRemove(template_url));
228 dict->SetBoolean("canBeDefault", 230 dict->SetBoolean("canBeDefault",
229 list_controller_.CanMakeDefault(template_url)); 231 list_controller_.CanMakeDefault(template_url));
230 dict->SetBoolean("default", is_default); 232 dict->SetBoolean("default", is_default);
231 dict->SetBoolean("canBeEdited", list_controller_.CanEdit(template_url)); 233 dict->SetBoolean("canBeEdited", list_controller_.CanEdit(template_url));
232 TemplateURL::Type type = template_url->type(); 234 TemplateURL::Type type = template_url->type();
233 dict->SetBoolean("isOmniboxExtension", 235 dict->SetBoolean("isOmniboxExtension",
234 type == TemplateURL::OMNIBOX_API_EXTENSION); 236 type == TemplateURL::OMNIBOX_API_EXTENSION);
235 if (type == TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION || 237 if (type == TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION ||
236 type == TemplateURL::OMNIBOX_API_EXTENSION) { 238 type == TemplateURL::OMNIBOX_API_EXTENSION) {
237 const extensions::Extension* extension = 239 const extensions::Extension* extension =
238 extensions::ExtensionRegistry::Get(Profile::FromWebUI(web_ui())) 240 extensions::ExtensionRegistry::Get(profile)->GetExtensionById(
239 ->GetExtensionById(template_url->GetExtensionId(), 241 template_url->GetExtensionId(),
240 extensions::ExtensionRegistry::EVERYTHING); 242 extensions::ExtensionRegistry::EVERYTHING);
241 if (extension) { 243 if (extension) {
242 dict->Set("extension", 244 std::unique_ptr<base::DictionaryValue> ext_info =
243 extensions::util::GetExtensionInfo(extension).release()); 245 extensions::util::GetExtensionInfo(extension);
246 ext_info->SetBoolean("canBeDisabled",
247 !extensions::ExtensionSystem::Get(profile)
248 ->management_policy()
249 ->MustRemainEnabled(extension, nullptr));
250 dict->Set("extension", ext_info.release());
244 } 251 }
245 } 252 }
246 return dict; 253 return dict;
247 } 254 }
248 255
249 void SearchEnginesHandler::HandleGetSearchEnginesList( 256 void SearchEnginesHandler::HandleGetSearchEnginesList(
250 const base::ListValue* args) { 257 const base::ListValue* args) {
251 CHECK_EQ(1U, args->GetSize()); 258 CHECK_EQ(1U, args->GetSize());
252 const base::Value* callback_id; 259 const base::Value* callback_id;
253 CHECK(args->Get(0, &callback_id)); 260 CHECK(args->Get(0, &callback_id));
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 bool logging_enabled = 531 bool logging_enabled =
525 profile_->GetPrefs()->GetBoolean(prefs::kHotwordAudioLoggingEnabled); 532 profile_->GetPrefs()->GetBoolean(prefs::kHotwordAudioLoggingEnabled);
526 launch_mode = logging_enabled ? HotwordService::HOTWORD_ONLY 533 launch_mode = logging_enabled ? HotwordService::HOTWORD_ONLY
527 : HotwordService::HOTWORD_AND_AUDIO_HISTORY; 534 : HotwordService::HOTWORD_AND_AUDIO_HISTORY;
528 } 535 }
529 hotword_service->OptIntoHotwording(launch_mode); 536 hotword_service->OptIntoHotwording(launch_mode);
530 SendHotwordInfo(); 537 SendHotwordInfo();
531 } 538 }
532 539
533 } // namespace settings 540 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698