1 // Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights 2 // reserved. Use of this source code is governed by a BSD-style license that can 3 // be found in the LICENSE file. 4 5 #ifndef CEF_LIBCEF_BROWSER_NET_SERVICE_LOGIN_DELEGATE_H_ 6 #define CEF_LIBCEF_BROWSER_NET_SERVICE_LOGIN_DELEGATE_H_ 7 8 #include "include/cef_base.h" 9 10 #include "base/memory/weak_ptr.h" 11 #include "content/public/browser/content_browser_client.h" 12 #include "content/public/browser/login_delegate.h" 13 #include "net/base/auth.h" 14 15 namespace content { 16 struct GlobalRequestID; 17 class WebContents; 18 } // namespace content 19 20 class CefBrowserHostBase; 21 class GURL; 22 23 namespace net_service { 24 25 class LoginDelegate : public content::LoginDelegate { 26 public: 27 // This object will be deleted when |callback| is executed or the request is 28 // canceled. |callback| should not be executed after this object is deleted. 29 LoginDelegate(const net::AuthChallengeInfo& auth_info, 30 content::WebContents* web_contents, 31 const content::GlobalRequestID& request_id, 32 const GURL& origin_url, 33 LoginAuthRequiredCallback callback); 34 35 void Continue(const CefString& username, const CefString& password); 36 void Cancel(); 37 38 private: 39 void Start(CefRefPtr<CefBrowserHostBase> browser, 40 const net::AuthChallengeInfo& auth_info, 41 const content::GlobalRequestID& request_id, 42 const GURL& origin_url); 43 44 LoginAuthRequiredCallback callback_; 45 base::WeakPtrFactory<LoginDelegate> weak_ptr_factory_; 46 }; 47 48 } // namespace net_service 49 50 #endif // CEF_LIBCEF_BROWSER_NET_SERVICE_LOGIN_DELEGATE_H_ 51