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

Side by Side Diff: chrome/browser/chromeos/app_mode/startup_app_launcher.h

Issue 22914008: Refactor kiosk app launch to be part of login screen UI flow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_STARTUP_APP_LAUNCHER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_STARTUP_APP_LAUNCHER_H_
6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_STARTUP_APP_LAUNCHER_H_ 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_STARTUP_APP_LAUNCHER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list.h"
13 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
14 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" 15 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
15 #include "chrome/browser/signin/oauth2_token_service.h" 16 #include "chrome/browser/signin/oauth2_token_service.h"
16 #include "net/base/network_change_notifier.h" 17 #include "net/base/network_change_notifier.h"
17 #include "ui/base/events/event_handler.h"
18 18
19 class Profile; 19 class Profile;
20 20
21 namespace extensions { 21 namespace extensions {
22 class WebstoreStandaloneInstaller; 22 class WebstoreStandaloneInstaller;
23 } 23 }
24 24
25 namespace chromeos { 25 namespace chromeos {
26 26
27 // Launches the app at startup. The flow roughly looks like this: 27 // Launches the app at startup. The flow roughly looks like this:
28 // - Starts the app launch splash screen;
29 // - Checks if the app is installed in user profile (aka app profile); 28 // - Checks if the app is installed in user profile (aka app profile);
30 // - If the app is installed, launch it and finish the flow; 29 // - If the app is installed, launch it and finish the flow;
31 // - If not installed, prepare to start install by checking network online 30 // - If not installed, prepare to start install by checking network online
32 // state; 31 // state;
33 // - If network gets online in time, start to install the app from web store; 32 // - If network gets online in time, start to install the app from web store;
34 // - If all goes good, launches the app and finish the flow; 33 // - If all goes good, launches the app and finish the flow;
35 // If anything goes wrong, it exits app mode and goes back to login screen.
36 class StartupAppLauncher 34 class StartupAppLauncher
37 : public base::SupportsWeakPtr<StartupAppLauncher>, 35 : public base::SupportsWeakPtr<StartupAppLauncher>,
38 public OAuth2TokenService::Observer, 36 public OAuth2TokenService::Observer,
39 public net::NetworkChangeNotifier::NetworkChangeObserver, 37 public net::NetworkChangeNotifier::NetworkChangeObserver {
40 public ui::EventHandler {
41 public: 38 public:
39 class Observer {
40 public:
41 virtual void OnLoadingOAuthFile() = 0;
42 virtual void OnInitializingTokenService() = 0;
43 virtual void OnInitializingNetwork() = 0;
44 virtual void OnNetworkWaitTimedout() = 0;
45 virtual void OnInstallingApp() = 0;
46 virtual void OnLaunchSucceeded() = 0;
47 virtual void OnLaunchFailed(KioskAppLaunchError::Error error) = 0;
48
49 protected:
50 virtual ~Observer() {}
51 };
52
42 StartupAppLauncher(Profile* profile, const std::string& app_id); 53 StartupAppLauncher(Profile* profile, const std::string& app_id);
43 54
55 virtual ~StartupAppLauncher();
56
44 // Starts app launcher. If |skip_auth_setup| is set, we will skip 57 // Starts app launcher. If |skip_auth_setup| is set, we will skip
45 // TokenService initialization. 58 // TokenService initialization.
46 void Start(); 59 void Start();
47 60
61 // Add and remove observers for app launch procedure.
62 void AddObserver(Observer* observer);
63 void RemoveObserver(Observer* observer);
64
48 private: 65 private:
49 // OAuth parameters from /home/chronos/kiosk_auth file. 66 // OAuth parameters from /home/chronos/kiosk_auth file.
50 struct KioskOAuthParams { 67 struct KioskOAuthParams {
51 std::string refresh_token; 68 std::string refresh_token;
52 std::string client_id; 69 std::string client_id;
53 std::string client_secret; 70 std::string client_secret;
54 }; 71 };
55 72
56 // Private dtor because this class manages its own lifetime.
57 virtual ~StartupAppLauncher();
58
59 void Cleanup();
60 void OnLaunchSuccess(); 73 void OnLaunchSuccess();
61 void OnLaunchFailure(KioskAppLaunchError::Error error); 74 void OnLaunchFailure(KioskAppLaunchError::Error error);
62 75
63 void Launch(); 76 void Launch();
64 77
65 void BeginInstall(); 78 void BeginInstall();
66 void InstallCallback(bool success, const std::string& error); 79 void InstallCallback(bool success, const std::string& error);
67 80
68 void InitializeTokenService(); 81 void InitializeTokenService();
69 void InitializeNetwork(); 82 void InitializeNetwork();
70 83
71 void OnNetworkWaitTimedout(); 84 void OnNetworkWaitTimedout();
72 85
73 void StartLoadingOAuthFile(); 86 void StartLoadingOAuthFile();
74 static void LoadOAuthFileOnBlockingPool(KioskOAuthParams* auth_params); 87 static void LoadOAuthFileOnBlockingPool(KioskOAuthParams* auth_params);
75 void OnOAuthFileLoaded(KioskOAuthParams* auth_params); 88 void OnOAuthFileLoaded(KioskOAuthParams* auth_params);
76 89
77 // OAuth2TokenService::Observer overrides. 90 // OAuth2TokenService::Observer overrides.
78 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE; 91 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE;
79 virtual void OnRefreshTokensLoaded() OVERRIDE; 92 virtual void OnRefreshTokensLoaded() OVERRIDE;
80 93
81 // net::NetworkChangeNotifier::NetworkChangeObserver overrides: 94 // net::NetworkChangeNotifier::NetworkChangeObserver overrides:
82 virtual void OnNetworkChanged( 95 virtual void OnNetworkChanged(
83 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; 96 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
84 97
85 // ui::EventHandler overrides:
86 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
87
88 Profile* profile_; 98 Profile* profile_;
89 const std::string app_id_; 99 const std::string app_id_;
90 100 ObserverList<Observer> observer_list_;
91 int64 launch_splash_start_time_;
92 101
93 scoped_refptr<extensions::WebstoreStandaloneInstaller> installer_; 102 scoped_refptr<extensions::WebstoreStandaloneInstaller> installer_;
94 base::OneShotTimer<StartupAppLauncher> network_wait_timer_; 103 base::OneShotTimer<StartupAppLauncher> network_wait_timer_;
95 KioskOAuthParams auth_params_; 104 KioskOAuthParams auth_params_;
96 105
97 DISALLOW_COPY_AND_ASSIGN(StartupAppLauncher); 106 DISALLOW_COPY_AND_ASSIGN(StartupAppLauncher);
98 }; 107 };
99 108
100 } // namespace chromeos 109 } // namespace chromeos
101 110
102 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_STARTUP_APP_LAUNCHER_H_ 111 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_STARTUP_APP_LAUNCHER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/app_mode/kiosk_profile_loader.cc ('k') | chrome/browser/chromeos/app_mode/startup_app_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698