| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 bool IsWebContentsVisible(content::WebContents* web_contents) override { | 108 bool IsWebContentsVisible(content::WebContents* web_contents) override { |
| 109 return true; | 109 return true; |
| 110 } | 110 } |
| 111 | 111 |
| 112 ~UserManagerModalManagerDelegate() override {} | 112 ~UserManagerModalManagerDelegate() override {} |
| 113 protected: | 113 protected: |
| 114 std::unique_ptr<UserManagerModalHost> modal_host_; | 114 std::unique_ptr<UserManagerModalHost> modal_host_; |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 // Custom WebContentsDelegate that allows handling of hotkeys. | 117 // Custom WebContentsDelegate that allows handling of hotkeys. |
| 118 class UserManagerWebContentsDelegate : public content::WebContentsDelegate { | 118 class UserManagerWebContentsDelegate : |
| 119 virtual public content::WebContentsDelegate { |
| 119 public: | 120 public: |
| 120 UserManagerWebContentsDelegate() {} | 121 UserManagerWebContentsDelegate() {} |
| 121 | 122 |
| 122 // WebContentsDelegate implementation. Forwards all unhandled keyboard events | 123 // WebContentsDelegate implementation. Forwards all unhandled keyboard events |
| 123 // to the current window. | 124 // to the current window. |
| 124 void HandleKeyboardEvent( | 125 void HandleKeyboardEvent( |
| 125 content::WebContents* source, | 126 content::WebContents* source, |
| 126 const content::NativeWebKeyboardEvent& event) override { | 127 const content::NativeWebKeyboardEvent& event) override { |
| 127 if (![BrowserWindowUtils shouldHandleKeyboardEvent:event]) | 128 if (![BrowserWindowUtils shouldHandleKeyboardEvent:event]) |
| 128 return; | 129 return; |
| 129 | 130 |
| 130 // -getCommandId returns -1 if the event isn't a chrome accelerator. | 131 // -getCommandId returns -1 if the event isn't a chrome accelerator. |
| 131 int chromeCommandId = [BrowserWindowUtils getCommandId:event]; | 132 int chromeCommandId = [BrowserWindowUtils getCommandId:event]; |
| 132 | 133 |
| 133 // Check for Cmd+A and Cmd+V events that could come from a password field. | 134 // Check for Cmd+A and Cmd+V events that could come from a password field. |
| 134 BOOL isTextEditingCommand = [BrowserWindowUtils isTextEditingEvent:event]; | 135 BOOL isTextEditingCommand = [BrowserWindowUtils isTextEditingEvent:event]; |
| 135 | 136 |
| 136 // Only handle close window Chrome accelerators and text editing ones. | 137 // Only handle close window Chrome accelerators and text editing ones. |
| 137 if (chromeCommandId == IDC_CLOSE_WINDOW || chromeCommandId == IDC_EXIT || | 138 if (chromeCommandId == IDC_CLOSE_WINDOW || chromeCommandId == IDC_EXIT || |
| 138 isTextEditingCommand) { | 139 isTextEditingCommand) { |
| 139 [[NSApp mainMenu] performKeyEquivalent:event.os_event]; | 140 [[NSApp mainMenu] performKeyEquivalent:event.os_event]; |
| 140 } | 141 } |
| 141 } | 142 } |
| 142 }; | 143 }; |
| 143 | 144 |
| 144 class ReauthDialogDelegate : public UserManager::ReauthDialogObserver, | 145 class ReauthDialogDelegate : public UserManager::BaseReauthDialogDelegate, |
| 145 public UserManagerWebContentsDelegate, | 146 public UserManagerWebContentsDelegate, |
| 146 public ConstrainedWindowMacDelegate { | 147 public ConstrainedWindowMacDelegate { |
| 147 public: | 148 public: |
| 148 ReauthDialogDelegate(content::WebContents* web_contents, | 149 ReauthDialogDelegate(content::WebContents* web_contents, |
| 149 const std::string& email) | 150 const std::string& email) |
| 150 : UserManager::ReauthDialogObserver(web_contents, email) {} | 151 : UserManager::BaseReauthDialogDelegate(web_contents) {} |
| 151 | 152 |
| 152 // UserManager::ReauthDialogObserver: | 153 // UserManager::BaseReauthDialogDelegate: |
| 153 void CloseReauthDialog() override { | 154 void CloseReauthDialog() override { |
| 154 CloseInstanceReauthDialog(); | 155 CloseInstanceReauthDialog(); |
| 155 } | 156 } |
| 156 | 157 |
| 157 // ConstrainedWindowMacDelegate: | 158 // ConstrainedWindowMacDelegate: |
| 158 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override { | 159 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override { |
| 159 CloseReauthDialog(); | 160 CloseReauthDialog(); |
| 160 } | 161 } |
| 161 | 162 |
| 162 DISALLOW_COPY_AND_ASSIGN(ReauthDialogDelegate); | 163 DISALLOW_COPY_AND_ASSIGN(ReauthDialogDelegate); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 ProfileMetrics::LogTimeToOpenUserManager( | 519 ProfileMetrics::LogTimeToOpenUserManager( |
| 519 base::Time::Now() - user_manager_started_showing_); | 520 base::Time::Now() - user_manager_started_showing_); |
| 520 user_manager_started_showing_ = base::Time(); | 521 user_manager_started_showing_ = base::Time(); |
| 521 } | 522 } |
| 522 | 523 |
| 523 void UserManagerMac::WindowWasClosed() { | 524 void UserManagerMac::WindowWasClosed() { |
| 524 CloseReauthDialog(); | 525 CloseReauthDialog(); |
| 525 instance_ = NULL; | 526 instance_ = NULL; |
| 526 delete this; | 527 delete this; |
| 527 } | 528 } |
| OLD | NEW |