| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/profiles/forced_reauthentication_dialog.h" | 5 #include "chrome/browser/ui/views/profiles/forced_reauthentication_dialog.h" |
| 6 | 6 |
| 7 #include <map> |
| 7 #include <memory> | 8 #include <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 #include <utility> | 10 #include <utility> |
| 10 | 11 |
| 11 #include "base/i18n/message_formatter.h" | 12 #include "base/i18n/message_formatter.h" |
| 12 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_dialogs.h" |
| 16 #include "chrome/browser/ui/browser_list.h" | 18 #include "chrome/browser/ui/browser_list.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h" | 20 #include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h" |
| 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 20 #include "chrome/browser/ui/views/frame/browser_view.h" | 22 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 21 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" | 23 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
| 22 #include "chrome/grit/chromium_strings.h" | 24 #include "chrome/grit/chromium_strings.h" |
| 23 #include "chrome/grit/generated_resources.h" | 25 #include "chrome/grit/generated_resources.h" |
| 24 #include "components/constrained_window/constrained_window_views.h" | 26 #include "components/constrained_window/constrained_window_views.h" |
| 25 #include "components/signin/core/browser/signin_manager.h" | 27 #include "components/signin/core/browser/signin_manager.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 return ChromeLayoutProvider::Get()->GetInsetsMetric( | 80 return ChromeLayoutProvider::Get()->GetInsetsMetric( |
| 79 views::INSETS_DIALOG_CONTENTS); | 81 views::INSETS_DIALOG_CONTENTS); |
| 80 } | 82 } |
| 81 }; | 83 }; |
| 82 | 84 |
| 83 } // namespace | 85 } // namespace |
| 84 | 86 |
| 85 ForcedReauthenticationDialog::ForcedReauthenticationDialog( | 87 ForcedReauthenticationDialog::ForcedReauthenticationDialog( |
| 86 Browser* browser, | 88 Browser* browser, |
| 87 SigninManager* signin_manager, | 89 SigninManager* signin_manager, |
| 88 const base::TimeDelta& countdown_duration) | 90 base::TimeDelta countdown_duration) |
| 89 : browser_(browser), | 91 : browser_(browser), |
| 90 signin_manager_(signin_manager), | 92 signin_manager_(signin_manager), |
| 91 desired_close_time_(base::TimeTicks::Now() + countdown_duration) { | 93 desired_close_time_(base::TimeTicks::Now() + countdown_duration) { |
| 92 constrained_window::CreateBrowserModalDialogViews( | 94 constrained_window::CreateBrowserModalDialogViews( |
| 93 this, browser->window()->GetNativeWindow()) | 95 this, browser->window()->GetNativeWindow()) |
| 94 ->Show(); | 96 ->Show(); |
| 95 browser->window()->FlashFrame(true); | 97 browser->window()->FlashFrame(true); |
| 96 browser->window()->Activate(); | 98 browser->window()->Activate(); |
| 97 } | 99 } |
| 98 | 100 |
| 99 ForcedReauthenticationDialog::~ForcedReauthenticationDialog() {} | 101 ForcedReauthenticationDialog::~ForcedReauthenticationDialog() {} |
| 100 | 102 |
| 101 // static | 103 // static |
| 102 ForcedReauthenticationDialog* ForcedReauthenticationDialog::ShowDialog( | 104 ForcedReauthenticationDialog* ForcedReauthenticationDialog::ShowDialog( |
| 103 Profile* profile, | 105 Profile* profile, |
| 104 SigninManager* signin_manager, | 106 SigninManager* signin_manager, |
| 105 const base::TimeDelta& countdown_duration) { | 107 base::TimeDelta countdown_duration) { |
| 106 Browser* browser = FindBrowserWithProfile(profile); | 108 Browser* browser = FindBrowserWithProfile(profile); |
| 107 if (browser == nullptr) { // If there is no browser, we can just sign | 109 if (browser == nullptr) { // If there is no browser, we can just sign |
| 108 // out profile directly. | 110 // out profile directly. |
| 109 Signout(signin_manager); | 111 Signout(signin_manager); |
| 110 return nullptr; | 112 return nullptr; |
| 111 } | 113 } |
| 112 | 114 |
| 113 return new ForcedReauthenticationDialog(browser, signin_manager, | 115 return new ForcedReauthenticationDialog(browser, signin_manager, |
| 114 countdown_duration); | 116 countdown_duration); |
| 115 } | 117 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 243 } |
| 242 GetWidget()->UpdateWindowTitle(); | 244 GetWidget()->UpdateWindowTitle(); |
| 243 } | 245 } |
| 244 | 246 |
| 245 base::TimeDelta ForcedReauthenticationDialog::GetTimeRemaining() const { | 247 base::TimeDelta ForcedReauthenticationDialog::GetTimeRemaining() const { |
| 246 base::TimeTicks now = base::TimeTicks::Now(); | 248 base::TimeTicks now = base::TimeTicks::Now(); |
| 247 if (desired_close_time_ <= now) | 249 if (desired_close_time_ <= now) |
| 248 return base::TimeDelta(); | 250 return base::TimeDelta(); |
| 249 return desired_close_time_ - now; | 251 return desired_close_time_ - now; |
| 250 } | 252 } |
| 253 |
| 254 namespace chrome { |
| 255 views::Widget* ShowForcedReauthenticationDialog( |
| 256 Profile* profile, |
| 257 SigninManager* signin_manager, |
| 258 base::TimeDelta countdown_duration) { |
| 259 return ForcedReauthenticationDialog::ShowDialog(profile, signin_manager, |
| 260 countdown_duration) |
| 261 ->GetWidget(); |
| 262 } |
| 263 |
| 264 } // namespace chrome |
| OLD | NEW |