1 // Copyright 2016 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_GOOGLE_AUTH_NAVIGATION_THROTTLE_H_ 6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_GOOGLE_AUTH_NAVIGATION_THROTTLE_H_ 7 8 #include <memory> 9 10 #include "base/callback_list.h" 11 #include "base/compiler_specific.h" 12 #include "base/macros.h" 13 #include "base/memory/weak_ptr.h" 14 #include "chrome/browser/supervised_user/supervised_users.h" 15 #include "content/public/browser/navigation_throttle.h" 16 17 class ChildAccountService; 18 class Profile; 19 20 class SupervisedUserGoogleAuthNavigationThrottle 21 : public content::NavigationThrottle { 22 public: 23 // Returns a new throttle for the given navigation handle, or nullptr if no 24 // throttling is required. 25 static std::unique_ptr<SupervisedUserGoogleAuthNavigationThrottle> 26 MaybeCreate(content::NavigationHandle* navigation_handle); 27 28 ~SupervisedUserGoogleAuthNavigationThrottle() override; 29 30 ThrottleCheckResult WillStartRequest() override; 31 ThrottleCheckResult WillRedirectRequest() override; 32 const char* GetNameForLogging() override; 33 34 private: 35 SupervisedUserGoogleAuthNavigationThrottle( 36 Profile* profile, 37 content::NavigationHandle* navigation_handle); 38 39 void OnGoogleAuthStateChanged(); 40 41 ThrottleCheckResult WillStartOrRedirectRequest(); 42 43 ThrottleCheckResult ShouldProceed(); 44 45 void OnReauthenticationResult(bool reauth_successful); 46 47 ChildAccountService* child_account_service_; 48 std::unique_ptr<base::CallbackList<void()>::Subscription> 49 google_auth_state_subscription_; 50 51 #if defined(OS_ANDROID) 52 bool has_shown_reauth_; 53 #endif 54 55 base::WeakPtrFactory<SupervisedUserGoogleAuthNavigationThrottle> 56 weak_ptr_factory_{this}; 57 58 DISALLOW_COPY_AND_ASSIGN(SupervisedUserGoogleAuthNavigationThrottle); 59 }; 60 61 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_GOOGLE_AUTH_NAVIGATION_THROTTLE_H_ 62