| 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 <memory> |
| 9 |
| 8 #include "base/callback.h" | 10 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 10 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 14 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 15 #include "chrome/browser/ui/sync/one_click_signin_bubble_delegate.h" | 16 #include "chrome/browser/ui/sync/one_click_signin_bubble_delegate.h" |
| 16 #include "ui/views/bubble/bubble_delegate.h" | 17 #include "ui/views/bubble/bubble_delegate.h" |
| 17 #include "ui/views/controls/button/button.h" | 18 #include "ui/views/controls/button/button.h" |
| 18 #include "ui/views/controls/link_listener.h" | 19 #include "ui/views/controls/link_listener.h" |
| 19 | 20 |
| 20 namespace views { | 21 namespace views { |
| 21 class GridLayout; | 22 class GridLayout; |
| 22 class ImageButton; | 23 class ImageButton; |
| 23 class LabelButton; | 24 class LabelButton; |
| 24 class View; | 25 class View; |
| 25 } | 26 } |
| 26 | 27 |
| 27 // OneClickSigninBubbleView is a view intended to be used as the content of an | 28 // OneClickSigninBubbleView is a view intended to be used as the content of an |
| 28 // Bubble. It provides simple and concise feedback to the user that sync'ing | 29 // Bubble. It provides simple and concise feedback to the user that sync'ing |
| 29 // has started after using the one-click singin infobar. | 30 // has started after using the one-click singin infobar. |
| 30 class OneClickSigninBubbleView : public views::BubbleDelegateView, | 31 class OneClickSigninBubbleView : public views::BubbleDelegateView, |
| 31 public views::LinkListener, | 32 public views::LinkListener, |
| 32 public views::ButtonListener { | 33 public views::ButtonListener { |
| 33 public: | 34 public: |
| 34 // Show the one-click signin bubble if not already showing. The bubble | 35 // Show the one-click signin bubble if not already showing. The bubble |
| 35 // will be placed visually beneath |anchor_view|. |start_sync| is called | 36 // will be placed visually beneath |anchor_view|. |start_sync| is called |
| 36 // to start sync. | 37 // to start sync. |
| 37 static void ShowBubble(BrowserWindow::OneClickSigninBubbleType type, | 38 static void ShowBubble(BrowserWindow::OneClickSigninBubbleType type, |
| 38 const base::string16& email, | 39 const base::string16& email, |
| 39 const base::string16& error_message, | 40 const base::string16& error_message, |
| 40 scoped_ptr<OneClickSigninBubbleDelegate> delegate, | 41 std::unique_ptr<OneClickSigninBubbleDelegate> delegate, |
| 41 views::View* anchor_view, | 42 views::View* anchor_view, |
| 42 const BrowserWindow::StartSyncCallback& start_sync); | 43 const BrowserWindow::StartSyncCallback& start_sync); |
| 43 | 44 |
| 44 static bool IsShowing(); | 45 static bool IsShowing(); |
| 45 | 46 |
| 46 static void Hide(); | 47 static void Hide(); |
| 47 | 48 |
| 48 // Gets the global bubble view. If its not showing returns NULL. This | 49 // Gets the global bubble view. If its not showing returns NULL. This |
| 49 // method is meant to be called only from tests. | 50 // method is meant to be called only from tests. |
| 50 static OneClickSigninBubbleView* view_for_testing() { return bubble_view_; } | 51 static OneClickSigninBubbleView* view_for_testing() { return bubble_view_; } |
| 51 | 52 |
| 52 protected: | 53 protected: |
| 53 // Creates a OneClickSigninBubbleView. | 54 // Creates a OneClickSigninBubbleView. |
| 54 OneClickSigninBubbleView( | 55 OneClickSigninBubbleView( |
| 55 const base::string16& error_message, | 56 const base::string16& error_message, |
| 56 const base::string16& email, | 57 const base::string16& email, |
| 57 scoped_ptr<OneClickSigninBubbleDelegate> delegate, | 58 std::unique_ptr<OneClickSigninBubbleDelegate> delegate, |
| 58 views::View* anchor_view, | 59 views::View* anchor_view, |
| 59 const BrowserWindow::StartSyncCallback& start_sync_callback, | 60 const BrowserWindow::StartSyncCallback& start_sync_callback, |
| 60 bool is_sync_dialog); | 61 bool is_sync_dialog); |
| 61 | 62 |
| 62 ~OneClickSigninBubbleView() override; | 63 ~OneClickSigninBubbleView() override; |
| 63 | 64 |
| 64 private: | 65 private: |
| 65 friend class OneClickSigninBubbleViewTest; | 66 friend class OneClickSigninBubbleViewTest; |
| 66 | 67 |
| 67 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewTest, BubbleOkButton); | 68 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewTest, BubbleOkButton); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 void GetButtons(views::LabelButton** ok_button, | 100 void GetButtons(views::LabelButton** ok_button, |
| 100 views::LabelButton** undo_button); | 101 views::LabelButton** undo_button); |
| 101 | 102 |
| 102 // Creates learn more link to be used at the bottom of the bubble. | 103 // Creates learn more link to be used at the bottom of the bubble. |
| 103 void InitLearnMoreLink(); | 104 void InitLearnMoreLink(); |
| 104 | 105 |
| 105 // Creates advanced link to be used at the bottom of the bubble. | 106 // Creates advanced link to be used at the bottom of the bubble. |
| 106 void InitAdvancedLink(); | 107 void InitAdvancedLink(); |
| 107 | 108 |
| 108 // Delegate to handle clicking on links in the bubble. | 109 // Delegate to handle clicking on links in the bubble. |
| 109 scoped_ptr<OneClickSigninBubbleDelegate> delegate_; | 110 std::unique_ptr<OneClickSigninBubbleDelegate> delegate_; |
| 110 | 111 |
| 111 // Alternate error message to be displayed. | 112 // Alternate error message to be displayed. |
| 112 const base::string16 error_message_; | 113 const base::string16 error_message_; |
| 113 | 114 |
| 114 // The user's email address to be used for sync. | 115 // The user's email address to be used for sync. |
| 115 const base::string16 email_; | 116 const base::string16 email_; |
| 116 | 117 |
| 117 // This callback is nulled once its called, so that it is called only once. | 118 // This callback is nulled once its called, so that it is called only once. |
| 118 // It will be called when the bubble is closed if it has not been called | 119 // It will be called when the bubble is closed if it has not been called |
| 119 // and nulled earlier. | 120 // and nulled earlier. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 136 | 137 |
| 137 bool clicked_learn_more_; | 138 bool clicked_learn_more_; |
| 138 | 139 |
| 139 // The bubble, if we're showing one. | 140 // The bubble, if we're showing one. |
| 140 static OneClickSigninBubbleView* bubble_view_; | 141 static OneClickSigninBubbleView* bubble_view_; |
| 141 | 142 |
| 142 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleView); | 143 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleView); |
| 143 }; | 144 }; |
| 144 | 145 |
| 145 #endif // CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ | 146 #endif // CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ |
| OLD | NEW |