| 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 ProvidingExtensionInfo::Capabilities* capabilities = |
| 327 extension->id(), extensions::api::file_system_provider:: | 322 ProvidingExtensionInfo::Capabilities::Get(extension.get()); |
| 328 OnConfigureRequested::kEventName); | 323 info.capabilities = |
| 329 info.can_add = router->ExtensionHasEventListener( | 324 capabilities ? *capabilities : ProvidingExtensionInfo::Capabilities(); |
| 330 extension->id(), | |
| 331 extensions::api::file_system_provider::OnMountRequested::kEventName); | |
| 332 | |
| 333 result.push_back(info); | 325 result.push_back(info); |
| 334 } | 326 } |
| 335 | 327 |
| 336 return result; | 328 return result; |
| 337 } | 329 } |
| 338 | 330 |
| 339 void Service::OnExtensionUnloaded( | 331 void Service::OnExtensionUnloaded( |
| 340 content::BrowserContext* browser_context, | 332 content::BrowserContext* browser_context, |
| 341 const extensions::Extension* extension, | 333 const extensions::Extension* extension, |
| 342 extensions::UnloadedExtensionInfo::Reason reason) { | 334 extensions::UnloadedExtensionInfo::Reason reason) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 } | 429 } |
| 438 | 430 |
| 439 void Service::OnWatcherListChanged( | 431 void Service::OnWatcherListChanged( |
| 440 const ProvidedFileSystemInfo& file_system_info, | 432 const ProvidedFileSystemInfo& file_system_info, |
| 441 const Watchers& watchers) { | 433 const Watchers& watchers) { |
| 442 registry_->RememberFileSystem(file_system_info, watchers); | 434 registry_->RememberFileSystem(file_system_info, watchers); |
| 443 } | 435 } |
| 444 | 436 |
| 445 } // namespace file_system_provider | 437 } // namespace file_system_provider |
| 446 } // namespace chromeos | 438 } // namespace chromeos |
| OLD | NEW |