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

Side by Side 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: Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" 5 #include "chrome/browser/ui/passwords/manage_passwords_icon.h"
6 6
7 #include "grit/generated_resources.h"
8 #include "grit/theme_resources.h"
9
7 ManagePasswordsIcon::ManagePasswordsIcon() 10 ManagePasswordsIcon::ManagePasswordsIcon()
8 : state_(password_manager::ui::INACTIVE_STATE), 11 : icon_id_(0),
12 tooltip_text_id_(0),
13 state_(password_manager::ui::INACTIVE_STATE),
9 active_(false) { 14 active_(false) {
10 } 15 }
11 16
12 ManagePasswordsIcon::~ManagePasswordsIcon() { 17 ManagePasswordsIcon::~ManagePasswordsIcon() {
13 } 18 }
14 19
15 void ManagePasswordsIcon::SetActive(bool active) { 20 void ManagePasswordsIcon::SetActive(bool active) {
16 if (active_ == active) 21 if (active_ == active)
17 return; 22 return;
18 active_ = active; 23 active_ = active;
24 UpdateIDs();
19 UpdateVisibleUI(); 25 UpdateVisibleUI();
20 } 26 }
21 27
22 void ManagePasswordsIcon::SetState(password_manager::ui::State state) { 28 void ManagePasswordsIcon::SetState(password_manager::ui::State state) {
23 if (state_ == state) 29 if (state_ == state)
24 return; 30 return;
25 state_ = state; 31 state_ = state;
32 UpdateIDs();
26 UpdateVisibleUI(); 33 UpdateVisibleUI();
27 } 34 }
35
36 void ManagePasswordsIcon::UpdateIDs() {
37 // If the icon is inactive: clear out its image and tooltip and exit early.
38 if (state() == password_manager::ui::INACTIVE_STATE) {
39 icon_id_ = 0;
40 tooltip_text_id_ = 0;
41 return;
42 }
43
44 // Otherwise, start with the correct values for MANAGE_STATE, and adjust
45 // things accordingly if we're either in BLACKLIST_STATE or PENDING_STATE.
46 icon_id_ = active() ? IDR_SAVE_PASSWORD_ACTIVE : IDR_SAVE_PASSWORD_INACTIVE;
47 tooltip_text_id_ = IDS_PASSWORD_MANAGER_TOOLTIP_MANAGE;
48 if (state() == password_manager::ui::BLACKLIST_STATE)
49 icon_id_ = active() ? IDR_SAVE_PASSWORD_DISABLED_ACTIVE
50 : IDR_SAVE_PASSWORD_DISABLED_INACTIVE;
51 else if (password_manager::ui::IsPendingState(state()))
52 tooltip_text_id_ = IDS_PASSWORD_MANAGER_TOOLTIP_SAVE;
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698