1 // Copyright 2018 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_CHROMEOS_LOGIN_SCREENS_RECOMMEND_APPS_SCREEN_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_RECOMMEND_APPS_SCREEN_H_ 7 8 #include <memory> 9 #include <string> 10 11 #include "base/callback.h" 12 #include "base/macros.h" 13 #include "chrome/browser/chromeos/login/screens/base_screen.h" 14 #include "chrome/browser/chromeos/login/screens/recommend_apps/recommend_apps_fetcher_delegate.h" 15 16 namespace base { 17 class Value; 18 } 19 20 namespace chromeos { 21 22 class RecommendAppsFetcher; 23 class RecommendAppsScreenView; 24 25 // This is Recommend Apps screen that is displayed as a part of user first 26 // sign-in flow. 27 class RecommendAppsScreen : public BaseScreen, 28 public RecommendAppsFetcherDelegate { 29 public: 30 using TView = RecommendAppsScreenView; 31 32 enum class Result { SELECTED, SKIPPED, NOT_APPLICABLE, LOAD_ERROR }; 33 34 static std::string GetResultString(Result result); 35 36 using ScreenExitCallback = base::RepeatingCallback<void(Result result)>; 37 38 RecommendAppsScreen(RecommendAppsScreenView* view, 39 const ScreenExitCallback& exit_callback); 40 ~RecommendAppsScreen() override; 41 42 // Called when the user skips the Recommend Apps screen. 43 void OnSkip(); 44 45 // Called when the user tries to reload the screen. 46 void OnRetry(); 47 48 // Called when the user Install the selected apps. 49 void OnInstall(); 50 51 // Called when the view is destroyed so there is no dead reference to it. 52 void OnViewDestroyed(RecommendAppsScreenView* view); 53 SetSkipForTesting()54 void SetSkipForTesting() { skip_for_testing_ = true; } 55 56 // RecommendAppsFetcherDelegate: 57 void OnLoadSuccess(const base::Value& app_list) override; 58 void OnLoadError() override; 59 void OnParseResponseError() override; 60 61 // BaseScreen: 62 bool MaybeSkip(WizardContext* context) override; 63 set_exit_callback_for_testing(ScreenExitCallback exit_callback)64 void set_exit_callback_for_testing(ScreenExitCallback exit_callback) { 65 exit_callback_ = exit_callback; 66 } 67 68 private: 69 // BaseScreen: 70 void ShowImpl() override; 71 void HideImpl() override; 72 73 RecommendAppsScreenView* view_; 74 ScreenExitCallback exit_callback_; 75 76 std::unique_ptr<RecommendAppsFetcher> recommend_apps_fetcher_; 77 78 // Skip the screen for testing if set to true. 79 bool skip_for_testing_ = false; 80 81 DISALLOW_COPY_AND_ASSIGN(RecommendAppsScreen); 82 }; 83 84 } // namespace chromeos 85 86 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_RECOMMEND_APPS_SCREEN_H_ 87