Home | History | Annotate | Download | only in login
      1 // Copyright (c) 2011 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_CHROMEOS_LOGIN_MESSAGE_BUBBLE_H_
      6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MESSAGE_BUBBLE_H_
      7 #pragma once
      8 
      9 #include "chrome/browser/ui/views/bubble/bubble.h"
     10 #include "views/controls/button/button.h"
     11 #include "views/controls/link.h"
     12 #include "views/view.h"
     13 #include "views/widget/widget_gtk.h"
     14 
     15 class SkBitmap;
     16 
     17 namespace views {
     18 class ImageButton;
     19 class ImageView;
     20 class Label;
     21 }
     22 
     23 namespace chromeos {
     24 
     25 class MessageBubbleDelegate : public BubbleDelegate {
     26  public:
     27   // Called when the user clicked on help link.
     28   virtual void OnHelpLinkActivated() = 0;
     29 };
     30 
     31 // MessageBubble is used to show error and info messages on OOBE screens.
     32 class MessageBubble : public Bubble,
     33                       public views::ButtonListener,
     34                       public views::LinkController {
     35  public:
     36   // Create and show bubble. position_relative_to must be in screen coordinates.
     37   static MessageBubble* Show(views::Widget* parent,
     38                              const gfx::Rect& position_relative_to,
     39                              BubbleBorder::ArrowLocation arrow_location,
     40                              SkBitmap* image,
     41                              const std::wstring& text,
     42                              const std::wstring& help,
     43                              MessageBubbleDelegate* delegate);
     44 
     45   // Create and show bubble which does not grab pointer.  This creates
     46   // a TYPE_CHILD WidgetGtk and |position_relative_to| must be in parent's
     47   // coordinates.
     48   static MessageBubble* ShowNoGrab(views::Widget* parent,
     49                                    const gfx::Rect& position_relative_to,
     50                                    BubbleBorder::ArrowLocation arrow_location,
     51                                    SkBitmap* image,
     52                                    const std::wstring& text,
     53                                    const std::wstring& help,
     54                                    MessageBubbleDelegate* delegate);
     55 
     56   // Overridden from WidgetGtk.
     57   virtual void Close() OVERRIDE;
     58 
     59   virtual gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event) {
     60     WidgetGtk::OnButtonPress(widget, event);
     61     // Never propagate event to parent.
     62     return true;
     63   }
     64 
     65  protected:
     66   // Overridden from views::ButtonListener:
     67   virtual void ButtonPressed(views::Button* sender,
     68                              const views::Event& event);
     69 
     70   // Overridden from views::LinkController:
     71   virtual void LinkActivated(views::Link* source, int event_flags);
     72 
     73   // Overridden from WidgetGtk.
     74   virtual void IsActiveChanged();
     75   virtual void SetMouseCapture();
     76 
     77  private:
     78   MessageBubble(views::WidgetGtk::Type type,
     79                 views::Widget* parent,
     80                 SkBitmap* image,
     81                 const std::wstring& text,
     82                 const std::wstring& help,
     83                 bool grab_enabled,
     84                 MessageBubbleDelegate* delegate);
     85 
     86   views::Widget* parent_;
     87   views::ImageView* icon_;
     88   views::Label* text_;
     89   views::ImageButton* close_button_;
     90   views::Link* help_link_;
     91   MessageBubbleDelegate* message_delegate_;
     92   bool grab_enabled_;
     93 
     94   DISALLOW_COPY_AND_ASSIGN(MessageBubble);
     95 };
     96 
     97 }  // namespace chromeos
     98 
     99 #endif  // CHROME_BROWSER_CHROMEOS_LOGIN_MESSAGE_BUBBLE_H_
    100