Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / gtk / password_generation_bubble_gtk.h
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.
4
5 #ifndef CHROME_BROWSER_UI_GTK_PASSWORD_GENERATION_BUBBLE_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_PASSWORD_GENERATION_BUBBLE_GTK_H_
7
8 #include <gtk/gtk.h>
9
10 #include "base/basictypes.h"
11 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
12 #include "components/autofill/core/common/password_form.h"
13 #include "components/autofill/core/common/password_generation_util.h"
14 #include "ui/base/gtk/gtk_signal.h"
15 #include "ui/gfx/rect.h"
16
17 namespace autofill {
18 class PasswordGenerator;
19 }
20
21 namespace content {
22 class WebContents;
23 }
24
25 // PasswordGenerationBubbleGtk is a bubble use to show possible generated
26 // passwords to users. It is set in page content, anchored at |anchor_rect|.
27 // If the generated password is accepted by the user, the renderer associated
28 // with |render_view_host| and the |password_manager| are informed.
29 class PasswordGenerationBubbleGtk : public BubbleDelegateGtk {
30  public:
31   PasswordGenerationBubbleGtk(const gfx::Rect& anchor_rect,
32                               const autofill::PasswordForm& form,
33                               content::WebContents* web_contents,
34                               autofill::PasswordGenerator* password_generator);
35   virtual ~PasswordGenerationBubbleGtk();
36
37   // Overridden from BubbleDelegateGtk:
38   virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE;
39
40  private:
41   CHROMEGTK_CALLBACK_0(PasswordGenerationBubbleGtk, void, OnDestroy);
42   CHROMEGTK_CALLBACK_0(PasswordGenerationBubbleGtk, void, OnAcceptClicked);
43   CHROMEGTK_CALLBACK_2(PasswordGenerationBubbleGtk, void, OnRegenerateClicked,
44                        GtkEntryIconPosition, GdkEvent*);
45   CHROMEGTK_CALLBACK_0(PasswordGenerationBubbleGtk, void, OnPasswordEdited);
46   CHROMEG_CALLBACK_0(
47       PasswordGenerationBubbleGtk, void, OnLearnMoreLinkClicked, GtkButton*);
48
49   BubbleGtk* bubble_;
50   GtkWidget* text_field_;
51
52   // Form that contains the password field that we are generating a password
53   // for. Used by the password_manager_.
54   autofill::PasswordForm form_;
55
56   // WebContents associated with the button that spawned this bubble.
57   content::WebContents* web_contents_;
58
59   // Object that deals with generating passwords. The class won't take the
60   // ownership of it.
61   autofill::PasswordGenerator* password_generator_;
62
63   // Store various status of the current living bubble.
64   autofill::password_generation::PasswordGenerationActions actions_;
65
66   DISALLOW_COPY_AND_ASSIGN(PasswordGenerationBubbleGtk);
67 };
68
69 #endif  // CHROME_BROWSER_UI_GTK_PASSWORD_GENERATION_BUBBLE_GTK_H_