Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 | 51 |
| 52 SendResponse(request_id, base::RefCountedString::TakeString(&response)); | 52 SendResponse(request_id, base::RefCountedString::TakeString(&response)); |
| 53 } | 53 } |
| 54 | 54 |
| 55 virtual std::string GetMimeType(const std::string& path) const OVERRIDE { | 55 virtual std::string GetMimeType(const std::string& path) const OVERRIDE { |
| 56 return "text/html"; | 56 return "text/html"; |
| 57 } | 57 } |
| 58 | 58 |
| 59 static void RegisterDataSource(Profile *profile) { | 59 static void RegisterDataSource(Profile *profile) { |
| 60 ChromeURLDataManager* url_manager = profile->GetChromeURLDataManager(); | 60 ChromeURLDataManager* url_manager = profile->GetChromeURLDataManager(); |
| 61 LoginHandlerSource *source = new LoginHandlerSource(); | 61 LoginHandlerSource* source = new LoginHandlerSource(); |
| 62 url_manager->AddDataSource(source); | 62 url_manager->AddDataSource(source); |
| 63 } | 63 } |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 virtual ~LoginHandlerSource() {} | 66 virtual ~LoginHandlerSource() {} |
| 67 | 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(LoginHandlerSource); | 68 DISALLOW_COPY_AND_ASSIGN(LoginHandlerSource); |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 class LoginHandlerHtml; | 71 class LoginHandlerHtml; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 // Send autofill data to HTML once the dialog is ready and the data is | 134 // Send autofill data to HTML once the dialog is ready and the data is |
| 135 // available. | 135 // available. |
| 136 void SendAutofillData(); | 136 void SendAutofillData(); |
| 137 | 137 |
| 138 // Handle the request for autofill data from HTML. | 138 // Handle the request for autofill data from HTML. |
| 139 void GetAutofill(const ListValue* args) { | 139 void GetAutofill(const ListValue* args) { |
| 140 ready_for_autofill_ = true; | 140 ready_for_autofill_ = true; |
| 141 SendAutofillData(); | 141 SendAutofillData(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 LoginHandlerHtml *login_handler_; | 144 LoginHandlerHtml* login_handler_; |
| 145 std::string explanation_; | 145 std::string explanation_; |
| 146 bool closed_; | 146 bool closed_; |
| 147 | 147 |
| 148 bool has_autofill_; | 148 bool has_autofill_; |
| 149 bool ready_for_autofill_; | 149 bool ready_for_autofill_; |
| 150 std::string autofill_username_; | 150 std::string autofill_username_; |
| 151 std::string autofill_password_; | 151 std::string autofill_password_; |
| 152 | 152 |
| 153 static const int kDialogWidth = 400; | 153 static const int kDialogWidth = 400; |
| 154 static const int kDialogHeight = 160; | 154 static const int kDialogHeight = 160; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 173 // LoginHandler method: | 173 // LoginHandler method: |
| 174 virtual void BuildViewForPasswordManager( | 174 virtual void BuildViewForPasswordManager( |
| 175 PasswordManager* manager, const string16& explanation) OVERRIDE; | 175 PasswordManager* manager, const string16& explanation) OVERRIDE; |
| 176 | 176 |
| 177 friend class LoginHandlerHtmlDelegate; | 177 friend class LoginHandlerHtmlDelegate; |
| 178 | 178 |
| 179 protected: | 179 protected: |
| 180 virtual ~LoginHandlerHtml() {} | 180 virtual ~LoginHandlerHtml() {} |
| 181 | 181 |
| 182 private: | 182 private: |
| 183 LoginHandlerHtmlDelegate *delegate_; | 183 LoginHandlerHtmlDelegate* delegate_; |
| 184 | 184 |
| 185 void FreeAndRelease() { | 185 void FreeAndRelease() { |
| 186 SetDialog(NULL); | 186 SetDialog(NULL); |
| 187 SetModel(NULL); | 187 SetModel(NULL); |
| 188 ReleaseSoon(); | 188 ReleaseSoon(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 DISALLOW_COPY_AND_ASSIGN(LoginHandlerHtml); | 191 DISALLOW_COPY_AND_ASSIGN(LoginHandlerHtml); |
| 192 }; | 192 }; |
| 193 | 193 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 void LoginHandlerHtml::BuildViewForPasswordManager( | 238 void LoginHandlerHtml::BuildViewForPasswordManager( |
| 239 PasswordManager* manager, const string16& explanation) { | 239 PasswordManager* manager, const string16& explanation) { |
| 240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 241 | 241 |
| 242 TabContents* tab_contents = GetTabContentsForLogin(); | 242 TabContents* tab_contents = GetTabContentsForLogin(); |
| 243 TabContentsWrapper* wrapper = | 243 TabContentsWrapper* wrapper = |
| 244 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); | 244 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); |
| 245 Profile* profile = wrapper->profile(); | 245 Profile* profile = wrapper->profile(); |
| 246 LoginHandlerSource::RegisterDataSource(profile); | 246 LoginHandlerSource::RegisterDataSource(profile); |
| 247 delegate_ = new LoginHandlerHtmlDelegate(this, explanation); | 247 delegate_ = new LoginHandlerHtmlDelegate(this, explanation); |
| 248 ConstrainedWindow* dialog = ConstrainedHtmlUI::CreateConstrainedHtmlDialog( | 248 ConstrainedHtmlUIDelegate* html_ui_delegate = |
| 249 profile, delegate_, wrapper); | 249 ConstrainedHtmlUI::CreateConstrainedHtmlDialog(profile, delegate_, |
| 250 wrapper); | |
|
Evan Stade
2011/10/13 23:59:14
nit: don't need to store delegate variable
Lei Zhang
2011/10/14 17:31:05
As in you prefer:
ConstrainedWindow* dialog = Con
| |
| 251 ConstrainedWindow* dialog = html_ui_delegate->window(); | |
| 250 | 252 |
| 251 SetModel(manager); | 253 SetModel(manager); |
| 252 SetDialog(dialog); | 254 SetDialog(dialog); |
| 253 | 255 |
| 254 NotifyAuthNeeded(); | 256 NotifyAuthNeeded(); |
| 255 } | 257 } |
| 256 | 258 |
| 257 // static | 259 // static |
| 258 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, | 260 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, |
| 259 net::URLRequest* request) { | 261 net::URLRequest* request) { |
| 260 return new LoginHandlerHtml(auth_info, request); | 262 return new LoginHandlerHtml(auth_info, request); |
| 261 } | 263 } |
| OLD | NEW |