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 #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/string16.h" | 12 #include "base/string16.h" |
| 13 #include "chrome/browser/ui/browser_window.h" | |
| 13 #include "ui/views/bubble/bubble_delegate.h" | 14 #include "ui/views/bubble/bubble_delegate.h" |
| 14 #include "ui/views/controls/button/button.h" | 15 #include "ui/views/controls/button/button.h" |
| 15 #include "ui/views/controls/link_listener.h" | 16 #include "ui/views/controls/link_listener.h" |
| 16 | 17 |
| 17 class MessageLoop; | 18 class MessageLoop; |
| 18 | 19 |
| 19 namespace views { | 20 namespace views { |
| 20 class TextButton; | 21 class TextButton; |
| 21 } | 22 } |
| 22 | 23 |
| 23 // OneClickSigninBubbleView is a view intended to be used as the content of an | 24 // 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 | 25 // Bubble. It provides simple and concise feedback to the user that sync'ing |
| 25 // has started after using the one-click singin infobar. | 26 // has started after using the one-click singin infobar. |
| 26 class OneClickSigninBubbleView : public views::BubbleDelegateView, | 27 class OneClickSigninBubbleView : public views::BubbleDelegateView, |
| 27 public views::LinkListener, | 28 public views::LinkListener, |
| 28 public views::ButtonListener { | 29 public views::ButtonListener { |
| 29 public: | 30 public: |
| 30 // Show the one-click signin bubble if not already showing. The bubble | 31 // Show the one-click signin bubble if not already showing. The bubble |
| 31 // will be placed visually beneath |anchor_view|. The |browser| is used | 32 // will be placed visually beneath |anchor_view|. The closures are called |
| 32 // to open links. | 33 // to open the corresponding links, and the callback is used to start sync. |
| 34 // The bool argument indicates if default sync settings should be used. | |
| 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 // The following accessor message should only be used for testing. |
| 46 views::Link* learn_more_link_for_testing() const { return learn_more_link_; } | |
| 47 views::Link* advanced_link_for_testing() const { return advanced_link_; } | 47 views::Link* advanced_link_for_testing() const { return advanced_link_; } |
| 48 views::TextButton* close_button_for_testing() const { return close_button_; } | 48 views::TextButton* ok_button_for_testing() const { return ok_button_; } |
| 49 views::TextButton* undo_button_for_testing() const { return undo_button_; } | |
| 49 void set_message_loop_for_testing(MessageLoop* loop) { | 50 void set_message_loop_for_testing(MessageLoop* loop) { |
| 50 message_loop_for_testing_ = loop; | 51 message_loop_for_testing_ = loop; |
| 51 } | 52 } |
| 52 | 53 |
| 53 private: | 54 private: |
| 54 // Creates a BookmarkBubbleView. | 55 // Creates a BookmarkBubbleView. |
| 55 OneClickSigninBubbleView(views::View* anchor_view, | 56 OneClickSigninBubbleView( |
| 56 const base::Closure& learn_more_callback, | 57 views::View* anchor_view, |
| 57 const base::Closure& advanced_callback); | 58 const BrowserWindow::StartSyncCallback& start_sync_callback); |
| 58 | 59 |
| 59 virtual ~OneClickSigninBubbleView(); | 60 virtual ~OneClickSigninBubbleView(); |
| 60 | 61 |
| 61 // views::BubbleDelegateView methods: | 62 // views::BubbleDelegateView methods: |
| 62 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 63 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; |
| 63 virtual void Init() OVERRIDE; | 64 virtual void Init() OVERRIDE; |
| 64 | 65 |
| 65 // views::WidgetDelegate method: | 66 // views::WidgetDelegate method: |
| 66 virtual void WindowClosing() OVERRIDE; | 67 virtual void WindowClosing() OVERRIDE; |
| 67 | 68 |
| 68 // views::View method: | 69 // views::View method: |
| 69 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | 70 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
| 70 | 71 |
| 71 // Overridden from views::LinkListener: | 72 // Overridden from views::LinkListener: |
| 72 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 73 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
| 73 | 74 |
| 74 // Overridden from views::ButtonListener: | 75 // Overridden from views::ButtonListener: |
| 75 virtual void ButtonPressed(views::Button* sender, | 76 virtual void ButtonPressed(views::Button* sender, |
| 76 const views::Event& event) OVERRIDE; | 77 const views::Event& event) OVERRIDE; |
| 77 | 78 |
| 78 // The bubble, if we're showing one. | 79 // The bubble, if we're showing one. |
| 79 static OneClickSigninBubbleView* bubble_view_; | 80 static OneClickSigninBubbleView* bubble_view_; |
| 80 | 81 |
| 81 // Link to web page to learn more about sync. | |
| 82 views::Link* learn_more_link_; | |
| 83 | |
| 84 // Link to sync setup advanced page. | 82 // Link to sync setup advanced page. |
| 85 views::Link* advanced_link_; | 83 views::Link* advanced_link_; |
| 86 | 84 |
| 87 // Button to close the window. | 85 // Controls at buttom of bubble. |
| 88 views::TextButton* close_button_; | 86 views::TextButton* ok_button_; |
| 87 views::TextButton* undo_button_; | |
| 89 | 88 |
| 90 // The callbacks for the links. | 89 BrowserWindow::StartSyncCallback start_sync_callback_; |
|
akalin
2012/05/24 18:42:04
comment explaining that the callback is nulled out
Roger Tawa OOO till Jul 10th
2012/05/24 19:08:33
Done.
| |
| 91 base::Closure learn_more_callback_; | |
| 92 base::Closure advanced_callback_; | |
| 93 | 90 |
| 94 // A message loop used only with unit tests. | 91 // A message loop used only with unit tests. |
| 95 MessageLoop* message_loop_for_testing_; | 92 MessageLoop* message_loop_for_testing_; |
| 96 | 93 |
| 97 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleView); | 94 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleView); |
| 98 }; | 95 }; |
| 99 | 96 |
| 100 #endif // CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ | 97 #endif // CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ |
| OLD | NEW |