| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/cocoa/profiles/user_manager_mac.h" | 5 #include "chrome/browser/ui/cocoa/profiles/user_manager_mac.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/mac/foundation_util.h" | 8 #include "base/mac/foundation_util.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #import "chrome/browser/app_controller_mac.h" | 10 #import "chrome/browser/app_controller_mac.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 BOOL isTextEditingCommand = [BrowserWindowUtils isTextEditingEvent:event]; | 134 BOOL isTextEditingCommand = [BrowserWindowUtils isTextEditingEvent:event]; |
| 135 | 135 |
| 136 // Only handle close window Chrome accelerators and text editing ones. | 136 // Only handle close window Chrome accelerators and text editing ones. |
| 137 if (chromeCommandId == IDC_CLOSE_WINDOW || chromeCommandId == IDC_EXIT || | 137 if (chromeCommandId == IDC_CLOSE_WINDOW || chromeCommandId == IDC_EXIT || |
| 138 isTextEditingCommand) { | 138 isTextEditingCommand) { |
| 139 [[NSApp mainMenu] performKeyEquivalent:event.os_event]; | 139 [[NSApp mainMenu] performKeyEquivalent:event.os_event]; |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 }; | 142 }; |
| 143 | 143 |
| 144 class ReauthDialogDelegate : public UserManager::ReauthDialogObserver, | 144 class ReauthDialogDelegate : public UserManager::BaseReauthDialogDelegate, |
| 145 public UserManagerWebContentsDelegate, | |
| 146 public ConstrainedWindowMacDelegate { | 145 public ConstrainedWindowMacDelegate { |
| 147 public: | 146 public: |
| 148 ReauthDialogDelegate(content::WebContents* web_contents, | 147 ReauthDialogDelegate(content::WebContents* web_contents, |
| 149 const std::string& email) | 148 const std::string& email) |
| 150 : UserManager::ReauthDialogObserver(web_contents, email) {} | 149 : UserManager::BaseReauthDialogDelegate(web_contents) { |
| 150 hotKeysWebContentsDelegate_.reset(new UserManagerWebContentsDelegate()); |
| 151 } |
| 151 | 152 |
| 152 // UserManager::ReauthDialogObserver: | 153 // UserManager::BaseReauthDialogDelegate: |
| 153 void CloseReauthDialog() override { | 154 void CloseReauthDialog() override { |
| 154 CloseInstanceReauthDialog(); | 155 CloseInstanceReauthDialog(); |
| 155 } | 156 } |
| 156 | 157 |
| 158 // WebContentsDelegate::HandleKeyboardEvent: |
| 159 void HandleKeyboardEvent( |
| 160 content::WebContents* source, |
| 161 const content::NativeWebKeyboardEvent& event) override { |
| 162 hotKeysWebContentsDelegate_->HandleKeyboardEvent(source, event); |
| 163 } |
| 164 |
| 157 // ConstrainedWindowMacDelegate: | 165 // ConstrainedWindowMacDelegate: |
| 158 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override { | 166 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override { |
| 159 CloseReauthDialog(); | 167 CloseReauthDialog(); |
| 160 } | 168 } |
| 161 | 169 |
| 170 private: |
| 171 std::unique_ptr<UserManagerWebContentsDelegate> hotKeysWebContentsDelegate_; |
| 172 |
| 162 DISALLOW_COPY_AND_ASSIGN(ReauthDialogDelegate); | 173 DISALLOW_COPY_AND_ASSIGN(ReauthDialogDelegate); |
| 163 }; | 174 }; |
| 164 | 175 |
| 165 // WindowController for the reauth dialog. | 176 // WindowController for the reauth dialog. |
| 166 @interface ReauthDialogWindowController | 177 @interface ReauthDialogWindowController |
| 167 : NSWindowController <NSWindowDelegate> { | 178 : NSWindowController <NSWindowDelegate> { |
| 168 @private | 179 @private |
| 169 std::string emailAddress_; | 180 std::string emailAddress_; |
| 170 content::WebContents* webContents_; | 181 content::WebContents* webContents_; |
| 171 signin_metrics::Reason reason_; | 182 signin_metrics::Reason reason_; |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 ProfileMetrics::LogTimeToOpenUserManager( | 529 ProfileMetrics::LogTimeToOpenUserManager( |
| 519 base::Time::Now() - user_manager_started_showing_); | 530 base::Time::Now() - user_manager_started_showing_); |
| 520 user_manager_started_showing_ = base::Time(); | 531 user_manager_started_showing_ = base::Time(); |
| 521 } | 532 } |
| 522 | 533 |
| 523 void UserManagerMac::WindowWasClosed() { | 534 void UserManagerMac::WindowWasClosed() { |
| 524 CloseReauthDialog(); | 535 CloseReauthDialog(); |
| 525 instance_ = NULL; | 536 instance_ = NULL; |
| 526 delete this; | 537 delete this; |
| 527 } | 538 } |
| OLD | NEW |