OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_DRIVE_DRIVE_INTEGRATION_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_INTEGRATION_SERVICE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_INTEGRATION_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_INTEGRATION_SERVICE_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // |preference_watcher| observes the drive enable preference, and sets the | 76 // |preference_watcher| observes the drive enable preference, and sets the |
77 // enable state when changed. It can be NULL. The ownership is taken by | 77 // enable state when changed. It can be NULL. The ownership is taken by |
78 // the DriveIntegrationService. | 78 // the DriveIntegrationService. |
79 DriveIntegrationService( | 79 DriveIntegrationService( |
80 Profile* profile, | 80 Profile* profile, |
81 PreferenceWatcher* preference_watcher, | 81 PreferenceWatcher* preference_watcher, |
82 DriveServiceInterface* test_drive_service, | 82 DriveServiceInterface* test_drive_service, |
83 const std::string& test_mount_point_name, | 83 const std::string& test_mount_point_name, |
84 const base::FilePath& test_cache_root, | 84 const base::FilePath& test_cache_root, |
85 FileSystemInterface* test_file_system); | 85 FileSystemInterface* test_file_system); |
86 virtual ~DriveIntegrationService(); | 86 ~DriveIntegrationService() override; |
87 | 87 |
88 // KeyedService override: | 88 // KeyedService override: |
89 virtual void Shutdown() override; | 89 void Shutdown() override; |
90 | 90 |
91 void SetEnabled(bool enabled); | 91 void SetEnabled(bool enabled); |
92 bool is_enabled() const { return enabled_; } | 92 bool is_enabled() const { return enabled_; } |
93 | 93 |
94 bool IsMounted() const; | 94 bool IsMounted() const; |
95 | 95 |
96 // Adds and removes the observer. | 96 // Adds and removes the observer. |
97 void AddObserver(DriveIntegrationServiceObserver* observer); | 97 void AddObserver(DriveIntegrationServiceObserver* observer); |
98 void RemoveObserver(DriveIntegrationServiceObserver* observer); | 98 void RemoveObserver(DriveIntegrationServiceObserver* observer); |
99 | 99 |
100 // DriveNotificationObserver implementation. | 100 // DriveNotificationObserver implementation. |
101 virtual void OnNotificationReceived() override; | 101 void OnNotificationReceived() override; |
102 virtual void OnPushNotificationEnabled(bool enabled) override; | 102 void OnPushNotificationEnabled(bool enabled) override; |
103 | 103 |
104 EventLogger* event_logger() { return logger_.get(); } | 104 EventLogger* event_logger() { return logger_.get(); } |
105 DriveServiceInterface* drive_service() { return drive_service_.get(); } | 105 DriveServiceInterface* drive_service() { return drive_service_.get(); } |
106 DebugInfoCollector* debug_info_collector() { | 106 DebugInfoCollector* debug_info_collector() { |
107 return debug_info_collector_.get(); | 107 return debug_info_collector_.get(); |
108 } | 108 } |
109 FileSystemInterface* file_system() { return file_system_.get(); } | 109 FileSystemInterface* file_system() { return file_system_.get(); } |
110 DownloadHandler* download_handler() { return download_handler_.get(); } | 110 DownloadHandler* download_handler() { return download_handler_.get(); } |
111 DriveAppRegistry* drive_app_registry() { return drive_app_registry_.get(); } | 111 DriveAppRegistry* drive_app_registry() { return drive_app_registry_.get(); } |
112 JobListInterface* job_list() { return scheduler_.get(); } | 112 JobListInterface* job_list() { return scheduler_.get(); } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 // Called when metadata initialization is done. Continues initialization if | 147 // Called when metadata initialization is done. Continues initialization if |
148 // the metadata initialization is successful. | 148 // the metadata initialization is successful. |
149 void InitializeAfterMetadataInitialized(FileError error); | 149 void InitializeAfterMetadataInitialized(FileError error); |
150 | 150 |
151 // Change the download directory to the local "Downloads" if the download | 151 // Change the download directory to the local "Downloads" if the download |
152 // destination is set under Drive. This must be called when disabling Drive. | 152 // destination is set under Drive. This must be called when disabling Drive. |
153 void AvoidDriveAsDownloadDirecotryPreference(); | 153 void AvoidDriveAsDownloadDirecotryPreference(); |
154 | 154 |
155 // content::NotificationObserver overrides. | 155 // content::NotificationObserver overrides. |
156 virtual void Observe(int type, | 156 void Observe(int type, |
157 const content::NotificationSource& source, | 157 const content::NotificationSource& source, |
158 const content::NotificationDetails& details) override; | 158 const content::NotificationDetails& details) override; |
159 | 159 |
160 friend class DriveIntegrationServiceFactory; | 160 friend class DriveIntegrationServiceFactory; |
161 | 161 |
162 Profile* profile_; | 162 Profile* profile_; |
163 State state_; | 163 State state_; |
164 bool enabled_; | 164 bool enabled_; |
165 // Custom mount point name that can be injected for testing in constructor. | 165 // Custom mount point name that can be injected for testing in constructor. |
166 std::string mount_point_name_; | 166 std::string mount_point_name_; |
167 | 167 |
168 base::FilePath cache_root_directory_; | 168 base::FilePath cache_root_directory_; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // |profile|, if it is not yet created it will return NULL. | 215 // |profile|, if it is not yet created it will return NULL. |
216 static DriveIntegrationService* FindForProfile(Profile* profile); | 216 static DriveIntegrationService* FindForProfile(Profile* profile); |
217 | 217 |
218 // Returns the DriveIntegrationServiceFactory instance. | 218 // Returns the DriveIntegrationServiceFactory instance. |
219 static DriveIntegrationServiceFactory* GetInstance(); | 219 static DriveIntegrationServiceFactory* GetInstance(); |
220 | 220 |
221 private: | 221 private: |
222 friend struct DefaultSingletonTraits<DriveIntegrationServiceFactory>; | 222 friend struct DefaultSingletonTraits<DriveIntegrationServiceFactory>; |
223 | 223 |
224 DriveIntegrationServiceFactory(); | 224 DriveIntegrationServiceFactory(); |
225 virtual ~DriveIntegrationServiceFactory(); | 225 ~DriveIntegrationServiceFactory() override; |
226 | 226 |
227 // BrowserContextKeyedServiceFactory overrides. | 227 // BrowserContextKeyedServiceFactory overrides. |
228 virtual content::BrowserContext* GetBrowserContextToUse( | 228 content::BrowserContext* GetBrowserContextToUse( |
229 content::BrowserContext* context) const override; | 229 content::BrowserContext* context) const override; |
230 virtual KeyedService* BuildServiceInstanceFor( | 230 KeyedService* BuildServiceInstanceFor( |
231 content::BrowserContext* context) const override; | 231 content::BrowserContext* context) const override; |
232 | 232 |
233 // This is static so it can be set without instantiating the factory. This | 233 // This is static so it can be set without instantiating the factory. This |
234 // allows factory creation to be delayed until it normally happens (on profile | 234 // allows factory creation to be delayed until it normally happens (on profile |
235 // creation) rather than when tests are set up. DriveIntegrationServiceFactory | 235 // creation) rather than when tests are set up. DriveIntegrationServiceFactory |
236 // transitively depends on ExtensionSystemFactory which crashes if created too | 236 // transitively depends on ExtensionSystemFactory which crashes if created too |
237 // soon (i.e. before the BrowserProcess exists). | 237 // soon (i.e. before the BrowserProcess exists). |
238 static FactoryCallback* factory_for_test_; | 238 static FactoryCallback* factory_for_test_; |
239 }; | 239 }; |
240 | 240 |
241 } // namespace drive | 241 } // namespace drive |
242 | 242 |
243 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_INTEGRATION_SERVICE_H_ | 243 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_INTEGRATION_SERVICE_H_ |
OLD | NEW |