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

Side by Side Diff: chrome/browser/ui/views/login_prompt_views.cc

Issue 680133002: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « chrome/browser/ui/views/load_complete_listener.h ('k') | chrome/browser/ui/views/login_view.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 (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 #include "chrome/browser/ui/login/login_prompt.h" 5 #include "chrome/browser/ui/login/login_prompt.h"
6 6
7 #include "base/strings/string16.h" 7 #include "base/strings/string16.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/ui/views/login_view.h" 9 #include "chrome/browser/ui/views/login_view.h"
10 #include "chrome/grit/generated_resources.h" 10 #include "chrome/grit/generated_resources.h"
(...skipping 16 matching lines...) Expand all
27 // have been called. 27 // have been called.
28 class LoginHandlerViews : public LoginHandler, public views::DialogDelegate { 28 class LoginHandlerViews : public LoginHandler, public views::DialogDelegate {
29 public: 29 public:
30 LoginHandlerViews(net::AuthChallengeInfo* auth_info, net::URLRequest* request) 30 LoginHandlerViews(net::AuthChallengeInfo* auth_info, net::URLRequest* request)
31 : LoginHandler(auth_info, request), 31 : LoginHandler(auth_info, request),
32 login_view_(NULL), 32 login_view_(NULL),
33 dialog_(NULL) { 33 dialog_(NULL) {
34 } 34 }
35 35
36 // LoginModelObserver: 36 // LoginModelObserver:
37 virtual void OnAutofillDataAvailable( 37 void OnAutofillDataAvailable(const base::string16& username,
38 const base::string16& username, 38 const base::string16& password) override {
39 const base::string16& password) override {
40 // Nothing to do here since LoginView takes care of autofill for win. 39 // Nothing to do here since LoginView takes care of autofill for win.
41 } 40 }
42 virtual void OnLoginModelDestroying() override {} 41 void OnLoginModelDestroying() override {}
43 42
44 // views::DialogDelegate: 43 // views::DialogDelegate:
45 virtual base::string16 GetDialogButtonLabel( 44 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override {
46 ui::DialogButton button) const override {
47 if (button == ui::DIALOG_BUTTON_OK) 45 if (button == ui::DIALOG_BUTTON_OK)
48 return l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_OK_BUTTON_LABEL); 46 return l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_OK_BUTTON_LABEL);
49 return DialogDelegate::GetDialogButtonLabel(button); 47 return DialogDelegate::GetDialogButtonLabel(button);
50 } 48 }
51 49
52 virtual base::string16 GetWindowTitle() const override { 50 base::string16 GetWindowTitle() const override {
53 return l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_TITLE); 51 return l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_TITLE);
54 } 52 }
55 53
56 virtual void WindowClosing() override { 54 void WindowClosing() override {
57 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 55 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
58 content::WebContents* web_contents = GetWebContentsForLogin(); 56 content::WebContents* web_contents = GetWebContentsForLogin();
59 if (web_contents) 57 if (web_contents)
60 web_contents->GetRenderViewHost()->SetIgnoreInputEvents(false); 58 web_contents->GetRenderViewHost()->SetIgnoreInputEvents(false);
61 59
62 // Reference is no longer valid. 60 // Reference is no longer valid.
63 dialog_ = NULL; 61 dialog_ = NULL;
64 CancelAuth(); 62 CancelAuth();
65 } 63 }
66 64
67 virtual void DeleteDelegate() override { 65 void DeleteDelegate() override {
68 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 66 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
69 67
70 // The widget is going to delete itself; clear our pointer. 68 // The widget is going to delete itself; clear our pointer.
71 dialog_ = NULL; 69 dialog_ = NULL;
72 SetModel(NULL); 70 SetModel(NULL);
73 71
74 ReleaseSoon(); 72 ReleaseSoon();
75 } 73 }
76 74
77 virtual ui::ModalType GetModalType() const override { 75 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_CHILD; }
78 return ui::MODAL_TYPE_CHILD;
79 }
80 76
81 virtual bool Cancel() override { 77 bool Cancel() override {
82 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 78 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
83 CancelAuth(); 79 CancelAuth();
84 return true; 80 return true;
85 } 81 }
86 82
87 virtual bool Accept() override { 83 bool Accept() override {
88 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 84 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
89 SetAuth(login_view_->GetUsername(), login_view_->GetPassword()); 85 SetAuth(login_view_->GetUsername(), login_view_->GetPassword());
90 return true; 86 return true;
91 } 87 }
92 88
93 virtual views::View* GetInitiallyFocusedView() override { 89 views::View* GetInitiallyFocusedView() override {
94 return login_view_->GetInitiallyFocusedView(); 90 return login_view_->GetInitiallyFocusedView();
95 } 91 }
96 92
97 virtual views::View* GetContentsView() override { 93 views::View* GetContentsView() override { return login_view_; }
98 return login_view_; 94 views::Widget* GetWidget() override { return login_view_->GetWidget(); }
99 } 95 const views::Widget* GetWidget() const override {
100 virtual views::Widget* GetWidget() override {
101 return login_view_->GetWidget();
102 }
103 virtual const views::Widget* GetWidget() const override {
104 return login_view_->GetWidget(); 96 return login_view_->GetWidget();
105 } 97 }
106 98
107 // LoginHandler: 99 // LoginHandler:
108 virtual void BuildViewForPasswordManager( 100 void BuildViewForPasswordManager(password_manager::PasswordManager* manager,
109 password_manager::PasswordManager* manager, 101 const base::string16& explanation) override {
110 const base::string16& explanation) override {
111 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 102 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
112 103
113 // Create a new LoginView and set the model for it. The model (password 104 // Create a new LoginView and set the model for it. The model (password
114 // manager) is owned by the WebContents, but the view is parented to the 105 // manager) is owned by the WebContents, but the view is parented to the
115 // browser window, so the view may be destroyed after the password 106 // browser window, so the view may be destroyed after the password
116 // manager. The view listens for model destruction and unobserves 107 // manager. The view listens for model destruction and unobserves
117 // accordingly. 108 // accordingly.
118 login_view_ = new LoginView(explanation, manager); 109 login_view_ = new LoginView(explanation, manager);
119 110
120 // Scary thread safety note: This can potentially be called *after* SetAuth 111 // Scary thread safety note: This can potentially be called *after* SetAuth
121 // or CancelAuth (say, if the request was cancelled before the UI thread got 112 // or CancelAuth (say, if the request was cancelled before the UI thread got
122 // control). However, that's OK since any UI interaction in those functions 113 // control). However, that's OK since any UI interaction in those functions
123 // will occur via an InvokeLater on the UI thread, which is guaranteed 114 // will occur via an InvokeLater on the UI thread, which is guaranteed
124 // to happen after this is called (since this was InvokeLater'd first). 115 // to happen after this is called (since this was InvokeLater'd first).
125 dialog_ = ShowWebModalDialogViews(this, GetWebContentsForLogin()); 116 dialog_ = ShowWebModalDialogViews(this, GetWebContentsForLogin());
126 NotifyAuthNeeded(); 117 NotifyAuthNeeded();
127 } 118 }
128 119
129 virtual void CloseDialog() override { 120 void CloseDialog() override {
130 // The hosting widget may have been freed. 121 // The hosting widget may have been freed.
131 if (dialog_) 122 if (dialog_)
132 dialog_->Close(); 123 dialog_->Close();
133 } 124 }
134 125
135 private: 126 private:
136 friend class base::RefCountedThreadSafe<LoginHandlerViews>; 127 friend class base::RefCountedThreadSafe<LoginHandlerViews>;
137 friend class LoginPrompt; 128 friend class LoginPrompt;
138 129
139 virtual ~LoginHandlerViews() {} 130 ~LoginHandlerViews() override {}
140 131
141 // The LoginView that contains the user's login information. 132 // The LoginView that contains the user's login information.
142 LoginView* login_view_; 133 LoginView* login_view_;
143 134
144 views::Widget* dialog_; 135 views::Widget* dialog_;
145 136
146 DISALLOW_COPY_AND_ASSIGN(LoginHandlerViews); 137 DISALLOW_COPY_AND_ASSIGN(LoginHandlerViews);
147 }; 138 };
148 139
149 // static 140 // static
150 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, 141 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info,
151 net::URLRequest* request) { 142 net::URLRequest* request) {
152 return new LoginHandlerViews(auth_info, request); 143 return new LoginHandlerViews(auth_info, request);
153 } 144 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/load_complete_listener.h ('k') | chrome/browser/ui/views/login_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698