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