diff options
Diffstat (limited to 'chrome')
7 files changed, 241 insertions, 24 deletions
diff --git a/chrome/browser/dom_ui/passwords_exceptions_handler.cc b/chrome/browser/dom_ui/passwords_exceptions_handler.cc index 521afe2..b69be9c 100644 --- a/chrome/browser/dom_ui/passwords_exceptions_handler.cc +++ b/chrome/browser/dom_ui/passwords_exceptions_handler.cc @@ -11,6 +11,7 @@ #include "chrome/browser/pref_service.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" +#include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "net/base/net_util.h" @@ -25,12 +26,30 @@ void PasswordsExceptionsHandler::GetLocalizedValues( DictionaryValue* localized_strings) { DCHECK(localized_strings); - localized_strings->SetString("passwordsExceptionsTitle", + localized_strings->SetString("savedPasswordsExceptionsTitle", l10n_util::GetStringUTF16(IDS_PASSWORDS_EXCEPTIONS_WINDOW_TITLE)); localized_strings->SetString("passwordsTabTitle", l10n_util::GetStringUTF16(IDS_PASSWORDS_SHOW_PASSWORDS_TAB_TITLE)); localized_strings->SetString("exceptionsTabTitle", l10n_util::GetStringUTF16(IDS_PASSWORDS_EXCEPTIONS_TAB_TITLE)); + localized_strings->SetString("passwordsSiteColumn", + l10n_util::GetStringUTF16(IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN)); + localized_strings->SetString("passwordsUsernameColumn", + l10n_util::GetStringUTF16(IDS_PASSWORDS_PAGE_VIEW_USERNAME_COLUMN)); + localized_strings->SetString("passwordsRemoveButton", + l10n_util::GetStringUTF16(IDS_PASSWORDS_PAGE_VIEW_REMOVE_BUTTON)); + localized_strings->SetString("passwordsRemoveAllButton", + l10n_util::GetStringUTF16(IDS_PASSWORDS_PAGE_VIEW_REMOVE_ALL_BUTTON)); + localized_strings->SetString("passwordsShowButton", + l10n_util::GetStringUTF16(IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON)); + localized_strings->SetString("passwordsHideButton", + l10n_util::GetStringUTF16(IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON)); + localized_strings->SetString("passwordsRemoveAllTitle", + l10n_util::GetStringUTF16( + IDS_PASSWORDS_PAGE_VIEW_CAPTION_DELETE_ALL_PASSWORDS)); + localized_strings->SetString("passwordsRemoveAllWarning", + l10n_util::GetStringUTF16( + IDS_PASSWORDS_PAGE_VIEW_TEXT_DELETE_ALL_PASSWORDS)); } void PasswordsExceptionsHandler::Initialize() { diff --git a/chrome/browser/resources/options.html b/chrome/browser/resources/options.html index f9835e0..e1228de 100644 --- a/chrome/browser/resources/options.html +++ b/chrome/browser/resources/options.html @@ -52,6 +52,7 @@ <script src="options/font_settings_overlay.js"></script> <script src="options/import_data_overlay.js"></script> <script src="options/passwords_exceptions.js"></script> +<script src="options/passwords_exceptions_list.js"></script> <script src="options/personal_options.js"></script> <script src="options/search_engine_manager.js"></script> <script src="options/stop_syncing_overlay.js"></script> @@ -171,6 +172,7 @@ window.onpopstate = function(e) { <link rel="stylesheet" href="options/browser_options_page.css"> <link rel="stylesheet" href="options/clear_browser_data_overlay.css"> <link rel="stylesheet" href="options/content_settings_exceptions_area.css"> +<link rel="stylesheet" href="options/passwords_exceptions_list.css"> <link rel="stylesheet" href="options/import_data_overlay.css"> <link rel="stylesheet" href="options/subpages_tab_controls.css"> <if expr="pp_ifdef('chromeos')"> diff --git a/chrome/browser/resources/options/content_settings.js b/chrome/browser/resources/options/content_settings.js index bc78304..523feda 100644 --- a/chrome/browser/resources/options/content_settings.js +++ b/chrome/browser/resources/options/content_settings.js @@ -50,7 +50,8 @@ cr.define('options', function() { imagesExceptionsList.redraw(); }; - var exceptionsAreas = document.querySelectorAll('div[contentType]'); + var exceptionsAreas = + document.querySelectorAll('#contentSettingsPage div[contentType]'); for (var i = 0; i < exceptionsAreas.length; i++) { options.contentSettings.ExceptionsArea.decorate(exceptionsAreas[i]); } diff --git a/chrome/browser/resources/options/passwords_exceptions.html b/chrome/browser/resources/options/passwords_exceptions.html index 15df380..47a02f0 100644 --- a/chrome/browser/resources/options/passwords_exceptions.html +++ b/chrome/browser/resources/options/passwords_exceptions.html @@ -2,30 +2,32 @@ <h1> <span i18n-content="personalPage"></span> > - <span i18n-content="passwordsExceptionsTitle"></span> + <span i18n-content="savedPasswordsExceptionsTitle"></span> </h1> - <!-- Navigation tabls --> + <!-- Navigation tabs --> <div class="subpages-nav-tabs"> <span i18n-content="passwordsTabTitle" id="passwords-nav-tab" - class="inactive-tab" tab-contents="passwordsFilterTab"></span> - <span i18n-content="exceptionsTabTitle" id="exceptions-nav-tab" - class="inactive-tab" tab-contents="exceptionsFilterTab"></span> + class="inactive-tab" tab-contents="passwordsTab"></span> + <span i18n-content="passwordsExceptionsTabTitle" + id="passwords-exceptions-nav-tab" + class="inactive-tab" tab-contents="passwordsExceptionsTab"></span> </div> - <!-- Passwords filter tab contents --> - <div id="passwordsFilterTab" class="subpages-tab-contents"> + <!-- Passwords tab contents --> + <div id="passwordsTab" class="subpages-tab-contents"> <section> + <button id="trigger" i18n-content="passwordsTabTitle"></button> <div id="passwordsArea"> - <ul id="autofillableLoginsList"></ul> + <list id="autofillableLoginsList"></list> </div> </section> </div> - <!-- Exceptions filter tab contents --> - <div id="exceptionsFilterTab" class="subpages-tab-contents"> + <!-- Exceptions tab contents --> + <div id="passwordsExceptionsTab" class="subpages-tab-contents"> <section> - <div id="exceptionsArea"> + <div id="passwordsExceptionsArea"> </div> </section> </div> diff --git a/chrome/browser/resources/options/passwords_exceptions.js b/chrome/browser/resources/options/passwords_exceptions.js index b239047..14ec9c9 100644 --- a/chrome/browser/resources/options/passwords_exceptions.js +++ b/chrome/browser/resources/options/passwords_exceptions.js @@ -16,7 +16,7 @@ cr.define('options', function() { function PasswordsExceptions() { this.activeNavTab = null; OptionsPage.call(this, 'passwordsExceptions', - templateData.passwordsExceptionsTitle, + templateData.savedPasswordsExceptionsTitle, 'passwordsExceptionsPage'); } @@ -28,26 +28,28 @@ cr.define('options', function() { initializePage: function() { OptionsPage.prototype.initializePage.call(this); + options.passwordsExceptions.ListArea.decorate($('passwordsArea')); + // TODO(sargrass): Passwords filter page -------------------------- + $('trigger').onclick = function(event) { + autofillableLoginsList.redraw(); + // TODO(sargrass): Remove this element. + }; // TODO(sargrass): Exceptions filter page ------------------------- }, - setAutofillableLogins_: function(autofillableLogins) { - var ul = $('autofillableLoginsList'); - for (var i = 0; i < autofillableLogins.length; i++) { - var entry = autofillableLogins[i]; - var li = document.createElement('li'); - li.textContent = "URL=" + entry[0] + " Username=" + entry[1]; - ul.appendChild(li); + setAutofillableLogins_: function(entries) { + autofillableLoginsList.clear(); + for (var i = 0; i < entries.length; i++) { + autofillableLoginsList.addEntry(entries[i]); } }, }; - PasswordsExceptions.setAutofillableLogins = function(autofillableLogins) { - PasswordsExceptions.getInstance().setAutofillableLogins_( - autofillableLogins); + PasswordsExceptions.setAutofillableLogins = function(entries) { + PasswordsExceptions.getInstance().setAutofillableLogins_(entries); }; // Export diff --git a/chrome/browser/resources/options/passwords_exceptions_list.css b/chrome/browser/resources/options/passwords_exceptions_list.css new file mode 100644 index 0000000..c62adbe --- /dev/null +++ b/chrome/browser/resources/options/passwords_exceptions_list.css @@ -0,0 +1,9 @@ +/* +Copyright (c) 2010 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. +*/ + +.passwordsUsername { + float: right; +} diff --git a/chrome/browser/resources/options/passwords_exceptions_list.js b/chrome/browser/resources/options/passwords_exceptions_list.js new file mode 100644 index 0000000..b9a826a --- /dev/null +++ b/chrome/browser/resources/options/passwords_exceptions_list.js @@ -0,0 +1,182 @@ +// Copyright (c) 2010 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. + +cr.define('options.passwordsExceptions', function() { + + const List = cr.ui.List; + const ListItem = cr.ui.ListItem; + const ArrayDataModel = cr.ui.ArrayDataModel; + + /** + * Creates a new passwords list item. + * @param {Array} entry A pair of the form [url, username]. + * @constructor + * @extends {cr.ui.ListItem} + */ + function PasswordsListItem(entry) { + var el = cr.doc.createElement('li'); + el.dataItem = entry; + el.__proto__ = PasswordsListItem.prototype; + el.decorate(); + + return el; + } + + PasswordsListItem.prototype = { + __proto__: ListItem.prototype, + + /** + * Call when an element is decorated as a list item. + */ + decorate: function() { + ListItem.prototype.decorate.call(this); + + // Labels for display + var urlLabel = cr.doc.createElement('span'); + urlLabel.textContent = this.url; + this.appendChild(urlLabel); + + var usernameLabel = cr.doc.createElement('span'); + usernameLabel.textContent = this.username; + usernameLabel.className = 'passwordsUsername'; + this.appendChild(usernameLabel); + + this.urlLabel = urlLabel; + this.usernameLabel = usernameLabel; + }, + + /** + * Get the url for the entry. + * @type {string} + */ + get url() { + return this.dataItem[0]; + }, + set url(url) { + this.dataItem[0] = url; + }, + + /** + * Get the username for the entry. + * @type {string} + */ + get username() { + return this.dataItem[1]; + }, + set username(username) { + this.dataItem[1] = username; + }, + }; + + /** + * Create a new passwords list. + * @constructor + * @extends {cr.ui.List} + */ + var PasswordsList = cr.ui.define('list'); + + PasswordsList.prototype = { + __proto__: List.prototype, + /** + * Called when an element is decorated as a list. + */ + decorate: function() { + List.prototype.decorate.call(this); + + this.dataModel = new ArrayDataModel([]); + }, + + /** + * Creates an item to go in the list. + * @param {Object} entry The element from the data model for this row. + */ + createItem: function(entry) { + return new PasswordsListItem(entry); + }, + + /** + * Adds an entry to the js model. + * @param {Array} entry A pair of the form [url, username]. + */ + addEntry: function(entry) { + this.dataModel.push(entry); + }, + + /** + * Remove all entries from the js model. + */ + clear: function() { + this.dataModel = new ArrayDataModel([]); + }, + + /** + * Remove selected row from browser's model. + */ + removeSelectedRow: function() { + var selectedItem = this.selectedItem; + chrome.send('removeAutofillable', selectedItem[0]); + }, + }; + + var ListArea = cr.ui.define('div'); + + ListArea.prototype = { + __proto__: HTMLDivElement.prototype, + + decorate: function() { + this.passwordsList = this.querySelector('list'); + this.passwordsList.contentType = this.contentType; + + PasswordsList.decorate(this.passwordsList); + this.passwordsList.selectionModel.addEventListener( + 'change', cr.bind(this.handleOnSelectionChange_, this)); + + var removeRow = cr.doc.createElement('button'); + removeRow.textContent = templateData.passwordsRemoveButton; + this.appendChild(removeRow); + this.removeRow = removeRow; + + var self = this; + removeRow.onclick = function(event) { + self.passwordsList.removeSelectedRow(); + }; + + this.updateButtonSensitivity(); + }, + + /** + * The content type for the exceptions area, such as 'passwords' + * @type {string} + */ + get contentType() { + return this.getAttribute('contentType'); + }, + set contentType(type) { + return this.getAttribute('contentType', type); + }, + + /** + * Update the button's states + */ + updateButtonSensitivity: function() { + var selectionSize = autofillableLoginsList.selectedItems.length; + this.removeRow.disabled = selectionSize == 0; + }, + + /** + * Callback from selection model + * @param {!cr.Event} ce Event with change info. + * @private + */ + handleOnSelectionChange_: function(ce) { + this.updateButtonSensitivity(); + }, + }; + + return { + PasswordsListItem: PasswordsListItem, + PasswordsList: PasswordsList, + ListArea: ListArea + }; +}); |