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

Unified Diff: chrome/browser/resources/settings/search_page/search_page.js

Issue 1096143003: Add chrome.searchEnginesPrivate API and Search Settings page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a test Created 5 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/search_page/search_page.js
diff --git a/chrome/browser/resources/settings/search_page/search_page.js b/chrome/browser/resources/settings/search_page/search_page.js
new file mode 100644
index 0000000000000000000000000000000000000000..aeb49a9bac9d13bfc9f1fb714662c81e1438fd4e
--- /dev/null
+++ b/chrome/browser/resources/settings/search_page/search_page.js
@@ -0,0 +1,109 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview
+ * 'cr-settings-search-page' is the settings page containing search settings.
+ *
+ * Example:
+ *
+ * <core-animated-pages>
+ * <cr-settings-search-page prefs="{{prefs}}"></cr-settings-search-page>
+ * ... other pages ...
+ * </core-animated-pages>
+ *
+ * @group Chrome Settings Elements
+ * @element cr-settings-search-page
+ */
+Polymer('cr-settings-search-page', {
+ publish: {
+ /**
+ * Preferences state.
+ *
+ * @attribute prefs
+ * @type CrSettingsPrefsElement
+ * @default null
+ */
+ prefs: null,
+
+ /**
+ * Whether the page is a subpage.
+ *
+ * @attribute subpage
+ * @type boolean
+ * @default false
+ */
+ subpage: false,
+
+ /**
+ * ID of the page.
+ *
+ * @attribute PAGE_ID
+ * @const string
+ * @default 'search'
+ */
+ PAGE_ID: 'search',
+
+ /**
+ * Title for the page header and navigation menu.
+ *
+ * @attribute pageTitle
+ * @type string
+ */
+ pageTitle: loadTimeData.getString('searchPageTitle'),
+
+ /**
+ * Name of the 'core-icon' to show.
Jeremy Klein 2015/04/22 17:37:46 nit: ... in the page header.
Oren Blasberg 2015/04/22 18:25:41 Done.
+ *
+ * @attribute icon
+ * @type string
+ * @default 'search'
+ */
+ icon: 'search',
+
+ /**
+ * List of default search engines available.
+ *
+ * @attribute searchEngines
+ * @type Array
Jeremy Klein 2015/04/22 17:37:46 I know all of our types don't have {} right now, b
Jeremy Klein 2015/04/22 17:37:46 !Array<!chrome.searchEnginesPrivate.SearchEngine>,
Oren Blasberg 2015/04/22 18:25:41 Done.
+ * @default []
+ */
+ searchEngines: [],
Jeremy Klein 2015/04/22 17:37:46 Array and Object properties should be initialized
Oren Blasberg 2015/04/22 18:25:41 Done.
+
+ /**
+ * GUID of the currently selected default search engine.
+ *
+ * @attribute defaultEngineGuid
+ * @type string
+ * @default ''
+ */
+ defaultEngineGuid: '',
+ },
+
+ domReady: function() {
Jeremy Klein 2015/04/22 17:37:46 @override
Jeremy Klein 2015/04/22 17:37:46 I think this could just be done in attached or rea
Oren Blasberg 2015/04/22 18:25:41 Done.
+ chrome.searchEnginesPrivate.onSearchEnginesChanged.addListener(
+ this.updateSearchEngines_.bind(this));
+ chrome.searchEnginesPrivate.getDefaultSearchEngines(
+ this.updateSearchEngines_.bind(this));
+ },
+
+ defaultEngineGuidChanged: function() {
Jeremy Klein 2015/04/22 17:37:46 Can you add a jsdoc just to clarify that this is c
Oren Blasberg 2015/04/22 18:25:41 Done.
+ chrome.searchEnginesPrivate.setDefaultSearchEngine(this.defaultEngineGuid);
+ },
+
+
+ /**
+ * Updates the list of search engines with the given |engines|.
+ * @param {!Array<!chrome.searchEnginesPrivate.SearchEngine>} engines
+ * @private
+ */
+ updateSearchEngines_: function(engines) {
+ this.searchEngines = engines;
+ for (var i = 0; i < engines.length; i++) {
+ if (engines[i].isDefault) {
+ this.defaultEngineGuid = engines[i].guid;
+ }
+ }
+ }
+});

Powered by Google App Engine
This is Rietveld 408576698