Add a minor text member to ui::MenuModel.
[chromium-blink-merge.git] / chrome / browser / ui / views / password_generation_bubble_view.h
blob74c38e52eebab47c1fd95ef84c497d4ff8796dfc
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_VIEWS_PASSWORD_GENERATION_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_PASSWORD_GENERATION_BUBBLE_VIEW_H_
8 #include "base/basictypes.h"
9 #include "components/autofill/core/common/password_generation_util.h"
10 #include "content/public/common/password_form.h"
11 #include "ui/gfx/rect.h"
12 #include "ui/views/bubble/bubble_delegate.h"
13 #include "ui/views/controls/button/button.h"
14 #include "ui/views/controls/textfield/textfield_controller.h"
15 #include "ui/views/view.h"
17 namespace autofill {
18 class PasswordGenerator;
21 namespace content {
22 class PageNavigator;
23 class RenderViewHost;
26 namespace views {
27 class ImageButton;
28 class Label;
29 class LabelButton;
32 class PasswordManager;
34 // PasswordGenerationBubbleView is a bubble used to show possible generated
35 // 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
37 // with |render_view_host| and the |password_manager| are informed.
38 class PasswordGenerationBubbleView : public views::BubbleDelegateView,
39 public views::ButtonListener,
40 public views::TextfieldController {
41 public:
42 PasswordGenerationBubbleView(const content::PasswordForm& form,
43 const gfx::Rect& anchor_rect,
44 views::View* anchor_view,
45 content::RenderViewHost* render_view_host,
46 PasswordManager* password_manager,
47 autofill::PasswordGenerator* password_generator,
48 content::PageNavigator* navigator,
49 ui::ThemeProvider* theme_provider);
50 virtual ~PasswordGenerationBubbleView();
52 // views::View
53 virtual gfx::Size GetPreferredSize() OVERRIDE;
54 virtual void Layout() OVERRIDE;
56 private:
57 // views::BubbleDelegateView
58 virtual void Init() OVERRIDE;
59 virtual gfx::Rect GetAnchorRect() OVERRIDE;
60 virtual void WindowClosing() OVERRIDE;
62 // views::ButtonListener
63 virtual void ButtonPressed(views::Button* sender,
64 const ui::Event& event) OVERRIDE;
66 // views::TextfieldController
67 virtual void ContentsChanged(views::Textfield* sender,
68 const string16& new_contents) OVERRIDE;
69 virtual bool HandleKeyEvent(views::Textfield* sender,
70 const ui::KeyEvent& key_event) OVERRIDE;
72 // views::WidgetDelegate
73 virtual views::View* GetInitiallyFocusedView() OVERRIDE;
75 // Subviews
76 views::Label* title_label_;
77 views::LabelButton* accept_button_;
78 views::Textfield* textfield_;
79 views::ImageButton* regenerate_button_;
80 views::View* textfield_wrapper_;
82 // The form associated with the password field(s) that we are generated.
83 content::PasswordForm form_;
85 // Location that the bubble points to
86 gfx::Rect anchor_rect_;
88 // RenderViewHost associated with the button that spawned this bubble.
89 content::RenderViewHost* render_view_host_;
91 // PasswordManager associated with this tab.
92 PasswordManager* password_manager_;
94 // Object to generate passwords. The class won't take the ownership of it.
95 autofill::PasswordGenerator* password_generator_;
97 // An object used to handle page loads that originate from link clicks
98 // within this UI.
99 content::PageNavigator* navigator_;
101 // Theme provider used to draw the regenerate button.
102 ui::ThemeProvider* theme_provider_;
104 // Store stats on the users actions for logging.
105 autofill::password_generation::PasswordGenerationActions actions_;
107 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationBubbleView);
110 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORD_GENERATION_BUBBLE_VIEW_H_