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

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

Issue 300843013: Install and launch kiosk app from cached crx file at start up. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ExternalProviderImplChromeOSTest.AppMode test case. Created 6 years, 5 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 "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" 13 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
14 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h"
15 #include "chrome/browser/extensions/install_observer.h"
14 #include "google_apis/gaia/oauth2_token_service.h" 16 #include "google_apis/gaia/oauth2_token_service.h"
15 17
16 class Profile; 18 class Profile;
17 19
18 namespace extensions {
19 class WebstoreStandaloneInstaller;
20 }
21
22 namespace chromeos { 20 namespace chromeos {
23 21
24 // Launches the app at startup. The flow roughly looks like this: 22 // Launches the app at startup. The flow roughly looks like this:
25 // First call Initialize(): 23 // First call Initialize():
26 // - Attempts to load oauth token file. Stores the loaded tokens in 24 // - Attempts to load oauth token file. Stores the loaded tokens in
27 // |auth_params_|. 25 // |auth_params_|.
28 // - Initialize token service and inject |auth_params_| if needed. 26 // - Initialize token service and inject |auth_params_| if needed.
29 // - Initialize network if app is not installed or not offline_enabled. 27 // - Initialize network if app is not installed or not offline_enabled.
30 // - If network is online, install or update the app as needed. 28 // - If network is online, install or update the app as needed.
31 // - After the app is installed/updated, launch it and finish the flow; 29 // - After the app is installed/updated, launch it and finish the flow;
32 // Report OnLauncherInitialized() or OnLaunchFailed() to observers: 30 // Report OnLauncherInitialized() or OnLaunchFailed() to observers:
33 // - If all goes good, launches the app and finish the flow; 31 // - If all goes good, launches the app and finish the flow;
34 class StartupAppLauncher 32 class StartupAppLauncher : public base::SupportsWeakPtr<StartupAppLauncher>,
35 : public base::SupportsWeakPtr<StartupAppLauncher>, 33 public OAuth2TokenService::Observer,
36 public OAuth2TokenService::Observer { 34 public extensions::InstallObserver,
35 public KioskAppManagerObserver {
37 public: 36 public:
38 class Delegate { 37 class Delegate {
39 public: 38 public:
40 // Invoked to perform actual network initialization work. Note the app 39 // Invoked to perform actual network initialization work. Note the app
41 // launch flow is paused until ContinueWithNetworkReady is called. 40 // launch flow is paused until ContinueWithNetworkReady is called.
42 virtual void InitializeNetwork() = 0; 41 virtual void InitializeNetwork() = 0;
43 42
44 // Returns true if Internet is online. 43 // Returns true if Internet is online.
45 virtual bool IsNetworkReady() = 0; 44 virtual bool IsNetworkReady() = 0;
46 45
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 84
86 void OnLaunchSuccess(); 85 void OnLaunchSuccess();
87 void OnLaunchFailure(KioskAppLaunchError::Error error); 86 void OnLaunchFailure(KioskAppLaunchError::Error error);
88 87
89 void MaybeInstall(); 88 void MaybeInstall();
90 89
91 // Callbacks from ExtensionUpdater. 90 // Callbacks from ExtensionUpdater.
92 void OnUpdateCheckFinished(); 91 void OnUpdateCheckFinished();
93 92
94 void BeginInstall(); 93 void BeginInstall();
95 void InstallCallback(bool success, const std::string& error);
96 void OnReadyToLaunch(); 94 void OnReadyToLaunch();
97 void UpdateAppData(); 95 void UpdateAppData();
98 96
99 void InitializeTokenService(); 97 void InitializeTokenService();
100 void MaybeInitializeNetwork(); 98 void MaybeInitializeNetwork();
101 99
102 void StartLoadingOAuthFile(); 100 void StartLoadingOAuthFile();
103 static void LoadOAuthFileOnBlockingPool(KioskOAuthParams* auth_params); 101 static void LoadOAuthFileOnBlockingPool(KioskOAuthParams* auth_params);
104 void OnOAuthFileLoaded(KioskOAuthParams* auth_params); 102 void OnOAuthFileLoaded(KioskOAuthParams* auth_params);
105 103
104 void OnKioskAppDataLoadStatusChanged(const std::string& app_id);
105
106 // OAuth2TokenService::Observer overrides. 106 // OAuth2TokenService::Observer overrides.
107 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE; 107 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE;
108 virtual void OnRefreshTokensLoaded() OVERRIDE; 108 virtual void OnRefreshTokensLoaded() OVERRIDE;
109 109
110 // extensions::InstallObserver overrides.
111 virtual void OnFinishCrxInstall(const std::string& extension_id,
112 bool success) OVERRIDE;
113
114 // KioskAppManagerObserver overrides.
115 virtual void OnKioskAppDataChanged(const std::string& app_id) OVERRIDE;
116 virtual void OnKioskAppDataLoadFailure(const std::string& app_id) OVERRIDE;
117
110 Profile* profile_; 118 Profile* profile_;
111 const std::string app_id_; 119 const std::string app_id_;
112 const bool diagnostic_mode_; 120 const bool diagnostic_mode_;
113 Delegate* delegate_; 121 Delegate* delegate_;
114 bool network_ready_handled_; 122 bool network_ready_handled_;
115 int install_attempt_; 123 int launch_attempt_;
116 bool ready_to_launch_; 124 bool ready_to_launch_;
125 // The crx file is ready for installation if it is not pending for download
126 // or update check with KioskAppManager.
127 bool crx_ready_for_install_;
117 128
118 scoped_refptr<extensions::WebstoreStandaloneInstaller> installer_;
119 KioskOAuthParams auth_params_; 129 KioskOAuthParams auth_params_;
120 130
121 DISALLOW_COPY_AND_ASSIGN(StartupAppLauncher); 131 DISALLOW_COPY_AND_ASSIGN(StartupAppLauncher);
122 }; 132 };
123 133
124 } // namespace chromeos 134 } // namespace chromeos
125 135
126 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_STARTUP_APP_LAUNCHER_H_ 136 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_STARTUP_APP_LAUNCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698