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" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 class OneClickSigninBubbleView : public views::BubbleDelegateView, | 31 class OneClickSigninBubbleView : public views::BubbleDelegateView, |
| 32 public views::LinkListener, | 32 public views::LinkListener, |
| 33 public views::ButtonListener { | 33 public views::ButtonListener { |
| 34 public: | 34 public: |
| 35 // 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 |
| 36 // will be placed visually beneath |anchor_view|. |start_sync| is called | 36 // will be placed visually beneath |anchor_view|. |start_sync| is called |
| 37 // to start sync. | 37 // to start sync. |
| 38 static void ShowBubble(BrowserWindow::OneClickSigninBubbleType type, | 38 static void ShowBubble(BrowserWindow::OneClickSigninBubbleType type, |
| 39 const string16& email, | 39 const string16& email, |
| 40 ToolbarView* toolbar_view, | 40 ToolbarView* toolbar_view, |
| 41 const BrowserWindow::StartSyncCallback& start_sync); | 41 const BrowserWindow::StartSyncCallback& start_sync, |
| 42 const std::string& error_message); | |
| 42 | 43 |
| 43 static bool IsShowing(); | 44 static bool IsShowing(); |
| 44 | 45 |
| 45 static void Hide(); | 46 static void Hide(); |
| 46 | 47 |
| 47 // Gets the global bubble view. If its not showing returns NULL. This | 48 // Gets the global bubble view. If its not showing returns NULL. This |
| 48 // method is meant to be called only from tests. | 49 // method is meant to be called only from tests. |
| 49 static OneClickSigninBubbleView* view_for_testing() { return bubble_view_; } | 50 static OneClickSigninBubbleView* view_for_testing() { return bubble_view_; } |
| 50 | 51 |
| 51 protected: | 52 protected: |
| 52 // Creates a OneClickSigninBubbleView. | 53 // Creates a OneClickSigninBubbleView. |
| 53 OneClickSigninBubbleView( | 54 OneClickSigninBubbleView( |
| 55 content::WebContents* web_content, | |
| 54 views::View* anchor_view, | 56 views::View* anchor_view, |
| 55 const BrowserWindow::StartSyncCallback& start_sync_callback); | 57 const std::string& error_message); |
| 56 | 58 |
| 57 virtual ~OneClickSigninBubbleView(); | 59 virtual ~OneClickSigninBubbleView(); |
| 58 | 60 |
| 59 // Overridden from views::LinkListener: | 61 // Overridden from views::LinkListener: |
| 60 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 62 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
| 61 | 63 |
| 62 // Overridden from views::ButtonListener: | 64 // Overridden from views::ButtonListener: |
| 63 virtual void ButtonPressed(views::Button* sender, | 65 virtual void ButtonPressed(views::Button* sender, |
| 64 const ui::Event& event) OVERRIDE; | 66 const ui::Event& event) OVERRIDE; |
| 65 | 67 |
| 68 // views::View method: | |
| 69 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | |
| 70 | |
| 71 // Creates learn more link to be used at the bottom of the bubble. | |
| 72 // Derived classes can reimplement. The caller of this function owns the | |
| 73 // returned link. | |
| 74 virtual views::Link* GetLearnMoreLink(); | |
| 75 | |
| 76 // Creates advanced link to be used at the bottom of the bubble. | |
| 77 // Derived classes can reimplement. The caller of this function owns the | |
| 78 // returned link. | |
| 79 virtual views::Link* GetAdvancedLink(); | |
| 80 | |
| 81 // views::WidgetDelegate method: | |
| 82 virtual void WindowClosing() OVERRIDE; | |
| 83 | |
| 84 // Link to sync setup advanced page. | |
| 85 views::Link* advanced_link_; | |
| 86 | |
| 87 // Link to the Learn More details page | |
| 88 views::Link* learn_more_link_; | |
| 89 | |
| 90 // Controls at bottom of bubble. | |
| 91 views::LabelButton* ok_button_; | |
| 92 views::LabelButton* undo_button_; | |
| 93 | |
| 94 content::WebContents* web_content_; | |
| 95 | |
| 66 private: | 96 private: |
| 67 friend class OneClickSigninBubbleViewBrowserTest; | 97 friend class OneClickSigninBubbleViewBrowserTest; |
| 68 | 98 |
| 69 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewBrowserTest, OkButton); | 99 FRIEND_TEST_ALL_PREFIXES( |
| 70 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewBrowserTest, UndoButton); | 100 OneClickSigninBubbleViewBrowserTest, BubbleOkButton); |
| 71 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewBrowserTest, AdvancedLink); | 101 FRIEND_TEST_ALL_PREFIXES( |
| 72 | 102 OneClickSigninBubbleViewBrowserTest, DialogOkButton); |
| 103 FRIEND_TEST_ALL_PREFIXES( | |
| 104 OneClickSigninBubbleViewBrowserTest, DialogUndoButton); | |
| 105 FRIEND_TEST_ALL_PREFIXES( | |
| 106 OneClickSigninBubbleViewBrowserTest, BubbleAdvancedLink); | |
| 107 FRIEND_TEST_ALL_PREFIXES( | |
| 108 OneClickSigninBubbleViewBrowserTest, DialogAdvancedLink); | |
| 109 FRIEND_TEST_ALL_PREFIXES( | |
| 110 OneClickSigninBubbleViewBrowserTest, BubbleLearnMoreLink); | |
| 111 FRIEND_TEST_ALL_PREFIXES( | |
| 112 OneClickSigninBubbleViewBrowserTest, DialogLearnMoreLink); | |
| 73 // views::BubbleDelegateView methods: | 113 // views::BubbleDelegateView methods: |
| 74 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 114 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; |
| 75 virtual void Init() OVERRIDE; | 115 virtual void Init() OVERRIDE; |
| 76 | 116 |
| 77 // Method to build the main part of the bubble. Derived classes should | 117 // Method to build the main part of the bubble. Derived classes should |
| 78 // reimplement this function. | 118 // reimplement this function. |
| 79 virtual void InitContent(views::GridLayout* layout); | 119 virtual void InitContent(views::GridLayout* layout); |
| 120 virtual void InitButtons(views::GridLayout* layout); | |
| 80 | 121 |
| 81 // Creates OK and Undo buttons to be used at the bottom of the bubble. | 122 // Creates OK/Undo button to be used at the bottom of the bubble. |
| 123 // By default, the Undo button is not implemented | |
|
bcwhite
2013/04/16 15:22:00
Not implemented? Meaning it can return NULL?
noms (inactive)
2013/04/16 17:15:37
Oops. Just meant it's not initially displayed. Hav
| |
| 82 // Derived classes can reimplement to have buttons with different labels, | 124 // Derived classes can reimplement to have buttons with different labels, |
| 83 // colours, or sizes. The caller of this function owns the returned buttons. | 125 // colours, or sizes. The caller of this function owns the returned buttons. |
| 84 virtual void GetButtons(views::LabelButton** ok_button, | 126 virtual void GetButtons(views::LabelButton** ok_button, |
| 85 views::LabelButton** undo_button); | 127 views::LabelButton** undo_button); |
| 86 | 128 |
| 87 // Creates advanced link to be used at the bottom of the bubble. | |
| 88 // Derived classes can reimplement. The caller of this function owns the | |
| 89 // returned link. | |
| 90 virtual views::Link* GetAdvancedLink(); | |
| 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 | |
| 98 // The bubble, if we're showing one. | 129 // The bubble, if we're showing one. |
| 99 static OneClickSigninBubbleView* bubble_view_; | 130 static OneClickSigninBubbleView* bubble_view_; |
| 100 | 131 |
| 101 // Link to sync setup advanced page. | |
| 102 views::Link* advanced_link_; | |
| 103 | |
| 104 // Controls at bottom of bubble. | |
| 105 views::LabelButton* ok_button_; | |
| 106 views::LabelButton* undo_button_; | |
| 107 | |
| 108 // This callback is nulled once its called, so that it is called only once. | |
| 109 // It will be called when the bubble is closed if it has not been called | |
| 110 // and nulled earlier. | |
| 111 BrowserWindow::StartSyncCallback start_sync_callback_; | |
| 112 | |
| 113 // A message loop used only with unit tests. | 132 // A message loop used only with unit tests. |
| 114 base::MessageLoop* message_loop_for_testing_; | 133 base::MessageLoop* message_loop_for_testing_; |
| 115 | 134 |
| 135 // Alternate error message to be displayed | |
| 136 std::string error_message_; | |
| 137 | |
| 116 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleView); | 138 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleView); |
| 117 }; | 139 }; |
| 118 | 140 |
| 119 #endif // CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ | 141 #endif // CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ |
| OLD | NEW |