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

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

Issue 9704056: Login dialog->views on cros too. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/login/login_prompt_ui.cc ('k') | chrome/browser/ui/login/login_prompt_win.cc » ('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/string16.h" 7 #include "base/string16.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/password_manager/password_manager.h" 9 #include "chrome/browser/password_manager/password_manager.h"
10 #include "chrome/browser/tab_contents/tab_util.h" 10 #include "chrome/browser/tab_contents/tab_util.h"
11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
12 #include "chrome/browser/ui/views/constrained_window_views.h" 12 #include "chrome/browser/ui/views/constrained_window_views.h"
13 #include "chrome/browser/ui/views/login_view.h" 13 #include "chrome/browser/ui/views/login_view.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/render_view_host.h" 15 #include "content/public/browser/render_view_host.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "grit/generated_resources.h" 17 #include "grit/generated_resources.h"
18 #include "net/url_request/url_request.h" 18 #include "net/url_request/url_request.h"
19 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/views/window/dialog_delegate.h" 20 #include "ui/views/window/dialog_delegate.h"
21 21
22 using content::BrowserThread; 22 using content::BrowserThread;
23 using content::WebContents; 23 using content::WebContents;
24 using webkit::forms::PasswordForm; 24 using webkit::forms::PasswordForm;
25 25
26 // ---------------------------------------------------------------------------- 26 // ----------------------------------------------------------------------------
27 // LoginHandlerWin 27 // LoginHandlerViews
28 28
29 // This class simply forwards the authentication from the LoginView (on 29 // This class simply forwards the authentication from the LoginView (on
30 // the UI thread) to the net::URLRequest (on the I/O thread). 30 // the UI thread) to the net::URLRequest (on the I/O thread).
31 // This class uses ref counting to ensure that it lives until all InvokeLaters 31 // This class uses ref counting to ensure that it lives until all InvokeLaters
32 // have been called. 32 // have been called.
33 class LoginHandlerWin : public LoginHandler, 33 class LoginHandlerViews : public LoginHandler,
34 public views::DialogDelegate { 34 public views::DialogDelegate {
35 public: 35 public:
36 LoginHandlerWin(net::AuthChallengeInfo* auth_info, net::URLRequest* request) 36 LoginHandlerViews(net::AuthChallengeInfo* auth_info, net::URLRequest* request)
37 : LoginHandler(auth_info, request), 37 : LoginHandler(auth_info, request),
38 login_view_(NULL) { 38 login_view_(NULL) {
39 } 39 }
40 40
41 // LoginModelObserver implementation. 41 // LoginModelObserver implementation.
42 virtual void OnAutofillDataAvailable(const string16& username, 42 virtual void OnAutofillDataAvailable(const string16& username,
43 const string16& password) OVERRIDE { 43 const string16& password) OVERRIDE {
44 // Nothing to do here since LoginView takes care of autofill for win. 44 // Nothing to do here since LoginView takes care of autofill for win.
45 } 45 }
46 46
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 virtual void BuildViewForPasswordManager( 112 virtual void BuildViewForPasswordManager(
113 PasswordManager* manager, 113 PasswordManager* manager,
114 const string16& explanation) OVERRIDE { 114 const string16& explanation) OVERRIDE {
115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
116 116
117 // Create a new LoginView and set the model for it. The model 117 // Create a new LoginView and set the model for it. The model
118 // (password manager) is owned by the view's parent TabContents, 118 // (password manager) is owned by the view's parent TabContents,
119 // so natural destruction order means we don't have to worry about 119 // so natural destruction order means we don't have to worry about
120 // disassociating the model from the view, because the view will 120 // disassociating the model from the view, because the view will
121 // be deleted before the password manager. 121 // be deleted before the password manager.
122 login_view_ = new LoginView(UTF16ToWideHack(explanation), manager); 122 login_view_ = new LoginView(explanation, manager);
123 123
124 // Scary thread safety note: This can potentially be called *after* SetAuth 124 // Scary thread safety note: This can potentially be called *after* SetAuth
125 // or CancelAuth (say, if the request was cancelled before the UI thread got 125 // or CancelAuth (say, if the request was cancelled before the UI thread got
126 // control). However, that's OK since any UI interaction in those functions 126 // control). However, that's OK since any UI interaction in those functions
127 // will occur via an InvokeLater on the UI thread, which is guaranteed 127 // will occur via an InvokeLater on the UI thread, which is guaranteed
128 // to happen after this is called (since this was InvokeLater'd first). 128 // to happen after this is called (since this was InvokeLater'd first).
129 WebContents* requesting_contents = GetWebContentsForLogin(); 129 WebContents* requesting_contents = GetWebContentsForLogin();
130 TabContentsWrapper* wrapper = 130 TabContentsWrapper* wrapper =
131 TabContentsWrapper::GetCurrentWrapperForContents(requesting_contents); 131 TabContentsWrapper::GetCurrentWrapperForContents(requesting_contents);
132 SetDialog(new ConstrainedWindowViews(wrapper, this)); 132 SetDialog(new ConstrainedWindowViews(wrapper, this));
133 NotifyAuthNeeded(); 133 NotifyAuthNeeded();
134 } 134 }
135 135
136 private: 136 private:
137 friend class base::RefCountedThreadSafe<LoginHandlerWin>; 137 friend class base::RefCountedThreadSafe<LoginHandlerViews>;
138 friend class LoginPrompt; 138 friend class LoginPrompt;
139 139
140 ~LoginHandlerWin() {} 140 ~LoginHandlerViews() {}
141 141
142 // The LoginView that contains the user's login information 142 // The LoginView that contains the user's login information
143 LoginView* login_view_; 143 LoginView* login_view_;
144 144
145 DISALLOW_COPY_AND_ASSIGN(LoginHandlerWin); 145 DISALLOW_COPY_AND_ASSIGN(LoginHandlerViews);
146 }; 146 };
147 147
148 // static 148 // static
149 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, 149 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info,
150 net::URLRequest* request) { 150 net::URLRequest* request) {
151 return new LoginHandlerWin(auth_info, request); 151 return new LoginHandlerViews(auth_info, request);
152 } 152 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/login/login_prompt_ui.cc ('k') | chrome/browser/ui/login/login_prompt_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698