OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_MANAGE_PASSWORDS_BUBBLE_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" | 9 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
10 #include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view
.h" | 10 #include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view
.h" |
11 #include "ui/base/ui_features.h" | 11 #include "ui/base/ui_features.h" |
| 12 #include "ui/views/controls/styled_label_listener.h" |
12 | 13 |
13 namespace content { | 14 namespace content { |
14 class WebContents; | 15 class WebContents; |
15 } | 16 } |
16 | 17 |
17 // The ManagePasswordsBubbleView controls the contents of the bubble which | 18 // The ManagePasswordsBubbleView controls the contents of the bubble which |
18 // pops up when Chrome offers to save a user's password, or when the user | 19 // pops up when Chrome offers to save a user's password, or when the user |
19 // interacts with the Omnibox icon. It has two distinct states: | 20 // interacts with the Omnibox icon. It has two distinct states: |
20 // | 21 // |
21 // 1. PendingView: Offers the user the possibility of saving credentials. | 22 // 1. PendingView: Offers the user the possibility of saving credentials. |
22 // 2. ManageView: Displays the current page's saved credentials. | 23 // 2. ManageView: Displays the current page's saved credentials. |
23 // 3. BlacklistedView: Informs the user that the current page is blacklisted. | 24 // 3. BlacklistedView: Informs the user that the current page is blacklisted. |
24 // | 25 // |
25 class ManagePasswordsBubbleView : public LocationBarBubbleDelegateView { | 26 class ManagePasswordsBubbleView : public LocationBarBubbleDelegateView, |
| 27 public views::StyledLabelListener { |
26 public: | 28 public: |
27 static constexpr int kDesiredBubbleWidth = 370; | 29 static constexpr int kDesiredBubbleWidth = 370; |
28 | 30 |
29 #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) | 31 #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) |
30 // Shows the bubble. | 32 // Shows the bubble. |
31 static void ShowBubble(content::WebContents* web_contents, | 33 static void ShowBubble(content::WebContents* web_contents, |
32 DisplayReason reason); | 34 DisplayReason reason); |
33 #endif | 35 #endif |
34 | 36 |
35 // Closes the existing bubble. | 37 // Closes the existing bubble. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 class SignInPromoView; | 72 class SignInPromoView; |
71 class UpdatePendingView; | 73 class UpdatePendingView; |
72 | 74 |
73 ~ManagePasswordsBubbleView() override; | 75 ~ManagePasswordsBubbleView() override; |
74 | 76 |
75 // LocationBarBubbleDelegateView: | 77 // LocationBarBubbleDelegateView: |
76 int GetDialogButtons() const override; | 78 int GetDialogButtons() const override; |
77 views::View* GetInitiallyFocusedView() override; | 79 views::View* GetInitiallyFocusedView() override; |
78 void Init() override; | 80 void Init() override; |
79 void CloseBubble() override; | 81 void CloseBubble() override; |
80 | 82 void AddedToWidget() override; |
81 // WidgetDelegate: | |
82 base::string16 GetWindowTitle() const override; | 83 base::string16 GetWindowTitle() const override; |
83 gfx::ImageSkia GetWindowIcon() override; | 84 gfx::ImageSkia GetWindowIcon() override; |
84 bool ShouldShowWindowTitle() const override; | |
85 bool ShouldShowWindowIcon() const override; | 85 bool ShouldShowWindowIcon() const override; |
86 bool ShouldShowCloseButton() const override; | 86 bool ShouldShowCloseButton() const override; |
87 | 87 |
| 88 // views::StyledLabelListener: |
| 89 void StyledLabelLinkClicked(views::StyledLabel* label, |
| 90 const gfx::Range& range, |
| 91 int event_flags) override; |
| 92 |
88 // Refreshes the bubble's state. | 93 // Refreshes the bubble's state. |
89 void Refresh(); | 94 void Refresh(); |
90 | 95 |
| 96 // Updates |title_view|'s text and link styling from |model_|. |
| 97 void UpdateTitleText(views::StyledLabel* title_view); |
| 98 |
91 // Sets up a child view according to the model state. | 99 // Sets up a child view according to the model state. |
92 void CreateChild(); | 100 void CreateChild(); |
93 | 101 |
94 void set_initially_focused_view(views::View* view) { | 102 void set_initially_focused_view(views::View* view) { |
95 DCHECK(!initially_focused_view_); | 103 DCHECK(!initially_focused_view_); |
96 initially_focused_view_ = view; | 104 initially_focused_view_ = view; |
97 } | 105 } |
98 | 106 |
99 // Singleton instance of the Password bubble. The Password bubble can only be | 107 // Singleton instance of the Password bubble. The Password bubble can only be |
100 // shown on the active browser window, so there is no case in which it will be | 108 // shown on the active browser window, so there is no case in which it will be |
101 // shown twice at the same time. The instance is owned by the Bubble and will | 109 // shown twice at the same time. The instance is owned by the Bubble and will |
102 // be deleted when the bubble closes. | 110 // be deleted when the bubble closes. |
103 static ManagePasswordsBubbleView* manage_passwords_bubble_; | 111 static ManagePasswordsBubbleView* manage_passwords_bubble_; |
104 | 112 |
105 // The timeout in seconds for the auto sign-in toast. | 113 // The timeout in seconds for the auto sign-in toast. |
106 static int auto_signin_toast_timeout_; | 114 static int auto_signin_toast_timeout_; |
107 | 115 |
108 ManagePasswordsBubbleModel model_; | 116 ManagePasswordsBubbleModel model_; |
109 | 117 |
110 views::View* initially_focused_view_; | 118 views::View* initially_focused_view_; |
111 | 119 |
112 std::unique_ptr<WebContentMouseHandler> mouse_handler_; | 120 std::unique_ptr<WebContentMouseHandler> mouse_handler_; |
113 | 121 |
114 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleView); | 122 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleView); |
115 }; | 123 }; |
116 | 124 |
117 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_ | 125 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_ |
OLD | NEW |