OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/chromeos/file_system_provider/service.h" | 5 #include "chrome/browser/chromeos/file_system_provider/service.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 ProvidedFileSystemInterface* CreateProvidedFileSystem( | 36 ProvidedFileSystemInterface* CreateProvidedFileSystem( |
37 Profile* profile, | 37 Profile* profile, |
38 const ProvidedFileSystemInfo& file_system_info) { | 38 const ProvidedFileSystemInfo& file_system_info) { |
39 DCHECK(profile); | 39 DCHECK(profile); |
40 return new ThrottledFileSystem( | 40 return new ThrottledFileSystem( |
41 make_scoped_ptr(new ProvidedFileSystem(profile, file_system_info))); | 41 make_scoped_ptr(new ProvidedFileSystem(profile, file_system_info))); |
42 } | 42 } |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 ProvidingExtensionInfo::ProvidingExtensionInfo() | 46 ProvidingExtensionInfo::ProvidingExtensionInfo() { |
47 : can_configure(false), can_add(false) { | |
48 } | 47 } |
49 | 48 |
50 ProvidingExtensionInfo::~ProvidingExtensionInfo() { | 49 ProvidingExtensionInfo::~ProvidingExtensionInfo() { |
51 } | 50 } |
52 | 51 |
53 Service::Service(Profile* profile, | 52 Service::Service(Profile* profile, |
54 extensions::ExtensionRegistry* extension_registry) | 53 extensions::ExtensionRegistry* extension_registry) |
55 : profile_(profile), | 54 : profile_(profile), |
56 extension_registry_(extension_registry), | 55 extension_registry_(extension_registry), |
57 file_system_factory_(base::Bind(&CreateProvidedFileSystem)), | 56 file_system_factory_(base::Bind(&CreateProvidedFileSystem)), |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 301 |
303 return file_system_it->second; | 302 return file_system_it->second; |
304 } | 303 } |
305 | 304 |
306 std::vector<ProvidingExtensionInfo> Service::GetProvidingExtensionInfoList() | 305 std::vector<ProvidingExtensionInfo> Service::GetProvidingExtensionInfoList() |
307 const { | 306 const { |
308 extensions::ExtensionRegistry* const registry = | 307 extensions::ExtensionRegistry* const registry = |
309 extensions::ExtensionRegistry::Get(profile_); | 308 extensions::ExtensionRegistry::Get(profile_); |
310 DCHECK(registry); | 309 DCHECK(registry); |
311 | 310 |
312 extensions::EventRouter* const router = | |
313 extensions::EventRouter::Get(profile_); | |
314 DCHECK(router); | |
315 | |
316 std::vector<ProvidingExtensionInfo> result; | 311 std::vector<ProvidingExtensionInfo> result; |
317 for (const auto& extension : registry->enabled_extensions()) { | 312 for (const auto& extension : registry->enabled_extensions()) { |
318 if (!extension->permissions_data()->HasAPIPermission( | 313 if (!extension->permissions_data()->HasAPIPermission( |
319 extensions::APIPermission::kFileSystemProvider)) { | 314 extensions::APIPermission::kFileSystemProvider)) { |
320 continue; | 315 continue; |
321 } | 316 } |
322 | 317 |
323 ProvidingExtensionInfo info; | 318 ProvidingExtensionInfo info; |
324 info.extension_id = extension->id(); | 319 info.extension_id = extension->id(); |
325 info.name = extension->name(); | 320 info.name = extension->name(); |
326 info.can_configure = router->ExtensionHasEventListener( | 321 const extensions::FileSystemProviderCapabilities* capabilities = |
327 extension->id(), extensions::api::file_system_provider:: | 322 extensions::FileSystemProviderCapabilities::Get(extension.get()); |
328 OnConfigureRequested::kEventName); | 323 info.capabilities = capabilities |
329 info.can_add = router->ExtensionHasEventListener( | 324 ? *capabilities |
330 extension->id(), | 325 : extensions::FileSystemProviderCapabilities(); |
331 extensions::api::file_system_provider::OnMountRequested::kEventName); | |
332 | |
333 result.push_back(info); | 326 result.push_back(info); |
334 } | 327 } |
335 | 328 |
336 return result; | 329 return result; |
337 } | 330 } |
338 | 331 |
339 void Service::OnExtensionUnloaded( | 332 void Service::OnExtensionUnloaded( |
340 content::BrowserContext* browser_context, | 333 content::BrowserContext* browser_context, |
341 const extensions::Extension* extension, | 334 const extensions::Extension* extension, |
342 extensions::UnloadedExtensionInfo::Reason reason) { | 335 extensions::UnloadedExtensionInfo::Reason reason) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 } | 430 } |
438 | 431 |
439 void Service::OnWatcherListChanged( | 432 void Service::OnWatcherListChanged( |
440 const ProvidedFileSystemInfo& file_system_info, | 433 const ProvidedFileSystemInfo& file_system_info, |
441 const Watchers& watchers) { | 434 const Watchers& watchers) { |
442 registry_->RememberFileSystem(file_system_info, watchers); | 435 registry_->RememberFileSystem(file_system_info, watchers); |
443 } | 436 } |
444 | 437 |
445 } // namespace file_system_provider | 438 } // namespace file_system_provider |
446 } // namespace chromeos | 439 } // namespace chromeos |
OLD | NEW |