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 |
+} |