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

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

Issue 1421013003: [Merge in M47] Do not involve PasswordManagerDriver in filling HTTP-auth forms; also check realm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2526
Patch Set: Created 5 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
« no previous file with comments | « chrome/browser/ui/login/login_prompt.cc ('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 void OnAutofillDataAvailable(const base::string16& username, 37 void OnAutofillDataAvailableInternal(
38 const base::string16& password) override { 38 const base::string16& username,
39 const base::string16& password) override {
39 // Nothing to do here since LoginView takes care of autofill for win. 40 // Nothing to do here since LoginView takes care of autofill for win.
40 } 41 }
41 void OnLoginModelDestroying() override {} 42 void OnLoginModelDestroying() override {}
42 43
43 // views::DialogDelegate: 44 // views::DialogDelegate:
44 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override { 45 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override {
45 if (button == ui::DIALOG_BUTTON_OK) 46 if (button == ui::DIALOG_BUTTON_OK)
46 return l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_OK_BUTTON_LABEL); 47 return l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_OK_BUTTON_LABEL);
47 return DialogDelegate::GetDialogButtonLabel(button); 48 return DialogDelegate::GetDialogButtonLabel(button);
48 } 49 }
(...skipping 11 matching lines...) Expand all
60 // Reference is no longer valid. 61 // Reference is no longer valid.
61 dialog_ = NULL; 62 dialog_ = NULL;
62 CancelAuth(); 63 CancelAuth();
63 } 64 }
64 65
65 void DeleteDelegate() override { 66 void DeleteDelegate() override {
66 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 67 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
67 68
68 // The widget is going to delete itself; clear our pointer. 69 // The widget is going to delete itself; clear our pointer.
69 dialog_ = NULL; 70 dialog_ = NULL;
70 SetModel(NULL); 71 ResetModel();
71 72
72 ReleaseSoon(); 73 ReleaseSoon();
73 } 74 }
74 75
75 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_CHILD; } 76 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_CHILD; }
76 77
77 bool Cancel() override { 78 bool Cancel() override {
78 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 79 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
79 CancelAuth(); 80 CancelAuth();
80 return true; 81 return true;
81 } 82 }
82 83
83 bool Accept() override { 84 bool Accept() override {
84 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 85 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
85 SetAuth(login_view_->GetUsername(), login_view_->GetPassword()); 86 SetAuth(login_view_->GetUsername(), login_view_->GetPassword());
86 return true; 87 return true;
87 } 88 }
88 89
89 views::View* GetInitiallyFocusedView() override { 90 views::View* GetInitiallyFocusedView() override {
90 return login_view_->GetInitiallyFocusedView(); 91 return login_view_->GetInitiallyFocusedView();
91 } 92 }
92 93
93 views::View* GetContentsView() override { return login_view_; } 94 views::View* GetContentsView() override { return login_view_; }
94 views::Widget* GetWidget() override { return login_view_->GetWidget(); } 95 views::Widget* GetWidget() override { return login_view_->GetWidget(); }
95 const views::Widget* GetWidget() const override { 96 const views::Widget* GetWidget() const override {
96 return login_view_->GetWidget(); 97 return login_view_->GetWidget();
97 } 98 }
98 99
99 // LoginHandler: 100 // LoginHandler:
100 void BuildViewForPasswordManager(password_manager::PasswordManager* manager, 101 void BuildView(const base::string16& explanation,
101 const base::string16& explanation) override { 102 LoginModelData* login_model_data) override {
102 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 103 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
103 104
104 // Create a new LoginView and set the model for it. The model (password 105 // Create a new LoginView and set the model for it. The model (password
105 // manager) is owned by the WebContents, but the view is parented to the 106 // manager) is owned by the WebContents, but the view is parented to the
106 // browser window, so the view may be destroyed after the password 107 // browser window, so the view may be destroyed after the password
107 // manager. The view listens for model destruction and unobserves 108 // manager. The view listens for model destruction and unobserves
108 // accordingly. 109 // accordingly.
109 login_view_ = new LoginView(explanation, manager); 110 login_view_ = new LoginView(explanation, login_model_data);
110 111
111 // Scary thread safety note: This can potentially be called *after* SetAuth 112 // Scary thread safety note: This can potentially be called *after* SetAuth
112 // or CancelAuth (say, if the request was cancelled before the UI thread got 113 // or CancelAuth (say, if the request was cancelled before the UI thread got
113 // control). However, that's OK since any UI interaction in those functions 114 // control). However, that's OK since any UI interaction in those functions
114 // will occur via an InvokeLater on the UI thread, which is guaranteed 115 // will occur via an InvokeLater on the UI thread, which is guaranteed
115 // to happen after this is called (since this was InvokeLater'd first). 116 // to happen after this is called (since this was InvokeLater'd first).
116 dialog_ = constrained_window::ShowWebModalDialogViews( 117 dialog_ = constrained_window::ShowWebModalDialogViews(
117 this, GetWebContentsForLogin()); 118 this, GetWebContentsForLogin());
118 NotifyAuthNeeded(); 119 NotifyAuthNeeded();
119 } 120 }
(...skipping 19 matching lines...) Expand all
139 }; 140 };
140 141
141 namespace chrome { 142 namespace chrome {
142 143
143 LoginHandler* CreateLoginHandlerViews(net::AuthChallengeInfo* auth_info, 144 LoginHandler* CreateLoginHandlerViews(net::AuthChallengeInfo* auth_info,
144 net::URLRequest* request) { 145 net::URLRequest* request) {
145 return new LoginHandlerViews(auth_info, request); 146 return new LoginHandlerViews(auth_info, request);
146 } 147 }
147 148
148 } // namespace chrome 149 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/login/login_prompt.cc ('k') | chrome/browser/ui/views/login_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698