OLD | NEW |
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 "android_webview/browser/aw_login_delegate.h" | 5 #include "android_webview/browser/aw_login_delegate.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/supports_user_data.h" | 9 #include "base/supports_user_data.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 this, (count->auth_attempts_ == 0))); | 59 this, (count->auth_attempts_ == 0))); |
60 count->auth_attempts_++; | 60 count->auth_attempts_++; |
61 } | 61 } |
62 | 62 |
63 AwLoginDelegate::~AwLoginDelegate() { | 63 AwLoginDelegate::~AwLoginDelegate() { |
64 // The Auth handler holds a ref count back on |this| object, so it should be | 64 // The Auth handler holds a ref count back on |this| object, so it should be |
65 // impossible to reach here while this object still owns an auth handler. | 65 // impossible to reach here while this object still owns an auth handler. |
66 DCHECK(aw_http_auth_handler_ == NULL); | 66 DCHECK(aw_http_auth_handler_ == NULL); |
67 } | 67 } |
68 | 68 |
69 void AwLoginDelegate::Proceed(const string16& user, | 69 void AwLoginDelegate::Proceed(const base::string16& user, |
70 const string16& password) { | 70 const base::string16& password) { |
71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
72 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 72 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
73 base::Bind(&AwLoginDelegate::ProceedOnIOThread, | 73 base::Bind(&AwLoginDelegate::ProceedOnIOThread, |
74 this, user, password)); | 74 this, user, password)); |
75 } | 75 } |
76 | 76 |
77 void AwLoginDelegate::Cancel() { | 77 void AwLoginDelegate::Cancel() { |
78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
79 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 79 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
80 base::Bind(&AwLoginDelegate::CancelOnIOThread, this)); | 80 base::Bind(&AwLoginDelegate::CancelOnIOThread, this)); |
(...skipping 24 matching lines...) Expand all Loading... |
105 void AwLoginDelegate::CancelOnIOThread() { | 105 void AwLoginDelegate::CancelOnIOThread() { |
106 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 106 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
107 if (request_) { | 107 if (request_) { |
108 request_->CancelAuth(); | 108 request_->CancelAuth(); |
109 ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(request_); | 109 ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(request_); |
110 request_ = NULL; | 110 request_ = NULL; |
111 } | 111 } |
112 DeleteAuthHandlerSoon(); | 112 DeleteAuthHandlerSoon(); |
113 } | 113 } |
114 | 114 |
115 void AwLoginDelegate::ProceedOnIOThread(const string16& user, | 115 void AwLoginDelegate::ProceedOnIOThread(const base::string16& user, |
116 const string16& password) { | 116 const base::string16& password) { |
117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
118 if (request_) { | 118 if (request_) { |
119 request_->SetAuth(net::AuthCredentials(user, password)); | 119 request_->SetAuth(net::AuthCredentials(user, password)); |
120 ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(request_); | 120 ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(request_); |
121 request_ = NULL; | 121 request_ = NULL; |
122 } | 122 } |
123 DeleteAuthHandlerSoon(); | 123 DeleteAuthHandlerSoon(); |
124 } | 124 } |
125 | 125 |
126 void AwLoginDelegate::OnRequestCancelled() { | 126 void AwLoginDelegate::OnRequestCancelled() { |
127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
128 request_ = NULL; | 128 request_ = NULL; |
129 DeleteAuthHandlerSoon(); | 129 DeleteAuthHandlerSoon(); |
130 } | 130 } |
131 | 131 |
132 void AwLoginDelegate::DeleteAuthHandlerSoon() { | 132 void AwLoginDelegate::DeleteAuthHandlerSoon() { |
133 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 133 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
134 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 134 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
135 base::Bind(&AwLoginDelegate::DeleteAuthHandlerSoon, this)); | 135 base::Bind(&AwLoginDelegate::DeleteAuthHandlerSoon, this)); |
136 return; | 136 return; |
137 } | 137 } |
138 aw_http_auth_handler_.reset(); | 138 aw_http_auth_handler_.reset(); |
139 } | 139 } |
140 | 140 |
141 } // namespace android_webview | 141 } // namespace android_webview |
OLD | NEW |