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

Side by Side Diff: chrome/browser/chromeos/drive/drive_integration_service.h

Issue 306023012: Enable Drive integration service in incognito windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments. Created 6 years, 6 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 (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"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "chrome/browser/chromeos/drive/file_errors.h" 13 #include "chrome/browser/chromeos/drive/file_errors.h"
14 #include "chrome/browser/chromeos/drive/file_system_util.h" 14 #include "chrome/browser/chromeos/drive/file_system_util.h"
15 #include "chrome/browser/chromeos/drive/job_scheduler.h" 15 #include "chrome/browser/chromeos/drive/job_scheduler.h"
16 #include "chrome/browser/drive/drive_notification_observer.h" 16 #include "chrome/browser/drive/drive_notification_observer.h"
17 #include "components/keyed_service/content/browser_context_keyed_service_factory .h" 17 #include "components/keyed_service/content/browser_context_keyed_service_factory .h"
18 #include "components/keyed_service/core/keyed_service.h" 18 #include "components/keyed_service/core/keyed_service.h"
19 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h"
19 21
20 namespace base { 22 namespace base {
21 class FilePath; 23 class FilePath;
22 class SequencedTaskRunner; 24 class SequencedTaskRunner;
23 } 25 }
24 26
25 namespace drive { 27 namespace drive {
26 28
27 class DebugInfoCollector; 29 class DebugInfoCollector;
28 class DownloadHandler; 30 class DownloadHandler;
(...skipping 27 matching lines...) Expand all
56 58
57 // DriveIntegrationService is used to integrate Drive to Chrome. This class 59 // DriveIntegrationService is used to integrate Drive to Chrome. This class
58 // exposes the file system representation built on top of Drive and some 60 // exposes the file system representation built on top of Drive and some
59 // other Drive related objects to the file manager, and some other sub 61 // other Drive related objects to the file manager, and some other sub
60 // systems. 62 // systems.
61 // 63 //
62 // The class is essentially a container that manages lifetime of the objects 64 // The class is essentially a container that manages lifetime of the objects
63 // that are used to integrate Drive to Chrome. The object of this class is 65 // that are used to integrate Drive to Chrome. The object of this class is
64 // created per-profile. 66 // created per-profile.
65 class DriveIntegrationService : public KeyedService, 67 class DriveIntegrationService : public KeyedService,
66 public DriveNotificationObserver { 68 public DriveNotificationObserver,
69 public content::NotificationObserver {
67 public: 70 public:
68 class PreferenceWatcher; 71 class PreferenceWatcher;
69 72
70 // test_drive_service, test_mount_point_name, test_cache_root and 73 // test_drive_service, test_mount_point_name, test_cache_root and
71 // test_file_system are used by tests to inject customized instances. 74 // test_file_system are used by tests to inject customized instances.
72 // Pass NULL or the empty value when not interested. 75 // Pass NULL or the empty value when not interested.
73 // |preference_watcher| observes the drive enable preference, and sets the 76 // |preference_watcher| observes the drive enable preference, and sets the
74 // 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
75 // the DriveIntegrationService. 78 // the DriveIntegrationService.
76 DriveIntegrationService( 79 DriveIntegrationService(
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 void Initialize(); 145 void Initialize();
143 146
144 // Called when metadata initialization is done. Continues initialization if 147 // Called when metadata initialization is done. Continues initialization if
145 // the metadata initialization is successful. 148 // the metadata initialization is successful.
146 void InitializeAfterMetadataInitialized(FileError error); 149 void InitializeAfterMetadataInitialized(FileError error);
147 150
148 // Change the download directory to the local "Downloads" if the download 151 // Change the download directory to the local "Downloads" if the download
149 // 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.
150 void AvoidDriveAsDownloadDirecotryPreference(); 153 void AvoidDriveAsDownloadDirecotryPreference();
151 154
155 // content::NotificationObserver overrides.
156 virtual void Observe(int type,
157 const content::NotificationSource& source,
158 const content::NotificationDetails& details) OVERRIDE;
159
152 friend class DriveIntegrationServiceFactory; 160 friend class DriveIntegrationServiceFactory;
153 161
154 Profile* profile_; 162 Profile* profile_;
155 State state_; 163 State state_;
156 bool enabled_; 164 bool enabled_;
157 // 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.
158 std::string mount_point_name_; 166 std::string mount_point_name_;
159 167
160 base::FilePath cache_root_directory_; 168 base::FilePath cache_root_directory_;
161 scoped_ptr<EventLogger> logger_; 169 scoped_ptr<EventLogger> logger_;
162 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 170 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
163 scoped_ptr<internal::ResourceMetadataStorage, 171 scoped_ptr<internal::ResourceMetadataStorage,
164 util::DestroyHelper> metadata_storage_; 172 util::DestroyHelper> metadata_storage_;
165 scoped_ptr<internal::FileCache, util::DestroyHelper> cache_; 173 scoped_ptr<internal::FileCache, util::DestroyHelper> cache_;
166 scoped_ptr<DriveServiceInterface> drive_service_; 174 scoped_ptr<DriveServiceInterface> drive_service_;
167 scoped_ptr<JobScheduler> scheduler_; 175 scoped_ptr<JobScheduler> scheduler_;
168 scoped_ptr<DriveAppRegistry> drive_app_registry_; 176 scoped_ptr<DriveAppRegistry> drive_app_registry_;
169 scoped_ptr<internal::ResourceMetadata, 177 scoped_ptr<internal::ResourceMetadata,
170 util::DestroyHelper> resource_metadata_; 178 util::DestroyHelper> resource_metadata_;
171 scoped_ptr<FileSystemInterface> file_system_; 179 scoped_ptr<FileSystemInterface> file_system_;
172 scoped_ptr<DownloadHandler> download_handler_; 180 scoped_ptr<DownloadHandler> download_handler_;
173 scoped_ptr<DebugInfoCollector> debug_info_collector_; 181 scoped_ptr<DebugInfoCollector> debug_info_collector_;
174 182
175 ObserverList<DriveIntegrationServiceObserver> observers_; 183 ObserverList<DriveIntegrationServiceObserver> observers_;
176 scoped_ptr<PreferenceWatcher> preference_watcher_; 184 scoped_ptr<PreferenceWatcher> preference_watcher_;
185 scoped_ptr<content::NotificationRegistrar> profile_notification_registrar_;
177 186
178 // Note: This should remain the last member so it'll be destroyed and 187 // Note: This should remain the last member so it'll be destroyed and
179 // invalidate its weak pointers before any other members are destroyed. 188 // invalidate its weak pointers before any other members are destroyed.
180 base::WeakPtrFactory<DriveIntegrationService> weak_ptr_factory_; 189 base::WeakPtrFactory<DriveIntegrationService> weak_ptr_factory_;
181 DISALLOW_COPY_AND_ASSIGN(DriveIntegrationService); 190 DISALLOW_COPY_AND_ASSIGN(DriveIntegrationService);
182 }; 191 };
183 192
184 // Singleton that owns all instances of DriveIntegrationService and 193 // Singleton that owns all instances of DriveIntegrationService and
185 // associates them with Profiles. 194 // associates them with Profiles.
186 class DriveIntegrationServiceFactory 195 class DriveIntegrationServiceFactory
(...skipping 29 matching lines...) Expand all
216 225
217 // Returns the DriveIntegrationServiceFactory instance. 226 // Returns the DriveIntegrationServiceFactory instance.
218 static DriveIntegrationServiceFactory* GetInstance(); 227 static DriveIntegrationServiceFactory* GetInstance();
219 228
220 private: 229 private:
221 friend struct DefaultSingletonTraits<DriveIntegrationServiceFactory>; 230 friend struct DefaultSingletonTraits<DriveIntegrationServiceFactory>;
222 231
223 DriveIntegrationServiceFactory(); 232 DriveIntegrationServiceFactory();
224 virtual ~DriveIntegrationServiceFactory(); 233 virtual ~DriveIntegrationServiceFactory();
225 234
226 // BrowserContextKeyedServiceFactory: 235 // BrowserContextKeyedServiceFactory overrides.
236 virtual content::BrowserContext* GetBrowserContextToUse(
237 content::BrowserContext* context) const OVERRIDE;
227 virtual KeyedService* BuildServiceInstanceFor( 238 virtual KeyedService* BuildServiceInstanceFor(
228 content::BrowserContext* context) const OVERRIDE; 239 content::BrowserContext* context) const OVERRIDE;
229 240
230 // This is static so it can be set without instantiating the factory. This 241 // This is static so it can be set without instantiating the factory. This
231 // allows factory creation to be delayed until it normally happens (on profile 242 // allows factory creation to be delayed until it normally happens (on profile
232 // creation) rather than when tests are set up. DriveIntegrationServiceFactory 243 // creation) rather than when tests are set up. DriveIntegrationServiceFactory
233 // transitively depends on ExtensionSystemFactory which crashes if created too 244 // transitively depends on ExtensionSystemFactory which crashes if created too
234 // soon (i.e. before the BrowserProcess exists). 245 // soon (i.e. before the BrowserProcess exists).
235 static FactoryCallback* factory_for_test_; 246 static FactoryCallback* factory_for_test_;
236 }; 247 };
237 248
238 } // namespace drive 249 } // namespace drive
239 250
240 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_INTEGRATION_SERVICE_H_ 251 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_INTEGRATION_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/download_handler.cc ('k') | chrome/browser/chromeos/drive/drive_integration_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698