Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / passwords / manage_passwords_bubble_view.h
index b33aeba..a33c2b0 100644 (file)
@@ -5,17 +5,8 @@
 #ifndef CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_
 #define CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_
 
-#include "base/basictypes.h"
-#include "base/timer/timer.h"
 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h"
-#include "chrome/browser/ui/views/passwords/save_password_refusal_combobox_model.h"
 #include "ui/views/bubble/bubble_delegate.h"
-#include "ui/views/controls/button/button.h"
-#include "ui/views/controls/combobox/combobox.h"
-#include "ui/views/controls/combobox/combobox_listener.h"
-#include "ui/views/controls/link.h"
-#include "ui/views/controls/link_listener.h"
-#include "ui/views/controls/styled_label_listener.h"
 
 class ManagePasswordsIconView;
 
@@ -23,12 +14,6 @@ namespace content {
 class WebContents;
 }
 
-namespace views {
-class BlueButton;
-class LabelButton;
-class GridLayout;
-}
-
 // The ManagePasswordsBubbleView controls the contents of the bubble which
 // pops up when Chrome offers to save a user's password, or when the user
 // interacts with the Omnibox icon. It has two distinct states:
@@ -40,124 +25,11 @@ class GridLayout;
 class ManagePasswordsBubbleView : public ManagePasswordsBubble,
                                   public views::BubbleDelegateView {
  public:
-  // A view offering the user the ability to save credentials. Contains a
-  // single ManagePasswordItemView, along with a "Save Passwords" button
-  // and a rejection combobox.
-  class PendingView : public views::View,
-                      public views::ButtonListener,
-                      public views::ComboboxListener {
-   public:
-    explicit PendingView(ManagePasswordsBubbleView* parent);
-    virtual ~PendingView();
-
-   private:
-    // views::ButtonListener:
-    virtual void ButtonPressed(views::Button* sender,
-                               const ui::Event& event) OVERRIDE;
-
-    // Handles the event when the user changes an index of a combobox.
-    virtual void OnPerformAction(views::Combobox* source) OVERRIDE;
-
-    ManagePasswordsBubbleView* parent_;
-
-    views::BlueButton* save_button_;
-
-    // The combobox doesn't take ownership of its model. If we created a
-    // combobox we need to ensure that we delete the model here, and because the
-    // combobox uses the model in it's destructor, we need to make sure we
-    // delete the model _after_ the combobox itself is deleted.
-    scoped_ptr<SavePasswordRefusalComboboxModel> combobox_model_;
-    scoped_ptr<views::Combobox> refuse_combobox_;
-  };
-
-  // A view offering the user the ability to undo her decision to never save
-  // passwords for a particular site.
-  class ConfirmNeverView : public views::View, public views::ButtonListener {
-   public:
-    explicit ConfirmNeverView(ManagePasswordsBubbleView* parent);
-    virtual ~ConfirmNeverView();
-
-   private:
-    // views::ButtonListener:
-    virtual void ButtonPressed(views::Button* sender,
-                               const ui::Event& event) OVERRIDE;
-
-    ManagePasswordsBubbleView* parent_;
-
-    views::LabelButton* confirm_button_;
-    views::LabelButton* undo_button_;
-  };
-
-  // A view offering the user a list of her currently saved credentials
-  // for the current page, along with a "Manage passwords" link and a
-  // "Done" button.
-  class ManageView : public views::View,
-                     public views::ButtonListener,
-                     public views::LinkListener {
-   public:
-    explicit ManageView(ManagePasswordsBubbleView* parent);
-    virtual ~ManageView();
-
-   private:
-    // views::ButtonListener:
-    virtual void ButtonPressed(views::Button* sender,
-                               const ui::Event& event) OVERRIDE;
-
-    // views::LinkListener:
-    virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
-
-    ManagePasswordsBubbleView* parent_;
-
-    views::Link* manage_link_;
-    views::LabelButton* done_button_;
-  };
-
-  // A view offering the user the ability to re-enable the password manager for
-  // a specific site after she's decided to "never save passwords".
-  class BlacklistedView : public views::View, public views::ButtonListener {
-   public:
-    explicit BlacklistedView(ManagePasswordsBubbleView* parent);
-    virtual ~BlacklistedView();
-
-   private:
-    // views::ButtonListener:
-    virtual void ButtonPressed(views::Button* sender,
-                               const ui::Event& event) OVERRIDE;
-
-    ManagePasswordsBubbleView* parent_;
-
-    views::BlueButton* unblacklist_button_;
-    views::LabelButton* done_button_;
-  };
-
-  // A view confirming to the user that a password was saved and offering a link
-  // to the Google account manager.
-  class SaveConfirmationView : public views::View,
-                               public views::ButtonListener,
-                               public views::StyledLabelListener {
-   public:
-    explicit SaveConfirmationView(ManagePasswordsBubbleView* parent);
-    virtual ~SaveConfirmationView();
-
-   private:
-    // views::ButtonListener:
-    virtual void ButtonPressed(views::Button* sender,
-                               const ui::Event& event) OVERRIDE;
-
-    // views::StyledLabelListener implementation
-    virtual void StyledLabelLinkClicked(const gfx::Range& range,
-                                        int event_flags) OVERRIDE;
-
-    ManagePasswordsBubbleView* parent_;
-
-    views::LabelButton* ok_button_;
-  };
-
   // Shows the bubble.
   static void ShowBubble(content::WebContents* web_contents,
                          DisplayReason reason);
 
-  // Closes any existing bubble.
+  // Closes the existing bubble.
   static void CloseBubble();
 
   // Makes the bubble the foreground window.
@@ -171,15 +43,19 @@ class ManagePasswordsBubbleView : public ManagePasswordsBubble,
     return manage_passwords_bubble_;
   }
 
+  content::WebContents* web_contents() const;
+
   const View* initially_focused_view() const {
     return initially_focused_view_;
   }
 
-  bool IsTimerRunning() const {
-    return timer_.IsRunning();
-  }
-
  private:
+  class BlacklistedView;
+  class ConfirmNeverView;
+  class ManageView;
+  class PendingView;
+  class SaveConfirmationView;
+
   ManagePasswordsBubbleView(content::WebContents* web_contents,
                             ManagePasswordsIconView* anchor_view,
                             DisplayReason reason);
@@ -210,22 +86,13 @@ class ManagePasswordsBubbleView : public ManagePasswordsBubble,
   // undo the action and refresh to PendingView.
   void NotifyUndoNeverForThisSite();
 
-  // Starts a timer which will close the bubble if it's inactive.
-  void StartTimerIfNecessary();
-
   // views::BubbleDelegateView:
   virtual void Init() OVERRIDE;
   virtual void WindowClosing() OVERRIDE;
-  virtual void OnWidgetActivationChanged(views::Widget* widget,
-                                         bool active) OVERRIDE;
 
   // views::WidgetDelegate
   virtual views::View* GetInitiallyFocusedView() OVERRIDE;
 
-  // views::View methods.
-  virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
-  virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
-
   void set_initially_focused_view(views::View* view) {
     DCHECK(!initially_focused_view_);
     initially_focused_view_ = view;
@@ -233,7 +100,8 @@ class ManagePasswordsBubbleView : public ManagePasswordsBubble,
 
   // Singleton instance of the Password bubble. The Password bubble can only be
   // shown on the active browser window, so there is no case in which it will be
-  // shown twice at the same time.
+  // shown twice at the same time. The instance is owned by the Bubble and will
+  // be deleted when the bubble closes.
   static ManagePasswordsBubbleView* manage_passwords_bubble_;
 
   ManagePasswordsIconView* anchor_view_;
@@ -244,8 +112,9 @@ class ManagePasswordsBubbleView : public ManagePasswordsBubble,
 
   views::View* initially_focused_view_;
 
-  // Timer used to close the bubble after timeout.
-  base::OneShotTimer<ManagePasswordsBubbleView> timer_;
+  // A helper to intercept mouse click events on the web contents.
+  class WebContentMouseHandler;
+  scoped_ptr<WebContentMouseHandler> mouse_handler_;
 
   DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleView);
 };