Chromium Code Reviews| 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 "chrome/browser/ui/login/login_handler.h" | 5 #include "chrome/browser/ui/login/login_handler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 | |
| 13 #include "device/vr/features/features.h" | |
| 14 #if BUILDFLAG(ENABLE_VR) | |
| 15 #include "chrome/browser/android/vr_shell/vr_tab_helper.h" | |
| 16 #endif // BUILDFLAG(ENABLE_VR) | |
| 17 | |
| 12 #include "chrome/browser/ui/android/chrome_http_auth_handler.h" | 18 #include "chrome/browser/ui/android/chrome_http_auth_handler.h" |
| 13 #include "chrome/browser/ui/android/view_android_helper.h" | 19 #include "chrome/browser/ui/android/view_android_helper.h" |
| 14 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 16 #include "net/base/auth.h" | 22 #include "net/base/auth.h" |
| 17 #include "ui/android/view_android.h" | 23 #include "ui/android/view_android.h" |
| 18 #include "ui/android/window_android.h" | 24 #include "ui/android/window_android.h" |
| 19 | 25 |
| 20 using content::BrowserThread; | 26 using content::BrowserThread; |
| 21 using net::URLRequest; | 27 using net::URLRequest; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 44 LoginModelData* login_model_data) override { | 50 LoginModelData* login_model_data) override { |
| 45 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 51 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 46 | 52 |
| 47 // Get pointer to TabAndroid | 53 // Get pointer to TabAndroid |
| 48 content::WebContents* web_contents = GetWebContentsForLogin(); | 54 content::WebContents* web_contents = GetWebContentsForLogin(); |
| 49 CHECK(web_contents); | 55 CHECK(web_contents); |
| 50 ViewAndroidHelper* view_helper = ViewAndroidHelper::FromWebContents( | 56 ViewAndroidHelper* view_helper = ViewAndroidHelper::FromWebContents( |
| 51 web_contents); | 57 web_contents); |
| 52 | 58 |
| 53 // Notify WindowAndroid that HTTP authentication is required. | 59 // Notify WindowAndroid that HTTP authentication is required. |
| 54 if (view_helper->GetViewAndroid() | 60 if (view_helper->GetViewAndroid() && |
| 55 && view_helper->GetViewAndroid()->GetWindowAndroid()) { | 61 view_helper->GetViewAndroid()->GetWindowAndroid() |
| 62 #if BUILDFLAG(ENABLE_VR) | |
|
Ted C
2017/05/24 17:40:44
just for readability, I'd be tempted to pull this
billorr
2017/05/24 18:00:42
Done.
| |
| 63 && !vr_shell::VrTabHelper::IsInVr(web_contents) | |
| 64 #endif | |
| 65 ) { | |
| 56 chrome_http_auth_handler_.reset( | 66 chrome_http_auth_handler_.reset( |
| 57 new ChromeHttpAuthHandler(authority, explanation)); | 67 new ChromeHttpAuthHandler(authority, explanation)); |
| 58 chrome_http_auth_handler_->Init(); | 68 chrome_http_auth_handler_->Init(); |
| 59 chrome_http_auth_handler_->SetObserver(this); | 69 chrome_http_auth_handler_->SetObserver(this); |
| 60 chrome_http_auth_handler_->ShowDialog( | 70 chrome_http_auth_handler_->ShowDialog( |
| 61 view_helper->GetViewAndroid() | 71 view_helper->GetViewAndroid() |
| 62 ->GetWindowAndroid()->GetJavaObject().obj()); | 72 ->GetWindowAndroid()->GetJavaObject().obj()); |
| 63 | 73 |
| 64 if (login_model_data) | 74 if (login_model_data) |
| 65 SetModel(*login_model_data); | 75 SetModel(*login_model_data); |
| 66 else | 76 else |
| 67 ResetModel(); | 77 ResetModel(); |
| 68 | 78 |
| 69 NotifyAuthNeeded(); | 79 NotifyAuthNeeded(); |
| 70 } else { | 80 } else { |
| 71 CancelAuth(); | 81 CancelAuth(); |
| 72 LOG(WARNING) << "HTTP Authentication failed because TabAndroid is " | 82 #if BUILDFLAG(ENABLE_VR) |
| 73 "missing"; | 83 // Only LOG(WARNING) if we aren't in VR |
| 84 if (!vr_shell::VrTabHelper::IsInVr(web_contents)) | |
| 85 #endif | |
| 86 LOG(WARNING) << "HTTP Authentication failed because TabAndroid is " | |
| 87 "missing"; | |
| 74 } | 88 } |
| 75 } | 89 } |
| 76 | 90 |
| 77 protected: | 91 protected: |
| 78 ~LoginHandlerAndroid() override {} | 92 ~LoginHandlerAndroid() override {} |
| 79 | 93 |
| 80 void CloseDialog() override {} | 94 void CloseDialog() override {} |
| 81 | 95 |
| 82 private: | 96 private: |
| 83 std::unique_ptr<ChromeHttpAuthHandler> chrome_http_auth_handler_; | 97 std::unique_ptr<ChromeHttpAuthHandler> chrome_http_auth_handler_; |
| 84 }; | 98 }; |
| 85 | 99 |
| 86 // static | 100 // static |
| 87 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, | 101 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, |
| 88 net::URLRequest* request) { | 102 net::URLRequest* request) { |
| 89 return new LoginHandlerAndroid(auth_info, request); | 103 return new LoginHandlerAndroid(auth_info, request); |
| 90 } | 104 } |
| OLD | NEW |