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

Side by Side Diff: chrome/browser/chromeos/first_run/drive_first_run_controller.h

Issue 71013003: Add browser tests for enabling Google Drive offline mode on first run. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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 #ifndef CHROME_BROWSER_CHROMEOS_FIRST_RUN_DRIVE_FIRST_RUN_CONTROLLER_H_ 4 #ifndef CHROME_BROWSER_CHROMEOS_FIRST_RUN_DRIVE_FIRST_RUN_CONTROLLER_H_
5 #define CHROME_BROWSER_CHROMEOS_FIRST_RUN_DRIVE_FIRST_RUN_CONTROLLER_H_ 5 #define CHROME_BROWSER_CHROMEOS_FIRST_RUN_DRIVE_FIRST_RUN_CONTROLLER_H_
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/observer_list.h"
8 #include "base/timer/timer.h" 9 #include "base/timer/timer.h"
9 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
10 11
11 namespace chromeos { 12 namespace chromeos {
12 13
13 class DriveWebContentsManager; 14 class DriveWebContentsManager;
14 15
15 // This class is responsible for kicking off the Google Drive offline 16 // This class is responsible for kicking off the Google Drive offline
16 // initialization process. There is an initial delay to avoid contention when 17 // initialization process. There is an initial delay to avoid contention when
17 // the session starts. DriveFirstRunController will manage its own lifetime and 18 // the session starts. DriveFirstRunController will manage its own lifetime and
18 // destroy itself when the initialization succeeds or fails. 19 // destroy itself when the initialization succeeds or fails.
19 class DriveFirstRunController { 20 class DriveFirstRunController {
20 public: 21 public:
22 class Observer {
23 public:
24 // Called when enabling offline mode times out. OnCompletion will be called
25 // immediately afterwards.
26 virtual void OnTimedOut() = 0;
27
28 // Called when the first run flow finishes, informing the observer of
29 // success or failure.
30 virtual void OnCompletion(bool success) = 0;
31
32 protected:
33 virtual ~Observer() {}
34 };
35
21 DriveFirstRunController(); 36 DriveFirstRunController();
22 ~DriveFirstRunController(); 37 ~DriveFirstRunController();
23 38
24 // Starts the process to enable offline mode for the user's Drive account. 39 // Starts the process to enable offline mode for the user's Drive account.
25 void EnableOfflineMode(); 40 void EnableOfflineMode();
26 41
42 // Manages observers of the first run flow.
43 void AddObserver(Observer* observer);
44 void RemoveObserver(Observer* observer);
45
46 // Set delay times for testing purposes.
47 void SetDelaysForTest(int initial_delay_secs, int timeout_secs);
48
49 // Set the app id and endpoint url for testing purposes.
50 void SetAppInfoForTest(const std::string& app_id,
51 const std::string& endpoint_url);
52
27 private: 53 private:
28 // Used as a callback to indicate whether the offline initialization 54 // Used as a callback to indicate whether the offline initialization
29 // succeeds or fails. 55 // succeeds or fails.
30 void OnOfflineInit(bool success); 56 void OnOfflineInit(bool success);
31 57
32 // Called when timed out waiting for offline initialization to complete. 58 // Called when timed out waiting for offline initialization to complete.
33 void OnWebContentsTimedOut(); 59 void OnWebContentsTimedOut();
34 60
35 // Cleans up internal state and schedules self for deletion. 61 // Cleans up internal state and schedules self for deletion.
36 void CleanUp(); 62 void CleanUp();
37 63
38 Profile* profile_; 64 Profile* profile_;
39 scoped_ptr<DriveWebContentsManager> web_contents_manager_; 65 scoped_ptr<DriveWebContentsManager> web_contents_manager_;
40 base::OneShotTimer<DriveFirstRunController> web_contents_timer_; 66 base::OneShotTimer<DriveFirstRunController> web_contents_timer_;
41 base::OneShotTimer<DriveFirstRunController> initial_delay_timer_; 67 base::OneShotTimer<DriveFirstRunController> initial_delay_timer_;
42 bool started_; 68 bool started_;
69 ObserverList<Observer> observer_list_;
70
71 int initial_delay_secs_;
72 int web_contents_timeout_secs_;
73 std::string drive_offline_endpoint_url_;
74 std::string drive_hosted_app_id_;
43 75
44 DISALLOW_COPY_AND_ASSIGN(DriveFirstRunController); 76 DISALLOW_COPY_AND_ASSIGN(DriveFirstRunController);
45 }; 77 };
46 78
47 } // namespace chromeos 79 } // namespace chromeos
48 80
49 #endif // CHROME_BROWSER_CHROMEOS_FIRST_RUN_DRIVE_FIRST_RUN_CONTROLLER_H_ 81 #endif // CHROME_BROWSER_CHROMEOS_FIRST_RUN_DRIVE_FIRST_RUN_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698