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

Side by Side Diff: chrome/browser/ui/cocoa/login_prompt_cocoa.mm

Issue 671653002: Standardize usage of virtual/override/final in chrome/browser/ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
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 #import "chrome/browser/ui/cocoa/login_prompt_cocoa.h" 5 #import "chrome/browser/ui/cocoa/login_prompt_cocoa.h"
6 6
7 #include "base/mac/bundle_locations.h" 7 #include "base/mac/bundle_locations.h"
8 #include "base/mac/mac_util.h" 8 #include "base/mac/mac_util.h"
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 23 matching lines...) Expand all
34 // This class uses ref counting to ensure that it lives until all InvokeLaters 34 // This class uses ref counting to ensure that it lives until all InvokeLaters
35 // have been called. 35 // have been called.
36 class LoginHandlerMac : public LoginHandler, 36 class LoginHandlerMac : public LoginHandler,
37 public ConstrainedWindowMacDelegate { 37 public ConstrainedWindowMacDelegate {
38 public: 38 public:
39 LoginHandlerMac(net::AuthChallengeInfo* auth_info, net::URLRequest* request) 39 LoginHandlerMac(net::AuthChallengeInfo* auth_info, net::URLRequest* request)
40 : LoginHandler(auth_info, request) { 40 : LoginHandler(auth_info, request) {
41 } 41 }
42 42
43 // LoginModelObserver implementation. 43 // LoginModelObserver implementation.
44 virtual void OnAutofillDataAvailable( 44 void OnAutofillDataAvailable(const base::string16& username,
45 const base::string16& username, 45 const base::string16& password) override {
46 const base::string16& password) override {
47 DCHECK_CURRENTLY_ON(BrowserThread::UI); 46 DCHECK_CURRENTLY_ON(BrowserThread::UI);
48 47
49 [sheet_controller_ autofillLogin:base::SysUTF16ToNSString(username) 48 [sheet_controller_ autofillLogin:base::SysUTF16ToNSString(username)
50 password:base::SysUTF16ToNSString(password)]; 49 password:base::SysUTF16ToNSString(password)];
51 } 50 }
52 virtual void OnLoginModelDestroying() override {} 51 void OnLoginModelDestroying() override {}
53 52
54 // LoginHandler: 53 // LoginHandler:
55 virtual void BuildViewForPasswordManager( 54 void BuildViewForPasswordManager(password_manager::PasswordManager* manager,
56 password_manager::PasswordManager* manager, 55 const base::string16& explanation) override {
57 const base::string16& explanation) override {
58 DCHECK_CURRENTLY_ON(BrowserThread::UI); 56 DCHECK_CURRENTLY_ON(BrowserThread::UI);
59 57
60 sheet_controller_.reset( 58 sheet_controller_.reset(
61 [[LoginHandlerSheet alloc] initWithLoginHandler:this]); 59 [[LoginHandlerSheet alloc] initWithLoginHandler:this]);
62 60
63 SetModel(manager); 61 SetModel(manager);
64 62
65 [sheet_controller_ setExplanation:base::SysUTF16ToNSString(explanation)]; 63 [sheet_controller_ setExplanation:base::SysUTF16ToNSString(explanation)];
66 64
67 // Scary thread safety note: This can potentially be called *after* SetAuth 65 // Scary thread safety note: This can potentially be called *after* SetAuth
68 // or CancelAuth (say, if the request was cancelled before the UI thread got 66 // or CancelAuth (say, if the request was cancelled before the UI thread got
69 // control). However, that's OK since any UI interaction in those functions 67 // control). However, that's OK since any UI interaction in those functions
70 // will occur via an InvokeLater on the UI thread, which is guaranteed 68 // will occur via an InvokeLater on the UI thread, which is guaranteed
71 // to happen after this is called (since this was InvokeLater'd first). 69 // to happen after this is called (since this was InvokeLater'd first).
72 WebContents* requesting_contents = GetWebContentsForLogin(); 70 WebContents* requesting_contents = GetWebContentsForLogin();
73 DCHECK(requesting_contents); 71 DCHECK(requesting_contents);
74 72
75 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( 73 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
76 [[CustomConstrainedWindowSheet alloc] 74 [[CustomConstrainedWindowSheet alloc]
77 initWithCustomWindow:[sheet_controller_ window]]); 75 initWithCustomWindow:[sheet_controller_ window]]);
78 constrained_window_.reset(new ConstrainedWindowMac( 76 constrained_window_.reset(new ConstrainedWindowMac(
79 this, requesting_contents, sheet)); 77 this, requesting_contents, sheet));
80 78
81 NotifyAuthNeeded(); 79 NotifyAuthNeeded();
82 } 80 }
83 81
84 virtual void CloseDialog() override { 82 void CloseDialog() override {
85 // The hosting dialog may have been freed. 83 // The hosting dialog may have been freed.
86 if (constrained_window_) 84 if (constrained_window_)
87 constrained_window_->CloseWebContentsModalDialog(); 85 constrained_window_->CloseWebContentsModalDialog();
88 } 86 }
89 87
90 // Overridden from ConstrainedWindowMacDelegate: 88 // Overridden from ConstrainedWindowMacDelegate:
91 virtual void OnConstrainedWindowClosed( 89 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override {
92 ConstrainedWindowMac* window) override {
93 DCHECK_CURRENTLY_ON(BrowserThread::UI); 90 DCHECK_CURRENTLY_ON(BrowserThread::UI);
94 SetModel(NULL); 91 SetModel(NULL);
95 ReleaseSoon(); 92 ReleaseSoon();
96 93
97 constrained_window_.reset(); 94 constrained_window_.reset();
98 sheet_controller_.reset(); 95 sheet_controller_.reset();
99 } 96 }
100 97
101 void OnLoginPressed(const base::string16& username, 98 void OnLoginPressed(const base::string16& username,
102 const base::string16& password) { 99 const base::string16& password) {
103 DCHECK_CURRENTLY_ON(BrowserThread::UI); 100 DCHECK_CURRENTLY_ON(BrowserThread::UI);
104 SetAuth(username, password); 101 SetAuth(username, password);
105 } 102 }
106 103
107 void OnCancelPressed() { 104 void OnCancelPressed() {
108 DCHECK_CURRENTLY_ON(BrowserThread::UI); 105 DCHECK_CURRENTLY_ON(BrowserThread::UI);
109 CancelAuth(); 106 CancelAuth();
110 } 107 }
111 108
112 private: 109 private:
113 friend class LoginPrompt; 110 friend class LoginPrompt;
114 111
115 virtual ~LoginHandlerMac() { 112 ~LoginHandlerMac() override {
116 // This class will be deleted on a non UI thread. Ensure that the UI members 113 // This class will be deleted on a non UI thread. Ensure that the UI members
117 // have already been deleted. 114 // have already been deleted.
118 CHECK(!constrained_window_.get()); 115 CHECK(!constrained_window_.get());
119 CHECK(!sheet_controller_.get()); 116 CHECK(!sheet_controller_.get());
120 } 117 }
121 118
122 // The Cocoa controller of the GUI. 119 // The Cocoa controller of the GUI.
123 base::scoped_nsobject<LoginHandlerSheet> sheet_controller_; 120 base::scoped_nsobject<LoginHandlerSheet> sheet_controller_;
124 121
125 scoped_ptr<ConstrainedWindowMac> constrained_window_; 122 scoped_ptr<ConstrainedWindowMac> constrained_window_;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // Resize the text field. 181 // Resize the text field.
185 CGFloat windowDelta = [GTMUILocalizerAndLayoutTweaker 182 CGFloat windowDelta = [GTMUILocalizerAndLayoutTweaker
186 sizeToFitFixedWidthTextField:explanationField_]; 183 sizeToFitFixedWidthTextField:explanationField_];
187 184
188 NSRect newFrame = [[self window] frame]; 185 NSRect newFrame = [[self window] frame];
189 newFrame.size.height += windowDelta; 186 newFrame.size.height += windowDelta;
190 [[self window] setFrame:newFrame display:NO]; 187 [[self window] setFrame:newFrame display:NO];
191 } 188 }
192 189
193 @end 190 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698