OLD | NEW |
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 #ifndef CHROME_BROWSER_UI_VIEWS_PASSWORDS_CREDENTIALS_ITEM_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PASSWORDS_CREDENTIALS_ITEM_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PASSWORDS_CREDENTIALS_ITEM_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PASSWORDS_CREDENTIALS_ITEM_VIEW_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "chrome/browser/ui/passwords/account_avatar_fetcher.h" | 10 #include "chrome/browser/ui/passwords/account_avatar_fetcher.h" |
11 #include "components/password_manager/core/common/credential_manager_types.h" | |
12 #include "ui/views/controls/button/label_button.h" | 11 #include "ui/views/controls/button/label_button.h" |
13 | 12 |
14 namespace autofill { | 13 namespace autofill { |
15 struct PasswordForm; | 14 struct PasswordForm; |
16 } | 15 } |
17 | 16 |
18 namespace gfx { | 17 namespace gfx { |
19 class ImageSkia; | 18 class ImageSkia; |
20 } | 19 } |
21 | 20 |
22 namespace net { | 21 namespace net { |
23 class URLRequestContextGetter; | 22 class URLRequestContextGetter; |
24 } | 23 } |
25 | 24 |
26 namespace views { | 25 namespace views { |
27 class ImageView; | 26 class ImageView; |
28 class Label; | 27 class Label; |
29 } | 28 } |
30 | 29 |
31 // CredentialsItemView represents a credential view in the account chooser | 30 // CredentialsItemView represents a credential view in the account chooser |
32 // bubble. | 31 // bubble. |
33 class CredentialsItemView : public AccountAvatarFetcherDelegate, | 32 class CredentialsItemView : public AccountAvatarFetcherDelegate, |
34 public views::LabelButton { | 33 public views::LabelButton { |
35 public: | 34 public: |
36 CredentialsItemView(views::ButtonListener* button_listener, | 35 CredentialsItemView(views::ButtonListener* button_listener, |
37 const autofill::PasswordForm* form, | |
38 password_manager::CredentialType credential_type, | |
39 const base::string16& upper_text, | 36 const base::string16& upper_text, |
40 const base::string16& lower_text, | 37 const base::string16& lower_text, |
| 38 SkColor hover_color, |
| 39 const autofill::PasswordForm* form, |
41 net::URLRequestContextGetter* request_context); | 40 net::URLRequestContextGetter* request_context); |
42 ~CredentialsItemView() override; | 41 ~CredentialsItemView() override; |
43 | 42 |
44 const autofill::PasswordForm* form() const { return form_; } | 43 const autofill::PasswordForm* form() const { return form_; } |
45 password_manager::CredentialType credential_type() const { | |
46 return credential_type_; | |
47 } | |
48 | 44 |
49 // AccountAvatarFetcherDelegate: | 45 // AccountAvatarFetcherDelegate: |
50 void UpdateAvatar(const gfx::ImageSkia& image) override; | 46 void UpdateAvatar(const gfx::ImageSkia& image) override; |
51 | 47 |
| 48 void SetLowerLabelColor(SkColor color); |
| 49 void SetHoverColor(SkColor color); |
| 50 |
52 private: | 51 private: |
53 // views::LabelButton: | 52 // views::LabelButton: |
54 gfx::Size GetPreferredSize() const override; | 53 gfx::Size GetPreferredSize() const override; |
55 int GetHeightForWidth(int w) const override; | 54 int GetHeightForWidth(int w) const override; |
56 void Layout() override; | 55 void Layout() override; |
| 56 void OnPaint(gfx::Canvas* canvas) override; |
57 | 57 |
58 const autofill::PasswordForm* form_; | 58 const autofill::PasswordForm* form_; |
59 const password_manager::CredentialType credential_type_; | |
60 | 59 |
61 views::ImageView* image_view_; | 60 views::ImageView* image_view_; |
62 views::Label* upper_label_; | 61 views::Label* upper_label_; |
63 views::Label* lower_label_; | 62 views::Label* lower_label_; |
64 | 63 |
| 64 SkColor hover_color_; |
| 65 |
65 base::WeakPtrFactory<CredentialsItemView> weak_ptr_factory_; | 66 base::WeakPtrFactory<CredentialsItemView> weak_ptr_factory_; |
66 | 67 |
67 DISALLOW_COPY_AND_ASSIGN(CredentialsItemView); | 68 DISALLOW_COPY_AND_ASSIGN(CredentialsItemView); |
68 }; | 69 }; |
69 | 70 |
70 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_CREDENTIALS_ITEM_VIEW_H_ | 71 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_CREDENTIALS_ITEM_VIEW_H_ |
OLD | NEW |