Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: chrome/browser/ui/cocoa/profiles/user_manager_mac.mm

Issue 2168953002: Disables the context menu in User Manager's reauth dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comment Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/user_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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() {
149 const std::string& email) 148 hotKeysWebContentsDelegate_.reset(new UserManagerWebContentsDelegate());
150 : UserManager::ReauthDialogObserver(web_contents, email) {} 149 }
151 150
152 // UserManager::ReauthDialogObserver: 151 // UserManager::BaseReauthDialogDelegate:
153 void CloseReauthDialog() override { 152 void CloseReauthDialog() override {
154 CloseInstanceReauthDialog(); 153 CloseInstanceReauthDialog();
155 } 154 }
156 155
156 // WebContentsDelegate::HandleKeyboardEvent:
157 void HandleKeyboardEvent(
158 content::WebContents* source,
159 const content::NativeWebKeyboardEvent& event) override {
160 hotKeysWebContentsDelegate_->HandleKeyboardEvent(source, event);
161 }
162
157 // ConstrainedWindowMacDelegate: 163 // ConstrainedWindowMacDelegate:
158 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override { 164 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override {
159 CloseReauthDialog(); 165 CloseReauthDialog();
160 } 166 }
161 167
168 private:
169 std::unique_ptr<UserManagerWebContentsDelegate> hotKeysWebContentsDelegate_;
170
162 DISALLOW_COPY_AND_ASSIGN(ReauthDialogDelegate); 171 DISALLOW_COPY_AND_ASSIGN(ReauthDialogDelegate);
163 }; 172 };
164 173
165 // WindowController for the reauth dialog. 174 // WindowController for the reauth dialog.
166 @interface ReauthDialogWindowController 175 @interface ReauthDialogWindowController
167 : NSWindowController <NSWindowDelegate> { 176 : NSWindowController <NSWindowDelegate> {
168 @private 177 @private
169 std::string emailAddress_; 178 std::string emailAddress_;
170 content::WebContents* webContents_; 179 content::WebContents* webContents_;
171 signin_metrics::Reason reason_; 180 signin_metrics::Reason reason_;
(...skipping 23 matching lines...) Expand all
195 base::scoped_nsobject<ConstrainedWindowCustomWindow> window( 204 base::scoped_nsobject<ConstrainedWindowCustomWindow> window(
196 [[ConstrainedWindowCustomWindow alloc] 205 [[ConstrainedWindowCustomWindow alloc]
197 initWithContentRect:frame 206 initWithContentRect:frame
198 styleMask:NSTitledWindowMask | NSClosableWindowMask]); 207 styleMask:NSTitledWindowMask | NSClosableWindowMask]);
199 if ((self = [super initWithWindow:window])) { 208 if ((self = [super initWithWindow:window])) {
200 webContents_ = webContents; 209 webContents_ = webContents;
201 210
202 reauthWebContents_.reset(content::WebContents::Create( 211 reauthWebContents_.reset(content::WebContents::Create(
203 content::WebContents::CreateParams(profile))); 212 content::WebContents::CreateParams(profile)));
204 window.get().contentView = reauthWebContents_->GetNativeView(); 213 window.get().contentView = reauthWebContents_->GetNativeView();
205 webContentsDelegate_.reset( 214 webContentsDelegate_.reset(new ReauthDialogDelegate());
206 new ReauthDialogDelegate(reauthWebContents_.get(), emailAddress_));
207 reauthWebContents_->SetDelegate(webContentsDelegate_.get()); 215 reauthWebContents_->SetDelegate(webContentsDelegate_.get());
208 216
209 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( 217 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
210 [[CustomConstrainedWindowSheet alloc] 218 [[CustomConstrainedWindowSheet alloc]
211 initWithCustomWindow:[self window]]); 219 initWithCustomWindow:[self window]]);
212 constrained_window_ = 220 constrained_window_ =
213 CreateAndShowWebModalDialogMac( 221 CreateAndShowWebModalDialogMac(
214 webContentsDelegate_.get(), webContents_, sheet); 222 webContentsDelegate_.get(), webContents_, sheet);
215 223
216 // The close button needs to call CloseWebContentsModalDialog() on the 224 // The close button needs to call CloseWebContentsModalDialog() on the
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 ProfileMetrics::LogTimeToOpenUserManager( 526 ProfileMetrics::LogTimeToOpenUserManager(
519 base::Time::Now() - user_manager_started_showing_); 527 base::Time::Now() - user_manager_started_showing_);
520 user_manager_started_showing_ = base::Time(); 528 user_manager_started_showing_ = base::Time();
521 } 529 }
522 530
523 void UserManagerMac::WindowWasClosed() { 531 void UserManagerMac::WindowWasClosed() {
524 CloseReauthDialog(); 532 CloseReauthDialog();
525 instance_ = NULL; 533 instance_ = NULL;
526 delete this; 534 delete this;
527 } 535 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/user_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698