OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PASSWORD_GENERATION_BUBBLE_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PASSWORD_GENERATION_BUBBLE_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PASSWORD_GENERATION_BUBBLE_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PASSWORD_GENERATION_BUBBLE_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
11 #include "ui/views/bubble/bubble_delegate.h" | 11 #include "ui/views/bubble/bubble_delegate.h" |
12 #include "ui/views/controls/button/button.h" | 12 #include "ui/views/controls/button/button.h" |
13 #include "ui/views/controls/link_listener.h" | 13 #include "ui/views/controls/link_listener.h" |
14 #include "ui/views/view.h" | 14 #include "ui/views/view.h" |
15 #include "webkit/forms/password_form.h" | 15 #include "webkit/forms/password_form.h" |
16 | 16 |
17 namespace autofill { | 17 namespace autofill { |
18 class PasswordGenerator; | 18 class PasswordGenerator; |
19 } | 19 } |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 class PageNavigator; | 22 class PageNavigator; |
23 class RenderViewHost; | 23 class RenderViewHost; |
24 } | 24 } |
25 | 25 |
26 namespace views { | 26 namespace views { |
27 class ImageButton; | |
28 class TextButton; | 27 class TextButton; |
29 class Textfield; | 28 class Textfield; |
30 } | 29 } |
31 | 30 |
32 class PasswordManager; | 31 class PasswordManager; |
33 | 32 |
34 // PasswordGenerationBubbleView is a bubble used to show possible generated | 33 // PasswordGenerationBubbleView is a bubble used to show possible generated |
35 // passwords to users. It is set in the page content, anchored at |anchor_rect|. | 34 // passwords to users. It is set in the page content, anchored at |anchor_rect|. |
36 // If the generated password is accepted by the user, the renderer associated | 35 // If the generated password is accepted by the user, the renderer associated |
37 // with |render_view_host| and the |password_manager| are informed. | 36 // with |render_view_host| and the |password_manager| are informed. |
38 class PasswordGenerationBubbleView : public views::BubbleDelegateView, | 37 class PasswordGenerationBubbleView : public views::BubbleDelegateView, |
39 public views::ButtonListener, | 38 public views::ButtonListener, |
40 public views::LinkListener { | 39 public views::LinkListener { |
41 public: | 40 public: |
42 PasswordGenerationBubbleView(const gfx::Rect& anchor_rect, | 41 PasswordGenerationBubbleView(const gfx::Rect& anchor_rect, |
43 const webkit::forms::PasswordForm& form, | 42 const webkit::forms::PasswordForm& form, |
44 views::View* anchor_view, | 43 views::View* anchor_view, |
45 content::RenderViewHost* render_view_host, | 44 content::RenderViewHost* render_view_host, |
46 autofill::PasswordGenerator* password_generator, | 45 autofill::PasswordGenerator* password_generator, |
47 content::PageNavigator* navigator, | 46 content::PageNavigator* navigator, |
48 PasswordManager* password_manager, | 47 PasswordManager* password_manager); |
49 ui::ThemeProvider* theme_provider); | |
50 virtual ~PasswordGenerationBubbleView(); | 48 virtual ~PasswordGenerationBubbleView(); |
51 | 49 |
52 private: | 50 private: |
53 // views::BubbleDelegateView | 51 // views::BubbleDelegateView |
54 virtual void Init() OVERRIDE; | 52 virtual void Init() OVERRIDE; |
55 virtual gfx::Rect GetAnchorRect() OVERRIDE; | 53 virtual gfx::Rect GetAnchorRect() OVERRIDE; |
56 | 54 |
57 // views::ButtonListener | 55 // views::ButtonListener |
58 virtual void ButtonPressed(views::Button* sender, | 56 virtual void ButtonPressed(views::Button* sender, |
59 const views::Event& event) OVERRIDE; | 57 const views::Event& event) OVERRIDE; |
60 | 58 |
61 // views::LinkListener | 59 // views::LinkListener |
62 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 60 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
63 | 61 |
64 // views::WidgetDelegate | 62 // views::WidgetDelegate |
65 virtual views::View* GetInitiallyFocusedView() OVERRIDE; | 63 virtual views::View* GetInitiallyFocusedView() OVERRIDE; |
66 | 64 |
67 // Subviews | 65 // Subviews |
68 views::TextButton* accept_button_; | 66 views::TextButton* accept_button_; |
69 views::ImageButton* regenerate_button_; | |
70 views::Textfield* text_field_; | 67 views::Textfield* text_field_; |
71 | 68 |
72 // Location that the bubble points to | 69 // Location that the bubble points to |
73 gfx::Rect anchor_rect_; | 70 gfx::Rect anchor_rect_; |
74 | 71 |
75 // The form associated with the password field(s) that we are generated. | 72 // The form associated with the password field(s) that we are generated. |
76 webkit::forms::PasswordForm form_; | 73 webkit::forms::PasswordForm form_; |
77 | 74 |
78 // RenderViewHost associated with the button that spawned this bubble. | 75 // RenderViewHost associated with the button that spawned this bubble. |
79 content::RenderViewHost* render_view_host_; | 76 content::RenderViewHost* render_view_host_; |
80 | 77 |
81 // Object to generate passwords. The class won't take the ownership of it. | 78 // Object to generate passwords. The class won't take the ownership of it. |
82 autofill::PasswordGenerator* password_generator_; | 79 autofill::PasswordGenerator* password_generator_; |
83 | 80 |
84 // An object used to handle page loads that originate from link clicks | 81 // An object used to handle page loads that originate from link clicks |
85 // within this UI. | 82 // within this UI. |
86 content::PageNavigator* navigator_; | 83 content::PageNavigator* navigator_; |
87 | 84 |
88 // PasswordManager associated with this tab. | 85 // PasswordManager associated with this tab. |
89 PasswordManager* password_manager_; | 86 PasswordManager* password_manager_; |
90 | 87 |
91 // Theme provider used to draw the regenerate button. | |
92 ui::ThemeProvider* theme_provider_; | |
93 | |
94 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationBubbleView); | 88 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationBubbleView); |
95 }; | 89 }; |
96 | 90 |
97 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORD_GENERATION_BUBBLE_VIEW_H_ | 91 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORD_GENERATION_BUBBLE_VIEW_H_ |
OLD | NEW |