| 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 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h" | 5 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 8 #include "base/logging.h" | 10 #include "base/logging.h" |
| 9 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
| 11 #include "chrome/grit/chromium_strings.h" | 13 #include "chrome/grit/chromium_strings.h" |
| 12 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
| 13 #include "components/google/core/browser/google_util.h" | 15 #include "components/google/core/browser/google_util.h" |
| 14 #include "grit/components_strings.h" | 16 #include "grit/components_strings.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 const base::string16& error_message, | 56 const base::string16& error_message, |
| 55 scoped_ptr<OneClickSigninBubbleDelegate> delegate, | 57 scoped_ptr<OneClickSigninBubbleDelegate> delegate, |
| 56 views::View* anchor_view, | 58 views::View* anchor_view, |
| 57 const BrowserWindow::StartSyncCallback& start_sync) { | 59 const BrowserWindow::StartSyncCallback& start_sync) { |
| 58 if (IsShowing()) | 60 if (IsShowing()) |
| 59 return; | 61 return; |
| 60 | 62 |
| 61 switch (type) { | 63 switch (type) { |
| 62 case BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE: | 64 case BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE: |
| 63 bubble_view_ = new OneClickSigninBubbleView( | 65 bubble_view_ = new OneClickSigninBubbleView( |
| 64 error_message, base::string16(), delegate.Pass(), | 66 error_message, base::string16(), std::move(delegate), anchor_view, |
| 65 anchor_view, start_sync, false); | 67 start_sync, false); |
| 66 break; | 68 break; |
| 67 case BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG: | 69 case BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG: |
| 68 bubble_view_ = new OneClickSigninBubbleView( | 70 bubble_view_ = new OneClickSigninBubbleView( |
| 69 base::string16(), base::string16(), delegate.Pass(), | 71 base::string16(), base::string16(), std::move(delegate), anchor_view, |
| 70 anchor_view, start_sync, true); | 72 start_sync, true); |
| 71 break; | 73 break; |
| 72 case BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_SAML_MODAL_DIALOG: | 74 case BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_SAML_MODAL_DIALOG: |
| 73 bubble_view_ = new OneClickSigninBubbleView( | 75 bubble_view_ = new OneClickSigninBubbleView( |
| 74 base::string16(), email, delegate.Pass(), | 76 base::string16(), email, std::move(delegate), anchor_view, start_sync, |
| 75 anchor_view, start_sync, true); | 77 true); |
| 76 break; | 78 break; |
| 77 } | 79 } |
| 78 | 80 |
| 79 views::BubbleDelegateView::CreateBubble(bubble_view_)->Show(); | 81 views::BubbleDelegateView::CreateBubble(bubble_view_)->Show(); |
| 80 } | 82 } |
| 81 | 83 |
| 82 // static | 84 // static |
| 83 bool OneClickSigninBubbleView::IsShowing() { | 85 bool OneClickSigninBubbleView::IsShowing() { |
| 84 return bubble_view_ != NULL; | 86 return bubble_view_ != NULL; |
| 85 } | 87 } |
| 86 | 88 |
| 87 // static | 89 // static |
| 88 void OneClickSigninBubbleView::Hide() { | 90 void OneClickSigninBubbleView::Hide() { |
| 89 if (IsShowing()) | 91 if (IsShowing()) |
| 90 bubble_view_->GetWidget()->Close(); | 92 bubble_view_->GetWidget()->Close(); |
| 91 } | 93 } |
| 92 | 94 |
| 93 OneClickSigninBubbleView::OneClickSigninBubbleView( | 95 OneClickSigninBubbleView::OneClickSigninBubbleView( |
| 94 const base::string16& error_message, | 96 const base::string16& error_message, |
| 95 const base::string16& email, | 97 const base::string16& email, |
| 96 scoped_ptr<OneClickSigninBubbleDelegate> delegate, | 98 scoped_ptr<OneClickSigninBubbleDelegate> delegate, |
| 97 views::View* anchor_view, | 99 views::View* anchor_view, |
| 98 const BrowserWindow::StartSyncCallback& start_sync_callback, | 100 const BrowserWindow::StartSyncCallback& start_sync_callback, |
| 99 bool is_sync_dialog) | 101 bool is_sync_dialog) |
| 100 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), | 102 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), |
| 101 delegate_(delegate.Pass()), | 103 delegate_(std::move(delegate)), |
| 102 error_message_(error_message), | 104 error_message_(error_message), |
| 103 email_(email), | 105 email_(email), |
| 104 start_sync_callback_(start_sync_callback), | 106 start_sync_callback_(start_sync_callback), |
| 105 is_sync_dialog_(is_sync_dialog), | 107 is_sync_dialog_(is_sync_dialog), |
| 106 advanced_link_(NULL), | 108 advanced_link_(NULL), |
| 107 learn_more_link_(NULL), | 109 learn_more_link_(NULL), |
| 108 ok_button_(NULL), | 110 ok_button_(NULL), |
| 109 undo_button_(NULL), | 111 undo_button_(NULL), |
| 110 close_button_(NULL), | 112 close_button_(NULL), |
| 111 clicked_learn_more_(false) { | 113 clicked_learn_more_(false) { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 // we'll be destroyed asynchronously and the shown state will be checked | 408 // we'll be destroyed asynchronously and the shown state will be checked |
| 407 // before then. | 409 // before then. |
| 408 DCHECK_EQ(bubble_view_, this); | 410 DCHECK_EQ(bubble_view_, this); |
| 409 bubble_view_ = NULL; | 411 bubble_view_ = NULL; |
| 410 | 412 |
| 411 if (is_sync_dialog_ && !start_sync_callback_.is_null()) { | 413 if (is_sync_dialog_ && !start_sync_callback_.is_null()) { |
| 412 base::ResetAndReturn(&start_sync_callback_).Run( | 414 base::ResetAndReturn(&start_sync_callback_).Run( |
| 413 OneClickSigninSyncStarter::UNDO_SYNC); | 415 OneClickSigninSyncStarter::UNDO_SYNC); |
| 414 } | 416 } |
| 415 } | 417 } |
| OLD | NEW |