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

Unified Diff: chrome/browser/ui/passwords/manage_passwords_icon.cc

Issue 419263002: Add ManagePasswordsDecoration and unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: exclude resource IDs on Android Created 6 years, 4 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/ui/passwords/manage_passwords_icon.cc
diff --git a/chrome/browser/ui/passwords/manage_passwords_icon.cc b/chrome/browser/ui/passwords/manage_passwords_icon.cc
index 26f2a011ff481fa00d753f522d14eefc46f5b9ca..a7245d50bb19e1dd35c6069587941d02120e279f 100644
--- a/chrome/browser/ui/passwords/manage_passwords_icon.cc
+++ b/chrome/browser/ui/passwords/manage_passwords_icon.cc
@@ -4,8 +4,13 @@
#include "chrome/browser/ui/passwords/manage_passwords_icon.h"
+#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
+
ManagePasswordsIcon::ManagePasswordsIcon()
- : state_(password_manager::ui::INACTIVE_STATE),
+ : icon_id_(0),
+ tooltip_text_id_(0),
+ state_(password_manager::ui::INACTIVE_STATE),
active_(false) {
}
@@ -16,6 +21,7 @@ void ManagePasswordsIcon::SetActive(bool active) {
if (active_ == active)
return;
active_ = active;
+ UpdateIDs();
UpdateVisibleUI();
}
@@ -23,5 +29,28 @@ void ManagePasswordsIcon::SetState(password_manager::ui::State state) {
if (state_ == state)
return;
state_ = state;
+ UpdateIDs();
UpdateVisibleUI();
}
+
+void ManagePasswordsIcon::UpdateIDs() {
+ // If the icon is inactive: clear out its image and tooltip and exit early.
+ if (state() == password_manager::ui::INACTIVE_STATE) {
+ icon_id_ = 0;
+ tooltip_text_id_ = 0;
+ return;
+ }
+
+ // Otherwise, start with the correct values for MANAGE_STATE, and adjust
+ // things accordingly if we're either in BLACKLIST_STATE or PENDING_STATE.
+ // TODO(dconnelly): Figure out how to share the resources with Android.
+#if !defined(OS_ANDROID)
+ icon_id_ = active() ? IDR_SAVE_PASSWORD_ACTIVE : IDR_SAVE_PASSWORD_INACTIVE;
+ tooltip_text_id_ = IDS_PASSWORD_MANAGER_TOOLTIP_MANAGE;
+ if (state() == password_manager::ui::BLACKLIST_STATE)
+ icon_id_ = active() ? IDR_SAVE_PASSWORD_DISABLED_ACTIVE
+ : IDR_SAVE_PASSWORD_DISABLED_INACTIVE;
+ else if (password_manager::ui::IsPendingState(state()))
+ tooltip_text_id_ = IDS_PASSWORD_MANAGER_TOOLTIP_SAVE;
+#endif
+}
« no previous file with comments | « chrome/browser/ui/passwords/manage_passwords_icon.h ('k') | chrome/browser/ui/views/passwords/manage_passwords_icon_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698