| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/gtest_prod_util.h" |
| 12 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "chrome/browser/ui/browser_window.h" |
| 13 #include "ui/views/bubble/bubble_delegate.h" | 15 #include "ui/views/bubble/bubble_delegate.h" |
| 14 #include "ui/views/controls/button/button.h" | 16 #include "ui/views/controls/button/button.h" |
| 15 #include "ui/views/controls/link_listener.h" | 17 #include "ui/views/controls/link_listener.h" |
| 16 | 18 |
| 17 class MessageLoop; | 19 class MessageLoop; |
| 18 | 20 |
| 19 namespace views { | 21 namespace views { |
| 20 class TextButton; | 22 class TextButton; |
| 21 } | 23 } |
| 22 | 24 |
| 23 // OneClickSigninBubbleView is a view intended to be used as the content of an | 25 // OneClickSigninBubbleView is a view intended to be used as the content of an |
| 24 // Bubble. It provides simple and concise feedback to the user that sync'ing | 26 // Bubble. It provides simple and concise feedback to the user that sync'ing |
| 25 // has started after using the one-click singin infobar. | 27 // has started after using the one-click singin infobar. |
| 26 class OneClickSigninBubbleView : public views::BubbleDelegateView, | 28 class OneClickSigninBubbleView : public views::BubbleDelegateView, |
| 27 public views::LinkListener, | 29 public views::LinkListener, |
| 28 public views::ButtonListener { | 30 public views::ButtonListener { |
| 29 public: | 31 public: |
| 30 // Show the one-click signin bubble if not already showing. The bubble | 32 // Show the one-click signin bubble if not already showing. The bubble |
| 31 // will be placed visually beneath |anchor_view|. The |browser| is used | 33 // will be placed visually beneath |anchor_view|. |start_sync| is called |
| 32 // to open links. | 34 // to start sync. |
| 33 static void ShowBubble(views::View* anchor_view, | 35 static void ShowBubble(views::View* anchor_view, |
| 34 const base::Closure& learn_more_callback, | 36 const BrowserWindow::StartSyncCallback& start_sync); |
| 35 const base::Closure& advanced_callback); | |
| 36 | 37 |
| 37 static bool IsShowing(); | 38 static bool IsShowing(); |
| 38 | 39 |
| 39 static void Hide(); | 40 static void Hide(); |
| 40 | 41 |
| 41 // Gets the global bubble view. If its not showing returns NULL. This | 42 // Gets the global bubble view. If its not showing returns NULL. This |
| 42 // method is meant to be called only from tests. | 43 // method is meant to be called only from tests. |
| 43 static OneClickSigninBubbleView* view_for_testing() { return bubble_view_; } | 44 static OneClickSigninBubbleView* view_for_testing() { return bubble_view_; } |
| 44 | 45 |
| 45 // The following accessor message should only be used for testing. | 46 private: |
| 46 views::Link* learn_more_link_for_testing() const { return learn_more_link_; } | 47 friend class OneClickSigninBubbleViewBrowserTest; |
| 47 views::Link* advanced_link_for_testing() const { return advanced_link_; } | |
| 48 views::TextButton* close_button_for_testing() const { return close_button_; } | |
| 49 void set_message_loop_for_testing(MessageLoop* loop) { | |
| 50 message_loop_for_testing_ = loop; | |
| 51 } | |
| 52 | 48 |
| 53 private: | 49 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewBrowserTest, OkButton); |
| 54 // Creates a BookmarkBubbleView. | 50 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewBrowserTest, UndoButton); |
| 55 OneClickSigninBubbleView(views::View* anchor_view, | 51 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewBrowserTest, AdvancedLink); |
| 56 const base::Closure& learn_more_callback, | 52 |
| 57 const base::Closure& advanced_callback); | 53 // Creates a OneClickSigninBubbleView. |
| 54 OneClickSigninBubbleView( |
| 55 views::View* anchor_view, |
| 56 const BrowserWindow::StartSyncCallback& start_sync_callback); |
| 58 | 57 |
| 59 virtual ~OneClickSigninBubbleView(); | 58 virtual ~OneClickSigninBubbleView(); |
| 60 | 59 |
| 61 // views::BubbleDelegateView methods: | 60 // views::BubbleDelegateView methods: |
| 62 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 61 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; |
| 63 virtual void Init() OVERRIDE; | 62 virtual void Init() OVERRIDE; |
| 64 | 63 |
| 65 // views::WidgetDelegate method: | 64 // views::WidgetDelegate method: |
| 66 virtual void WindowClosing() OVERRIDE; | 65 virtual void WindowClosing() OVERRIDE; |
| 67 | 66 |
| 68 // views::View method: | 67 // views::View method: |
| 69 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | 68 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
| 70 | 69 |
| 71 // Overridden from views::LinkListener: | 70 // Overridden from views::LinkListener: |
| 72 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 71 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
| 73 | 72 |
| 74 // Overridden from views::ButtonListener: | 73 // Overridden from views::ButtonListener: |
| 75 virtual void ButtonPressed(views::Button* sender, | 74 virtual void ButtonPressed(views::Button* sender, |
| 76 const views::Event& event) OVERRIDE; | 75 const views::Event& event) OVERRIDE; |
| 77 | 76 |
| 78 // The bubble, if we're showing one. | 77 // The bubble, if we're showing one. |
| 79 static OneClickSigninBubbleView* bubble_view_; | 78 static OneClickSigninBubbleView* bubble_view_; |
| 80 | 79 |
| 81 // Link to web page to learn more about sync. | |
| 82 views::Link* learn_more_link_; | |
| 83 | |
| 84 // Link to sync setup advanced page. | 80 // Link to sync setup advanced page. |
| 85 views::Link* advanced_link_; | 81 views::Link* advanced_link_; |
| 86 | 82 |
| 87 // Button to close the window. | 83 // Controls at bottom of bubble. |
| 88 views::TextButton* close_button_; | 84 views::TextButton* ok_button_; |
| 85 views::TextButton* undo_button_; |
| 89 | 86 |
| 90 // The callbacks for the links. | 87 // This callback is nulled once its called, so that it is called only once. |
| 91 base::Closure learn_more_callback_; | 88 // It will be called when the bubble is closed if it has not been called |
| 92 base::Closure advanced_callback_; | 89 // and nulled earlier. |
| 90 BrowserWindow::StartSyncCallback start_sync_callback_; |
| 93 | 91 |
| 94 // A message loop used only with unit tests. | 92 // A message loop used only with unit tests. |
| 95 MessageLoop* message_loop_for_testing_; | 93 MessageLoop* message_loop_for_testing_; |
| 96 | 94 |
| 97 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleView); | 95 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleView); |
| 98 }; | 96 }; |
| 99 | 97 |
| 100 #endif // CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ | 98 #endif // CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ |
| OLD | NEW |