summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/gtk/password_generation_bubble_gtk.h
blob: df1e35b490cbecb6bdd4b7cad0690c152876302f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_GTK_PASSWORD_GENERATION_BUBBLE_GTK_H_
#define CHROME_BROWSER_UI_GTK_PASSWORD_GENERATION_BUBBLE_GTK_H_

#include <gtk/gtk.h>

#include "base/basictypes.h"
#include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
#include "chrome/common/password_generation_util.h"
#include "ui/base/gtk/gtk_signal.h"
#include "ui/gfx/rect.h"
#include "webkit/forms/password_form.h"

namespace autofill {
class PasswordGenerator;
}

class TabContents;

// PasswordGenerationBubbleGtk is a bubble use to show possible generated
// passwords to users. It is set in page content, anchored at |anchor_rect|.
// If the generated password is accepted by the user, the renderer associated
// with |render_view_host| and the |password_manager| are informed.
class PasswordGenerationBubbleGtk : public BubbleDelegateGtk {
 public:
  PasswordGenerationBubbleGtk(const gfx::Rect& anchor_rect,
                              const webkit::forms::PasswordForm& form,
                              TabContents* tab,
                              autofill::PasswordGenerator* password_generator);
  virtual ~PasswordGenerationBubbleGtk();

  // Overridden from BubbleDelegateGtk:
  virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE;

 private:
  CHROMEGTK_CALLBACK_0(PasswordGenerationBubbleGtk, void, OnDestroy);
  CHROMEGTK_CALLBACK_0(PasswordGenerationBubbleGtk, void, OnAcceptClicked);
  CHROMEGTK_CALLBACK_2(PasswordGenerationBubbleGtk, void, OnRegenerateClicked,
                       GtkEntryIconPosition, GdkEvent*);
  CHROMEGTK_CALLBACK_0(PasswordGenerationBubbleGtk, void, OnPasswordEdited);
  CHROMEG_CALLBACK_0(
      PasswordGenerationBubbleGtk, void, OnLearnMoreLinkClicked, GtkButton*);

  BubbleGtk* bubble_;
  GtkWidget* text_field_;

  // Form that contains the password field that we are generating a password
  // for. Used by the password_manager_.
  webkit::forms::PasswordForm form_;

  // TabContents associated with the button that spawned this bubble.
  TabContents* tab_;

  // Object that deals with generating passwords. The class won't take the
  // ownership of it.
  autofill::PasswordGenerator* password_generator_;

  // Store various status of the current living bubble.
  password_generation::PasswordGenerationActions actions_;

  DISALLOW_COPY_AND_ASSIGN(PasswordGenerationBubbleGtk);
};

#endif  // CHROME_BROWSER_UI_GTK_PASSWORD_GENERATION_BUBBLE_GTK_H_