summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsargrass@google.com <sargrass@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-20 23:19:16 +0000
committersargrass@google.com <sargrass@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-20 23:19:16 +0000
commitd4e3ac8dcfc9d5cef0cb2e762ee3415d214844b8 (patch)
tree68dd5ad6f0c3520e24b73f2e7fd54cb1a6e40a19 /chrome
parentd40c5648de999219a68dd769755ade380a62400d (diff)
downloadchromium_src-d4e3ac8dcfc9d5cef0cb2e762ee3415d214844b8.zip
chromium_src-d4e3ac8dcfc9d5cef0cb2e762ee3415d214844b8.tar.gz
chromium_src-d4e3ac8dcfc9d5cef0cb2e762ee3415d214844b8.tar.bz2
Implement Password Exceptions Tab.
Separate the password exceptions list. BUG=49093 TEST=None Review URL: http://codereview.chromium.org/3177023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56931 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/dom_ui/options_ui.cc2
-rw-r--r--chrome/browser/dom_ui/passwords_exceptions_handler.cc104
-rw-r--r--chrome/browser/dom_ui/passwords_exceptions_handler.h73
-rw-r--r--chrome/browser/dom_ui/passwords_remove_all_handler.cc41
-rw-r--r--chrome/browser/dom_ui/passwords_remove_all_handler.h26
-rw-r--r--chrome/browser/resources/options.html8
-rw-r--r--chrome/browser/resources/options/passwords_exceptions.html13
-rw-r--r--chrome/browser/resources/options/passwords_exceptions.js67
-rw-r--r--chrome/browser/resources/options/passwords_exceptions_list.js219
-rw-r--r--chrome/browser/resources/options/passwords_remove_all_overlay.html7
-rw-r--r--chrome/browser/resources/options/passwords_remove_all_overlay.js50
-rw-r--r--chrome/chrome_browser.gypi2
12 files changed, 538 insertions, 74 deletions
diff --git a/chrome/browser/dom_ui/options_ui.cc b/chrome/browser/dom_ui/options_ui.cc
index 43821c6..5ce6a08 100644
--- a/chrome/browser/dom_ui/options_ui.cc
+++ b/chrome/browser/dom_ui/options_ui.cc
@@ -29,6 +29,7 @@
#include "chrome/browser/dom_ui/font_settings_handler.h"
#include "chrome/browser/dom_ui/import_data_handler.h"
#include "chrome/browser/dom_ui/passwords_exceptions_handler.h"
+#include "chrome/browser/dom_ui/passwords_remove_all_handler.h"
#include "chrome/browser/dom_ui/personal_options_handler.h"
#include "chrome/browser/dom_ui/search_engine_manager_handler.h"
#include "chrome/browser/dom_ui/stop_syncing_handler.h"
@@ -139,6 +140,7 @@ OptionsUI::OptionsUI(TabContents* contents) : DOMUI(contents) {
AddOptionsPageUIHandler(localized_strings, new ContentSettingsHandler());
AddOptionsPageUIHandler(localized_strings, new FontSettingsHandler());
AddOptionsPageUIHandler(localized_strings, new PasswordsExceptionsHandler());
+ AddOptionsPageUIHandler(localized_strings, new PasswordsRemoveAllHandler());
AddOptionsPageUIHandler(localized_strings, new PersonalOptionsHandler());
AddOptionsPageUIHandler(localized_strings, new SearchEngineManagerHandler());
AddOptionsPageUIHandler(localized_strings, new ImportDataHandler());
diff --git a/chrome/browser/dom_ui/passwords_exceptions_handler.cc b/chrome/browser/dom_ui/passwords_exceptions_handler.cc
index 44888bf..ea027bb 100644
--- a/chrome/browser/dom_ui/passwords_exceptions_handler.cc
+++ b/chrome/browser/dom_ui/passwords_exceptions_handler.cc
@@ -6,6 +6,7 @@
#include "app/l10n_util.h"
#include "base/callback.h"
+#include "base/stl_util-inl.h"
#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
@@ -17,7 +18,8 @@
#include "net/base/net_util.h"
PasswordsExceptionsHandler::PasswordsExceptionsHandler()
- : ALLOW_THIS_IN_INITIALIZER_LIST(populater_(this)) {
+ : ALLOW_THIS_IN_INITIALIZER_LIST(populater_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(exception_populater_(this)) {
}
PasswordsExceptionsHandler::~PasswordsExceptionsHandler() {
@@ -31,7 +33,7 @@ void PasswordsExceptionsHandler::GetLocalizedValues(
l10n_util::GetStringUTF16(IDS_PASSWORDS_EXCEPTIONS_WINDOW_TITLE));
localized_strings->SetString("passwordsTabTitle",
l10n_util::GetStringUTF16(IDS_PASSWORDS_SHOW_PASSWORDS_TAB_TITLE));
- localized_strings->SetString("passwordsExceptionsTabTitle",
+ localized_strings->SetString("passwordExceptionsTabTitle",
l10n_util::GetStringUTF16(IDS_PASSWORDS_EXCEPTIONS_TAB_TITLE));
localized_strings->SetString("passwordsSiteColumn",
l10n_util::GetStringUTF16(IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN));
@@ -60,14 +62,17 @@ void PasswordsExceptionsHandler::Initialize() {
void PasswordsExceptionsHandler::RegisterMessages() {
DCHECK(dom_ui_);
- dom_ui_->RegisterMessageCallback(
- "loadSavedPasswords",
- NewCallback(this, &PasswordsExceptionsHandler::LoadSavedPasswords));
- dom_ui_->RegisterMessageCallback(
- "removeAutofillable",
- NewCallback(this, &PasswordsExceptionsHandler::RemoveEntry));
- dom_ui_->RegisterMessageCallback(
- "showSelectedPassword",
+ dom_ui_->RegisterMessageCallback("loadLists",
+ NewCallback(this, &PasswordsExceptionsHandler::LoadLists));
+ dom_ui_->RegisterMessageCallback("removeSavedPassword",
+ NewCallback(this, &PasswordsExceptionsHandler::RemoveSavedPassword));
+ dom_ui_->RegisterMessageCallback("removePasswordException",
+ NewCallback(this, &PasswordsExceptionsHandler::RemovePasswordException));
+ dom_ui_->RegisterMessageCallback("removeAllSavedPasswords",
+ NewCallback(this, &PasswordsExceptionsHandler::RemoveAllSavedPasswords));
+ dom_ui_->RegisterMessageCallback("removeAllPasswordExceptions", NewCallback(
+ this, &PasswordsExceptionsHandler::RemoveAllPasswordExceptions));
+ dom_ui_->RegisterMessageCallback("showSelectedPassword",
NewCallback(this, &PasswordsExceptionsHandler::ShowSelectedPassword));
}
@@ -75,13 +80,17 @@ PasswordStore* PasswordsExceptionsHandler::GetPasswordStore() {
return profile_->GetPasswordStore(Profile::EXPLICIT_ACCESS);
}
-void PasswordsExceptionsHandler::LoadSavedPasswords(const ListValue* args) {
+void PasswordsExceptionsHandler::LoadLists(const ListValue* args) {
+ languages_ = UTF8ToWide(
+ profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
populater_.Populate();
+ exception_populater_.Populate();
}
-void PasswordsExceptionsHandler::RemoveEntry(const ListValue* args) {
+void PasswordsExceptionsHandler::RemoveSavedPassword(const ListValue* args) {
+ std::string string_value = WideToUTF8(ExtractStringValue(args));;
int index;
- CHECK(ExtractIntegerValue(args, &index));
+ base::StringToInt(string_value, &index);
GetPasswordStore()->RemoveLogin(*password_list_[index]);
delete password_list_[index];
@@ -89,9 +98,39 @@ void PasswordsExceptionsHandler::RemoveEntry(const ListValue* args) {
SetPasswordList();
}
+void PasswordsExceptionsHandler::RemovePasswordException(const ListValue* args) {
+ std::string string_value = WideToUTF8(ExtractStringValue(args));;
+ int index;
+ base::StringToInt(string_value, &index);
+
+ GetPasswordStore()->RemoveLogin(*password_exception_list_[index]);
+ delete password_exception_list_[index];
+ password_exception_list_.erase(password_exception_list_.begin() + index);
+ SetPasswordExceptionList();
+}
+
+void PasswordsExceptionsHandler::RemoveAllSavedPasswords(
+ const ListValue* args) {
+ PasswordStore* store = GetPasswordStore();
+ for (size_t i = 0; i < password_list_.size(); ++i)
+ store->RemoveLogin(*password_list_[i]);
+ STLDeleteElements(&password_list_);
+ SetPasswordList();
+}
+
+void PasswordsExceptionsHandler::RemoveAllPasswordExceptions(
+ const ListValue* args) {
+ PasswordStore* store = GetPasswordStore();
+ for (size_t i = 0; i < password_exception_list_.size(); ++i)
+ store->RemoveLogin(*password_exception_list_[i]);
+ STLDeleteElements(&password_exception_list_);
+ SetPasswordExceptionList();
+}
+
void PasswordsExceptionsHandler::ShowSelectedPassword(const ListValue* args) {
+ std::string string_value = WideToUTF8(ExtractStringValue(args));;
int index;
- CHECK(ExtractIntegerValue(args, &index));
+ base::StringToInt(string_value, &index);
std::string pass = UTF16ToUTF8(password_list_[index]->password_value);
scoped_ptr<Value> password_string(Value::CreateStringValue(pass));
@@ -100,20 +139,30 @@ void PasswordsExceptionsHandler::ShowSelectedPassword(const ListValue* args) {
}
void PasswordsExceptionsHandler::SetPasswordList() {
- ListValue autofillableLogins;
- std::wstring languages =
- UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
+ ListValue entries;
for (size_t i = 0; i < password_list_.size(); ++i) {
ListValue* entry = new ListValue();
entry->Append(new StringValue(
- WideToUTF8(net::FormatUrl(password_list_[i]->origin, languages))));
+ WideToUTF8(net::FormatUrl(password_list_[i]->origin, languages_))));
entry->Append(new StringValue(
UTF16ToUTF8(password_list_[i]->username_value)));
- autofillableLogins.Append(entry);
+ entries.Append(entry);
+ }
+
+ dom_ui_->CallJavascriptFunction(
+ L"PasswordsExceptions.setSavedPasswordsList", entries);
+}
+
+void PasswordsExceptionsHandler::SetPasswordExceptionList() {
+ ListValue entries;
+ for (size_t i = 0; i < password_exception_list_.size(); ++i) {
+ entries.Append(new StringValue(
+ WideToUTF8(net::FormatUrl(
+ password_exception_list_[i]->origin, languages_))));
}
dom_ui_->CallJavascriptFunction(
- L"PasswordsExceptions.setAutofillableLogins", autofillableLogins);
+ L"PasswordsExceptions.setPasswordExceptionsList", entries);
}
void PasswordsExceptionsHandler::PasswordListPopulater::Populate() {
@@ -130,3 +179,18 @@ void PasswordsExceptionsHandler::PasswordListPopulater::
page_->password_list_ = result;
page_->SetPasswordList();
}
+
+void PasswordsExceptionsHandler::PasswordExceptionListPopulater::Populate() {
+ DCHECK(!pending_login_query_);
+ PasswordStore* store = page_->GetPasswordStore();
+ pending_login_query_ = store->GetBlacklistLogins(this);
+}
+
+void PasswordsExceptionsHandler::PasswordExceptionListPopulater::
+ OnPasswordStoreRequestDone(int handle,
+ const std::vector<webkit_glue::PasswordForm*>& result) {
+ DCHECK_EQ(pending_login_query_, handle);
+ pending_login_query_ = 0;
+ page_->password_exception_list_ = result;
+ page_->SetPasswordExceptionList();
+}
diff --git a/chrome/browser/dom_ui/passwords_exceptions_handler.h b/chrome/browser/dom_ui/passwords_exceptions_handler.h
index 4bc87e8..f4bfe4b4 100644
--- a/chrome/browser/dom_ui/passwords_exceptions_handler.h
+++ b/chrome/browser/dom_ui/passwords_exceptions_handler.h
@@ -26,46 +26,93 @@ class PasswordsExceptionsHandler : public OptionsPageUIHandler {
PasswordStore* GetPasswordStore();
// Fired when user clicks 'show saved passwords' button in personal page.
- void LoadSavedPasswords(const ListValue* args);
+ void LoadLists(const ListValue* args);
// Remove an entry.
// @param value the entry index to be removed.
- void RemoveEntry(const ListValue* args);
+ void RemoveSavedPassword(const ListValue* args);
+
+ // Remove an password exception.
+ // @param value the entry index to be removed.
+ void RemovePasswordException(const ListValue* args);
+
+ // Remove all saved passwords
+ void RemoveAllSavedPasswords(const ListValue* args);
+
+ // Remove All password exceptions
+ void RemoveAllPasswordExceptions(const ListValue* args);
// Get password value for the selected entry.
// @param value the selected entry index.
void ShowSelectedPassword(const ListValue* args);
- // Sets the password list contents to the given data. We take ownership of
- // the PasswordForms in the vector.
+ // Sets the password and exception list contents to the given data.
+ // We take ownership of the PasswordForms in the vector.
void SetPasswordList();
+ void SetPasswordExceptionList();
// A short class to mediate requests to the password store.
- class PasswordListPopulater : public PasswordStoreConsumer {
+ class ListPopulater : public PasswordStoreConsumer {
public:
- explicit PasswordListPopulater(PasswordsExceptionsHandler* page)
+ explicit ListPopulater(PasswordsExceptionsHandler* page)
: page_(page),
pending_login_query_(0) {
}
- // Send a query to the password store to populate a PasswordsPageGtk.
- void Populate();
+ // Send a query to the password store to populate a list.
+ virtual void Populate() = 0;
- // Send the password store's reply back to the PasswordsPageGtk.
+ // Send the password store's reply back to the handler.
virtual void OnPasswordStoreRequestDone(
- int handle, const std::vector<webkit_glue::PasswordForm*>& result);
+ int handle, const std::vector<webkit_glue::PasswordForm*>& result) = 0;
- private:
+ protected:
PasswordsExceptionsHandler* page_;
int pending_login_query_;
};
- // Password store consumer for populating the password list.
+ // A short class to mediate requests to the password store for passwordlist.
+ class PasswordListPopulater : public ListPopulater {
+ public:
+ explicit PasswordListPopulater(PasswordsExceptionsHandler* page)
+ : ListPopulater(page) {
+ }
+
+ // Send a query to the password store to populate a password list.
+ virtual void Populate();
+
+ // Send the password store's reply back to the handler.
+ virtual void OnPasswordStoreRequestDone(
+ int handle, const std::vector<webkit_glue::PasswordForm*>& result);
+ };
+
+ // A short class to mediate requests to the password store for exceptions.
+ class PasswordExceptionListPopulater : public ListPopulater {
+ public:
+ explicit PasswordExceptionListPopulater(
+ PasswordsExceptionsHandler* page) : ListPopulater(page) {
+ }
+
+ // Send a query to the password store to populate a passwordException list.
+ virtual void Populate();
+
+ // Send the password store's reply back to the handler.
+ virtual void OnPasswordStoreRequestDone(
+ int handle, const std::vector<webkit_glue::PasswordForm*>& result);
+ };
+
+ // Password store consumer for populating the password list and exceptions.
PasswordListPopulater populater_;
+ PasswordExceptionListPopulater exception_populater_;
+
+ std::vector<webkit_glue::PasswordForm*> password_list_;
+ std::vector<webkit_glue::PasswordForm*> password_exception_list_;
// A weak reference to profile.
Profile* profile_;
- std::vector<webkit_glue::PasswordForm*> password_list_;
+
+ // User's pref
+ std::wstring languages_;
DISALLOW_COPY_AND_ASSIGN(PasswordsExceptionsHandler);
};
diff --git a/chrome/browser/dom_ui/passwords_remove_all_handler.cc b/chrome/browser/dom_ui/passwords_remove_all_handler.cc
new file mode 100644
index 0000000..ecf15a6
--- /dev/null
+++ b/chrome/browser/dom_ui/passwords_remove_all_handler.cc
@@ -0,0 +1,41 @@
+// 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.
+
+#include "chrome/browser/dom_ui/passwords_remove_all_handler.h"
+
+#include "app/l10n_util.h"
+#include "base/basictypes.h"
+#include "base/values.h"
+#include "base/callback.h"
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
+#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/profile.h"
+#include "chrome/browser/profile_manager.h"
+#include "chrome/browser/dom_ui/passwords_exceptions_handler.h"
+
+PasswordsRemoveAllHandler::PasswordsRemoveAllHandler() {
+}
+
+PasswordsRemoveAllHandler::~PasswordsRemoveAllHandler() {
+}
+
+void PasswordsRemoveAllHandler::GetLocalizedValues(
+ DictionaryValue* localized_strings) {
+ DCHECK(localized_strings);
+ localized_strings->SetString("remove_all_explanation",
+ l10n_util::GetStringUTF16(
+ IDS_PASSWORDS_PAGE_VIEW_TEXT_DELETE_ALL_PASSWORDS));
+ localized_strings->SetString("remove_all_title",
+ l10n_util::GetStringUTF16(
+ IDS_PASSWORDS_PAGE_VIEW_CAPTION_DELETE_ALL_PASSWORDS));
+ localized_strings->SetString("remove_all_yes",
+ l10n_util::GetStringUTF16(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL));
+ localized_strings->SetString("remove_all_no",
+ l10n_util::GetStringUTF16(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL));
+}
+
+void PasswordsRemoveAllHandler::RegisterMessages() {
+ DCHECK(dom_ui_);
+}
diff --git a/chrome/browser/dom_ui/passwords_remove_all_handler.h b/chrome/browser/dom_ui/passwords_remove_all_handler.h
new file mode 100644
index 0000000..08795c1
--- /dev/null
+++ b/chrome/browser/dom_ui/passwords_remove_all_handler.h
@@ -0,0 +1,26 @@
+// 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.
+
+#ifndef CHROME_BROWSER_DOM_UI_PASSWORDS_REMOVE_ALL_HANDLER_H_
+#define CHROME_BROWSER_DOM_UI_PASSWORDS_REMOVE_ALL_HANDLER_H_
+
+#include "chrome/browser/dom_ui/options_ui.h"
+
+// Chrome passwords and exceptions remove all overlay UI handler.
+class PasswordsRemoveAllHandler : public OptionsPageUIHandler {
+ public:
+ PasswordsRemoveAllHandler();
+ virtual ~PasswordsRemoveAllHandler();
+
+ // OptionsUIHandler implementation.
+ virtual void GetLocalizedValues(DictionaryValue* localized_strings);
+
+ // DOMMessageHandler implementation.
+ virtual void RegisterMessages();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(PasswordsRemoveAllHandler);
+};
+
+#endif // CHROME_BROWSER_DOM_UI_PASSWORDSREMOVE_ALL_HANDLER_H_
diff --git a/chrome/browser/resources/options.html b/chrome/browser/resources/options.html
index 873ea1f..91b225f 100644
--- a/chrome/browser/resources/options.html
+++ b/chrome/browser/resources/options.html
@@ -58,6 +58,7 @@
<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/passwords_remove_all_overlay.js"></script>
<script src="options/personal_options.js"></script>
<script src="options/search_engine_manager.js"></script>
<script src="options/search_engine_manager_engine_list.js"></script>
@@ -79,6 +80,7 @@ var PersonalOptions = options.PersonalOptions;
var Preferences = options.Preferences;
var SearchEngineManager = options.SearchEngineManager;
var StopSyncingOverlay = options.StopSyncingOverlay;
+var PasswordsRemoveAllOverlay = options.PasswordsRemoveAllOverlay;
/**
* Window onload handler, sets up the page.
@@ -105,6 +107,7 @@ function load() {
OptionsPage.registerOverlay(FontSettingsOverlay.getInstance());
OptionsPage.registerOverlay(ImportDataOverlay.getInstance());
OptionsPage.registerOverlay(StopSyncingOverlay.getInstance());
+ OptionsPage.registerOverlay(PasswordsRemoveAllOverlay.getInstance());
if (cr.isChromeOS) {
OptionsPage.register(AccountsOptions.getInstance());
@@ -142,9 +145,9 @@ function load() {
Preferences.getInstance().initialize();
OptionsPage.initialize();
-
+
var path = document.location.pathname;
-
+
if (path.length > 1) {
OptionsPage.showPageByName(path.slice(1));
} else {
@@ -201,6 +204,7 @@ window.onpopstate = function(e) {
<include src="options/font_settings_overlay.html">
<include src="options/import_data_overlay.html">
<include src="options/stop_syncing_overlay.html">
+ <include src="options/passwords_remove_all_overlay.html">
<if expr="pp_ifdef('chromeos')">
<include src="options/chromeos_language_add_language_overlay.html">
</if>
diff --git a/chrome/browser/resources/options/passwords_exceptions.html b/chrome/browser/resources/options/passwords_exceptions.html
index fe7b7bd..f45c263 100644
--- a/chrome/browser/resources/options/passwords_exceptions.html
+++ b/chrome/browser/resources/options/passwords_exceptions.html
@@ -9,24 +9,25 @@
<div class="subpages-nav-tabs">
<span i18n-content="passwordsTabTitle" id="passwords-nav-tab"
class="inactive-tab" tab-contents="passwordsTab"></span>
- <span i18n-content="passwordsExceptionsTabTitle"
- id="passwords-exceptions-nav-tab"
- class="inactive-tab" tab-contents="passwordsExceptionsTab"></span>
+ <span i18n-content="passwordExceptionsTabTitle"
+ id="password-exceptions-nav-tab"
+ class="inactive-tab" tab-contents="passwordExceptionsTab"></span>
</div>
<!-- Passwords tab contents -->
<div id="passwordsTab" class="subpages-tab-contents">
<section>
<div id="passwordsArea">
- <list id="autofillableLoginsList"></list>
+ <list id="savedPasswordsList"></list>
</div>
</section>
</div>
<!-- Exceptions tab contents -->
- <div id="passwordsExceptionsTab" class="subpages-tab-contents">
+ <div id="passwordExceptionsTab" class="subpages-tab-contents">
<section>
- <div id="passwordsExceptionsArea">
+ <div id="passwordExceptionsArea">
+ <list id="passwordExceptionsList"></list>
</div>
</section>
</div>
diff --git a/chrome/browser/resources/options/passwords_exceptions.js b/chrome/browser/resources/options/passwords_exceptions.js
index 3a979be..f325b1d0 100644
--- a/chrome/browser/resources/options/passwords_exceptions.js
+++ b/chrome/browser/resources/options/passwords_exceptions.js
@@ -28,36 +28,79 @@ cr.define('options', function() {
initializePage: function() {
OptionsPage.prototype.initializePage.call(this);
- options.passwordsExceptions.ListArea.decorate($('passwordsArea'));
+ options.passwordsExceptions.PasswordsListArea.decorate($('passwordsArea'));
+ options.passwordsExceptions.PasswordExceptionsListArea.decorate(
+ $('passwordExceptionsArea'));
- // TODO(sargrass): Passwords filter page --------------------------
-
- // TODO(sargrass): Exceptions filter page -------------------------
+ $('password-exceptions-nav-tab').onclick = function() {
+ OptionsPage.showTab($('password-exceptions-nav-tab'));
+ passwordExceptionsList.redraw();
+ }
+ },
+ setSavedPasswordsList_: function(entries) {
+ savedPasswordsList.clear();
+ for (var i = 0; i < entries.length; i++) {
+ savedPasswordsList.addEntry(entries[i]);
+ }
},
- setAutofillableLogins_: function(entries) {
- autofillableLoginsList.clear();
+ setPasswordExceptionsList_: function(entries) {
+ passwordExceptionsList.clear();
for (var i = 0; i < entries.length; i++) {
- autofillableLoginsList.addEntry(entries[i]);
+ passwordExceptionsList.addEntry(entries[i]);
}
},
+
};
PasswordsExceptions.load = function() {
- chrome.send('loadSavedPasswords');
+ chrome.send('loadLists');
};
- PasswordsExceptions.removeAutofillable = function(index) {
- chrome.send('removeAutofillable', [String(index)]);
+ /**
+ * Call to remove a saved password.
+ * @param rowIndex indicating the row to remove.
+ */
+ PasswordsExceptions.removeSavedPassword = function(rowIndex) {
+ chrome.send('removeSavedPassword', [String(rowIndex)]);
+ };
+
+ /**
+ * Call to remove a password exception.
+ * @param rowIndex indicating the row to remove.
+ */
+ PasswordsExceptions.removePasswordException = function(rowIndex) {
+ chrome.send('removePasswordException', [String(rowIndex)]);
+ };
+
+
+ /**
+ * Call to remove all saved passwords.
+ * @param tab contentType of the tab currently on.
+ */
+ PasswordsExceptions.removeAllPasswords = function() {
+ chrome.send('removeAllSavedPasswords');
+ };
+
+ /**
+ * Call to remove all saved passwords.
+ * @param tab contentType of the tab currently on.
+ */
+ PasswordsExceptions.removeAllPasswordExceptions = function() {
+ chrome.send('removeAllPasswordExceptions');
};
PasswordsExceptions.showSelectedPassword = function(index) {
chrome.send('showSelectedPassword', [String(index)]);
};
- PasswordsExceptions.setAutofillableLogins = function(entries) {
- PasswordsExceptions.getInstance().setAutofillableLogins_(entries);
+ PasswordsExceptions.setSavedPasswordsList = function(entries) {
+ PasswordsExceptions.getInstance().setSavedPasswordsList_(entries);
+ };
+
+ PasswordsExceptions.setPasswordExceptionsList = function(entries) {
+ PasswordsExceptions.getInstance().setPasswordExceptionsList_(entries);
};
PasswordsExceptions.selectedPasswordCallback = function(password) {
diff --git a/chrome/browser/resources/options/passwords_exceptions_list.js b/chrome/browser/resources/options/passwords_exceptions_list.js
index 8bf232e..261a3b0 100644
--- a/chrome/browser/resources/options/passwords_exceptions_list.js
+++ b/chrome/browser/resources/options/passwords_exceptions_list.js
@@ -36,13 +36,12 @@ cr.define('options.passwordsExceptions', function() {
var urlLabel = cr.doc.createElement('span');
urlLabel.textContent = this.url;
this.appendChild(urlLabel);
+ this.urlLabel = urlLabel;
var usernameLabel = cr.doc.createElement('span');
usernameLabel.textContent = this.username;
usernameLabel.className = 'passwordsUsername';
this.appendChild(usernameLabel);
-
- this.urlLabel = urlLabel;
this.usernameLabel = usernameLabel;
},
@@ -63,12 +62,56 @@ cr.define('options.passwordsExceptions', function() {
*/
get username() {
return this.dataItem[1];
- },
- set username(username) {
+ },
+ set username(username) {
this.dataItem[1] = username;
+ },
+ };
+
+ /**
+ * Creates a new PasswordExceptions list item.
+ * @param {Array} entry A pair of the form [url, username].
+ * @constructor
+ * @extends {cr.ui.ListItem}
+ */
+ function PasswordExceptionsListItem(entry) {
+ var el = cr.doc.createElement('li');
+ el.dataItem = entry;
+ el.__proto__ = PasswordExceptionsListItem.prototype;
+ el.decorate();
+
+ return el;
+ }
+
+ PasswordExceptionsListItem.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);
+ this.urlLabel = urlLabel;
+ },
+
+ /**
+ * Get the url for the entry.
+ * @type {string}
+ */
+ get url() {
+ return this.dataItem;
+ },
+ set url(url) {
+ this.dataItem = url;
},
};
+
/**
* Create a new passwords list.
* @constructor
@@ -101,6 +144,7 @@ cr.define('options.passwordsExceptions', function() {
*/
addEntry: function(entry) {
this.dataModel.push(entry);
+ this.listArea.updateButtonSensitivity();
},
/**
@@ -108,6 +152,7 @@ cr.define('options.passwordsExceptions', function() {
*/
clear: function() {
this.dataModel = new ArrayDataModel([]);
+ this.listArea.updateButtonSensitivity();
},
/**
@@ -115,7 +160,7 @@ cr.define('options.passwordsExceptions', function() {
*/
removeSelectedRow: function() {
var selectedIndex = this.selectionModel.selectedIndex;
- PasswordsExceptions.removeAutofillable(selectedIndex);
+ PasswordsExceptions.removeSavedPassword(selectedIndex);
},
showSelectedPassword: function() {
@@ -123,16 +168,86 @@ cr.define('options.passwordsExceptions', function() {
PasswordsExceptions.showSelectedPassword(selectedIndex);
},
+ /**
+ * The length of the list.
+ */
+ get length() {
+ return this.dataModel.length;
+ },
};
- var ListArea = cr.ui.define('div');
+ /**
+ * Create a new passwords list.
+ * @constructor
+ * @extends {cr.ui.List}
+ */
+ var PasswordExceptionsList = cr.ui.define('list');
- ListArea.prototype = {
+ PasswordExceptionsList.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 PasswordExceptionsListItem(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);
+ this.listArea.updateButtonSensitivity();
+ },
+
+ /**
+ * Remove all entries from the js model.
+ */
+ clear: function() {
+ this.dataModel = new ArrayDataModel([]);
+ this.listArea.updateButtonSensitivity();
+ },
+
+ /**
+ * Remove selected row from browser's model.
+ */
+ removeSelectedRow: function() {
+ var selectedIndex = this.selectionModel.selectedIndex;
+ PasswordsExceptions.removePasswordException(selectedIndex);
+ },
+
+ /**
+ * The length of the list.
+ */
+ get length() {
+ return this.dataModel.length;
+ },
+ };
+
+ /**
+ * Create a new passwords list area.
+ * @constructor
+ * @extends {cr.ui.div}
+ */
+ var PasswordsListArea = cr.ui.define('div');
+
+ PasswordsListArea.prototype = {
__proto__: HTMLDivElement.prototype,
decorate: function() {
this.passwordsList = this.querySelector('list');
- this.passwordsList.contentType = this.contentType;
+ this.passwordsList.listArea = this;
PasswordsList.decorate(this.passwordsList);
this.passwordsList.selectionModel.addEventListener(
@@ -143,6 +258,11 @@ cr.define('options.passwordsExceptions', function() {
this.appendChild(removeRow);
this.removeRow = removeRow;
+ var removeAll = cr.doc.createElement('button');
+ removeAll.textContent = templateData.passwordsRemoveAllButton;
+ this.appendChild(removeAll);
+ this.removeAll = removeAll;
+
var showHidePassword = cr.doc.createElement('button');
showHidePassword.textContent = templateData.passwordsShowButton;
this.appendChild(showHidePassword);
@@ -158,6 +278,10 @@ cr.define('options.passwordsExceptions', function() {
self.passwordsList.removeSelectedRow();
};
+ removeAll.onclick = function(event) {
+ OptionsPage.showOverlay('passwordsRemoveAllOverlay');
+ };
+
showHidePassword.onclick = function(event) {
if(self.showingPassword) {
self.passwordLabel.textContent = "";
@@ -172,17 +296,6 @@ cr.define('options.passwordsExceptions', function() {
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);
- },
-
displayReturnedPassword: function(password) {
this.passwordLabel.textContent = password;
},
@@ -191,9 +304,10 @@ cr.define('options.passwordsExceptions', function() {
* Update the button's states
*/
updateButtonSensitivity: function() {
- var selectionSize = autofillableLoginsList.selectedItems.length;
+ var selectionSize = this.passwordsList.selectedItems.length;
this.removeRow.disabled = selectionSize == 0;
this.showHidePassword.disabled = selectionSize == 0;
+ this.removeAll.disabled = this.passwordsList.length == 0;
},
/**
@@ -209,9 +323,72 @@ cr.define('options.passwordsExceptions', function() {
},
};
+ /**
+ * Create a new passwords list area.
+ * @constructor
+ * @extends {cr.ui.div}
+ */
+ var PasswordExceptionsListArea = cr.ui.define('div');
+
+ PasswordExceptionsListArea.prototype = {
+ __proto__: HTMLDivElement.prototype,
+
+ decorate: function() {
+ this.passwordExceptionsList = this.querySelector('list');
+ this.passwordExceptionsList.listArea = this;
+
+ PasswordExceptionsList.decorate(this.passwordExceptionsList);
+ this.passwordExceptionsList.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 removeAll = cr.doc.createElement('button');
+ removeAll.textContent = templateData.passwordsRemoveAllButton;
+ this.appendChild(removeAll);
+ this.removeAll = removeAll;
+
+ var self = this;
+ removeRow.onclick = function(event) {
+ self.passwordExceptionsList.removeSelectedRow();
+ };
+
+ removeAll.onclick = function(event) {
+ PasswordsExceptions.removeAllPasswordExceptions();
+ };
+
+ this.updateButtonSensitivity();
+ },
+
+ /**
+ * Update the button's states
+ */
+ updateButtonSensitivity: function() {
+ var selectionSize = this.passwordExceptionsList.selectedItems.length;
+ this.removeRow.disabled = selectionSize == 0;
+ this.removeAll.disabled = this.passwordExceptionsList.length == 0;
+ },
+
+ /**
+ * Callback from selection model
+ * @param {!cr.Event} ce Event with change info.
+ * @private
+ */
+ handleOnSelectionChange_: function(ce) {
+ this.updateButtonSensitivity();
+ },
+ };
+
+
return {
PasswordsListItem: PasswordsListItem,
+ PasswordExceptionsListItem: PasswordExceptionsListItem,
PasswordsList: PasswordsList,
- ListArea: ListArea
+ PasswordExceptionsList: PasswordExceptionsList,
+ PasswordsListArea: PasswordsListArea,
+ PasswordExceptionsListArea: PasswordExceptionsListArea
};
});
diff --git a/chrome/browser/resources/options/passwords_remove_all_overlay.html b/chrome/browser/resources/options/passwords_remove_all_overlay.html
new file mode 100644
index 0000000..4216612
--- /dev/null
+++ b/chrome/browser/resources/options/passwords_remove_all_overlay.html
@@ -0,0 +1,7 @@
+<div class="page hidden" id="passwordsRemoveAllOverlay">
+ <h1 i18n-content="remove_all_title"></h1>
+
+ <div i18n-content="remove_all_explanation"></div>
+ <button id="remove-all-cancel" i18n-content="remove_all_no"></button>
+ <button id="remove-all-confirm" i18n-content="remove_all_yes"></button>
+</div>
diff --git a/chrome/browser/resources/options/passwords_remove_all_overlay.js b/chrome/browser/resources/options/passwords_remove_all_overlay.js
new file mode 100644
index 0000000..c081bbf
--- /dev/null
+++ b/chrome/browser/resources/options/passwords_remove_all_overlay.js
@@ -0,0 +1,50 @@
+// 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', function() {
+
+ var OptionsPage = options.OptionsPage;
+
+ /**
+ * PasswordsRemoveAllOverlay class
+ * Encapsulated handling of the 'Remove All' overlay page.
+ * @class
+ */
+ function PasswordsRemoveAllOverlay() {
+ OptionsPage.call(this, 'passwordsRemoveAllOverlay',
+ templateData.remove_all_title,
+ 'passwordsRemoveAllOverlay');
+ }
+
+ cr.addSingletonGetter(PasswordsRemoveAllOverlay);
+
+ PasswordsRemoveAllOverlay.prototype = {
+ // Inherit StopSyncingOverlay from OptionsPage.
+ __proto__: OptionsPage.prototype,
+
+ /**
+ * Initialize the page.
+ */
+ initializePage: function() {
+ // Call base class implementation to starts preference initialization.
+ OptionsPage.prototype.initializePage.call(this);
+
+ $('remove-all-cancel').onclick = function(e) {
+ OptionsPage.clearOverlays();
+ }
+
+ $('remove-all-confirm').onclick = function(e) {
+ PasswordsExceptions.removeAllPasswords();
+ OptionsPage.clearOverlays();
+ }
+ }
+ };
+
+ // Export
+ return {
+ PasswordsRemoveAllOverlay: PasswordsRemoveAllOverlay
+ };
+
+});
+
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index e0f3ec6..affb35c 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1172,6 +1172,8 @@
'browser/dom_ui/font_settings_utils_win.cc',
'browser/dom_ui/passwords_exceptions_handler.cc',
'browser/dom_ui/passwords_exceptions_handler.h',
+ 'browser/dom_ui/passwords_remove_all_handler.cc',
+ 'browser/dom_ui/passwords_remove_all_handler.h',
'browser/dom_ui/personal_options_handler.cc',
'browser/dom_ui/personal_options_handler.h',
'browser/dom_ui/sync_options_handler.cc',