Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
| 14 #include "chrome/browser/ui/views/toolbar_view.h" | |
| 14 #include "ui/views/bubble/bubble_delegate.h" | 15 #include "ui/views/bubble/bubble_delegate.h" |
| 15 #include "ui/views/controls/button/button.h" | 16 #include "ui/views/controls/button/button.h" |
| 16 #include "ui/views/controls/link_listener.h" | 17 #include "ui/views/controls/link_listener.h" |
| 17 | 18 |
| 18 class MessageLoop; | 19 class MessageLoop; |
| 19 | 20 |
| 20 namespace views { | 21 namespace views { |
| 22 class GridLayout; | |
| 21 class TextButton; | 23 class TextButton; |
| 22 } | 24 } |
| 23 | 25 |
| 24 // OneClickSigninBubbleView is a view intended to be used as the content of an | 26 // OneClickSigninBubbleView is a view intended to be used as the content of an |
| 25 // Bubble. It provides simple and concise feedback to the user that sync'ing | 27 // Bubble. It provides simple and concise feedback to the user that sync'ing |
| 26 // has started after using the one-click singin infobar. | 28 // has started after using the one-click singin infobar. |
| 27 class OneClickSigninBubbleView : public views::BubbleDelegateView, | 29 class OneClickSigninBubbleView : public views::BubbleDelegateView, |
| 28 public views::LinkListener, | 30 public views::LinkListener, |
| 29 public views::ButtonListener { | 31 public views::ButtonListener { |
| 30 public: | 32 public: |
| 33 // The column set constants thaat can be used in the InitContent() function | |
| 34 // to layout views. | |
| 35 enum { | |
| 36 kColumnSetFillAlign, | |
|
tfarina
2013/01/22 19:22:48
why do you need this here, in the public section?
Roger Tawa OOO till Jul 10th
2013/01/22 21:32:35
Made it protected. I want to expose it to derived
| |
| 37 kColumnSetControls, | |
| 38 kColumnSetLast = kColumnSetControls | |
| 39 }; | |
| 40 | |
| 31 // Show the one-click signin bubble if not already showing. The bubble | 41 // Show the one-click signin bubble if not already showing. The bubble |
| 32 // will be placed visually beneath |anchor_view|. |start_sync| is called | 42 // will be placed visually beneath |anchor_view|. |start_sync| is called |
| 33 // to start sync. | 43 // to start sync. |
| 34 static void ShowBubble(views::View* anchor_view, | 44 static void ShowBubble(BrowserWindow::OneClickSigninBubbleType type, |
| 45 ToolbarView* toolbar_view, | |
| 35 const BrowserWindow::StartSyncCallback& start_sync); | 46 const BrowserWindow::StartSyncCallback& start_sync); |
| 36 | 47 |
| 37 static bool IsShowing(); | 48 static bool IsShowing(); |
| 38 | 49 |
| 39 static void Hide(); | 50 static void Hide(); |
| 40 | 51 |
| 41 // Gets the global bubble view. If its not showing returns NULL. This | 52 // Gets the global bubble view. If its not showing returns NULL. This |
| 42 // method is meant to be called only from tests. | 53 // method is meant to be called only from tests. |
| 43 static OneClickSigninBubbleView* view_for_testing() { return bubble_view_; } | 54 static OneClickSigninBubbleView* view_for_testing() { return bubble_view_; } |
| 44 | 55 |
| 45 private: | 56 protected: |
| 46 friend class OneClickSigninBubbleViewBrowserTest; | |
| 47 | |
| 48 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewBrowserTest, OkButton); | |
| 49 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewBrowserTest, UndoButton); | |
| 50 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewBrowserTest, AdvancedLink); | |
| 51 | |
| 52 // Creates a OneClickSigninBubbleView. | 57 // Creates a OneClickSigninBubbleView. |
| 53 OneClickSigninBubbleView( | 58 OneClickSigninBubbleView( |
| 54 views::View* anchor_view, | 59 views::View* anchor_view, |
| 55 const BrowserWindow::StartSyncCallback& start_sync_callback); | 60 const BrowserWindow::StartSyncCallback& start_sync_callback); |
| 56 | 61 |
| 57 virtual ~OneClickSigninBubbleView(); | 62 virtual ~OneClickSigninBubbleView(); |
| 58 | 63 |
| 59 // views::BubbleDelegateView methods: | |
| 60 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | |
| 61 virtual void Init() OVERRIDE; | |
| 62 | |
| 63 // views::WidgetDelegate method: | |
| 64 virtual void WindowClosing() OVERRIDE; | |
| 65 | |
| 66 // views::View method: | |
| 67 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | |
| 68 | |
| 69 // Overridden from views::LinkListener: | 64 // Overridden from views::LinkListener: |
| 70 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 65 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
| 71 | 66 |
| 72 // Overridden from views::ButtonListener: | 67 // Overridden from views::ButtonListener: |
| 73 virtual void ButtonPressed(views::Button* sender, | 68 virtual void ButtonPressed(views::Button* sender, |
| 74 const ui::Event& event) OVERRIDE; | 69 const ui::Event& event) OVERRIDE; |
| 75 | 70 |
| 71 private: | |
| 72 friend class OneClickSigninBubbleViewBrowserTest; | |
| 73 | |
| 74 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewBrowserTest, OkButton); | |
| 75 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewBrowserTest, UndoButton); | |
| 76 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewBrowserTest, AdvancedLink); | |
| 77 | |
| 78 // views::BubbleDelegateView methods: | |
| 79 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | |
| 80 virtual void Init() OVERRIDE; | |
| 81 | |
| 82 // Method to build the main part of the bubble. Derived classes should | |
| 83 // reimplement this function. | |
| 84 virtual void InitContent(views::GridLayout* layout); | |
| 85 | |
| 86 // Creates OK and Undo buttons to be used at the bottom of the bubble. | |
| 87 // Derived classes can reimplement to have buttons with different labels, | |
| 88 // colours, or sizes. The caller of this function owns the returned buttons. | |
| 89 virtual void GetButtons(views::TextButton** ok_button, | |
| 90 views::TextButton** undo_button); | |
| 91 | |
| 92 // views::WidgetDelegate method: | |
| 93 virtual void WindowClosing() OVERRIDE; | |
| 94 | |
| 95 // views::View method: | |
| 96 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | |
| 97 | |
| 76 // The bubble, if we're showing one. | 98 // The bubble, if we're showing one. |
| 77 static OneClickSigninBubbleView* bubble_view_; | 99 static OneClickSigninBubbleView* bubble_view_; |
| 78 | 100 |
| 79 // Link to sync setup advanced page. | 101 // Link to sync setup advanced page. |
| 80 views::Link* advanced_link_; | 102 views::Link* advanced_link_; |
| 81 | 103 |
| 82 // Controls at bottom of bubble. | 104 // Controls at bottom of bubble. |
| 83 views::TextButton* ok_button_; | 105 views::TextButton* ok_button_; |
| 84 views::TextButton* undo_button_; | 106 views::TextButton* undo_button_; |
| 85 | 107 |
| 86 // This callback is nulled once its called, so that it is called only once. | 108 // This callback is nulled once its called, so that it is called only once. |
| 87 // It will be called when the bubble is closed if it has not been called | 109 // It will be called when the bubble is closed if it has not been called |
| 88 // and nulled earlier. | 110 // and nulled earlier. |
| 89 BrowserWindow::StartSyncCallback start_sync_callback_; | 111 BrowserWindow::StartSyncCallback start_sync_callback_; |
| 90 | 112 |
| 91 // A message loop used only with unit tests. | 113 // A message loop used only with unit tests. |
| 92 MessageLoop* message_loop_for_testing_; | 114 MessageLoop* message_loop_for_testing_; |
| 93 | 115 |
| 94 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleView); | 116 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleView); |
| 95 }; | 117 }; |
| 96 | 118 |
| 97 #endif // CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ | 119 #endif // CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ |
| OLD | NEW |