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

Side by Side Diff: chrome/browser/ui/android/login_prompt_android.cc

Issue 378633002: Upstream support for basic Http authentication. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix indentation Created 6 years, 5 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
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/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/android/tab_android.h"
12 #include "chrome/browser/ui/android/chrome_http_auth_handler.h" 11 #include "chrome/browser/ui/android/chrome_http_auth_handler.h"
12 #include "chrome/browser/ui/android/window_android_helper.h"
13 #include "chrome/browser/ui/login/login_prompt.h" 13 #include "chrome/browser/ui/login/login_prompt.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "net/base/auth.h" 16 #include "net/base/auth.h"
17 #include "ui/base/android/window_android.h"
17 18
18 using content::BrowserThread; 19 using content::BrowserThread;
19 using net::URLRequest; 20 using net::URLRequest;
20 using net::AuthChallengeInfo; 21 using net::AuthChallengeInfo;
21 22
22 class LoginHandlerAndroid : public LoginHandler { 23 class LoginHandlerAndroid : public LoginHandler {
23 public: 24 public:
24 LoginHandlerAndroid(AuthChallengeInfo* auth_info, URLRequest* request) 25 LoginHandlerAndroid(AuthChallengeInfo* auth_info, URLRequest* request)
25 : LoginHandler(auth_info, request) { 26 : LoginHandler(auth_info, request) {
26 } 27 }
(...skipping 11 matching lines...) Expand all
38 virtual void OnLoginModelDestroying() OVERRIDE {} 39 virtual void OnLoginModelDestroying() OVERRIDE {}
39 40
40 virtual void BuildViewForPasswordManager( 41 virtual void BuildViewForPasswordManager(
41 password_manager::PasswordManager* manager, 42 password_manager::PasswordManager* manager,
42 const base::string16& explanation) OVERRIDE { 43 const base::string16& explanation) OVERRIDE {
43 DCHECK_CURRENTLY_ON(BrowserThread::UI); 44 DCHECK_CURRENTLY_ON(BrowserThread::UI);
44 45
45 // Get pointer to TabAndroid 46 // Get pointer to TabAndroid
46 content::WebContents* web_contents = GetWebContentsForLogin(); 47 content::WebContents* web_contents = GetWebContentsForLogin();
47 CHECK(web_contents); 48 CHECK(web_contents);
48 TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents); 49 WindowAndroidHelper* window_helper = WindowAndroidHelper::FromWebContents(
50 web_contents);
49 51
50 // Notify TabAndroid that HTTP authentication is required for current page. 52 // Notify WindowAndroid that HTTP authentication is required.
51 if (tab_android) { 53 if (window_helper->GetWindowAndroid()) {
52 chrome_http_auth_handler_.reset(new ChromeHttpAuthHandler(explanation)); 54 chrome_http_auth_handler_.reset(new ChromeHttpAuthHandler(explanation));
53 chrome_http_auth_handler_->Init(); 55 chrome_http_auth_handler_->Init();
54 chrome_http_auth_handler_->SetObserver(this); 56 chrome_http_auth_handler_->SetObserver(this);
55 57 chrome_http_auth_handler_->ShowDialog(
56 tab_android->OnReceivedHttpAuthRequest( 58 window_helper->GetWindowAndroid()->GetJavaObject().obj());
57 chrome_http_auth_handler_.get()->GetJavaObject(),
58 base::ASCIIToUTF16(auth_info()->challenger.ToString()),
59 base::UTF8ToUTF16(auth_info()->realm));
60 59
61 // Register to receive a callback to OnAutofillDataAvailable(). 60 // Register to receive a callback to OnAutofillDataAvailable().
62 SetModel(manager); 61 SetModel(manager);
63 NotifyAuthNeeded(); 62 NotifyAuthNeeded();
64 } else { 63 } else {
65 CancelAuth(); 64 CancelAuth();
66 LOG(WARNING) << "HTTP Authentication failed because TabAndroid is " 65 LOG(WARNING) << "HTTP Authentication failed because TabAndroid is "
67 "missing"; 66 "missing";
68 } 67 }
69 } 68 }
70 69
71 protected: 70 protected:
72 virtual ~LoginHandlerAndroid() {} 71 virtual ~LoginHandlerAndroid() {}
73 72
74 virtual void CloseDialog() OVERRIDE {} 73 virtual void CloseDialog() OVERRIDE {}
75 74
76 private: 75 private:
77 scoped_ptr<ChromeHttpAuthHandler> chrome_http_auth_handler_; 76 scoped_ptr<ChromeHttpAuthHandler> chrome_http_auth_handler_;
78 }; 77 };
79 78
80 // static 79 // static
81 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, 80 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info,
82 net::URLRequest* request) { 81 net::URLRequest* request) {
83 return new LoginHandlerAndroid(auth_info, request); 82 return new LoginHandlerAndroid(auth_info, request);
84 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698