Index: chrome/browser/extensions/api/file_system/file_system_api.cc |
diff --git a/chrome/browser/extensions/api/file_system/file_system_api.cc b/chrome/browser/extensions/api/file_system/file_system_api.cc |
index fbf6a83495164bf59b271ee14bbfcfe77ddfe004..47ee437c29e18265ba10a9733a890a3e4f9dc4a8 100644 |
--- a/chrome/browser/extensions/api/file_system/file_system_api.cc |
+++ b/chrome/browser/extensions/api/file_system/file_system_api.cc |
@@ -70,8 +70,6 @@ |
#include "chrome/browser/extensions/api/file_system/request_file_system_notification.h" |
#include "chrome/browser/ui/simple_message_box.h" |
#include "components/user_manager/user_manager.h" |
-#include "extensions/browser/event_router.h" |
-#include "extensions/browser/extension_registry.h" |
#include "extensions/common/constants.h" |
#include "extensions/common/manifest_handlers/kiosk_mode_info.h" |
#include "url/url_constants.h" |
@@ -249,25 +247,6 @@ |
registry->GetCurrentAppWindowForApp(app_id); |
return app_window ? app_window->web_contents() : nullptr; |
} |
- |
-// Fills a list of volumes mounted in the system. |
-void FillVolumeList( |
- Profile* profile, |
- std::vector<linked_ptr<extensions::api::file_system::Volume>>* result) { |
- using file_manager::VolumeManager; |
- VolumeManager* const volume_manager = VolumeManager::Get(profile); |
- DCHECK(volume_manager); |
- |
- using extensions::api::file_system::Volume; |
- const auto& volume_list = volume_manager->GetVolumeList(); |
- // Convert volume_list to result_volume_list. |
- for (const auto& volume : volume_list) { |
- const linked_ptr<Volume> result_volume(new Volume); |
- result_volume->volume_id = volume->volume_id(); |
- result_volume->writable = !volume->is_read_only(); |
- result->push_back(result_volume); |
- } |
-} |
#endif |
} // namespace |
@@ -307,33 +286,6 @@ |
} |
#if defined(OS_CHROMEOS) |
-void DispatchVolumeListChangeEvent(Profile* profile) { |
- DCHECK(profile); |
- EventRouter* const event_router = EventRouter::Get(profile); |
- if (!event_router) // Possible on shutdown. |
- return; |
- |
- extensions::ExtensionRegistry* const registry = |
- extensions::ExtensionRegistry::Get(profile); |
- if (!registry) // Possible on shutdown. |
- return; |
- |
- ConsentProvider consent_provider( |
- new ConsentProviderDelegate(profile, nullptr)); |
- extensions::api::file_system::VolumeListChangedEvent event_args; |
- FillVolumeList(profile, &event_args.volumes); |
- for (const auto& extension : registry->enabled_extensions()) { |
- if (!consent_provider.IsGrantable(*extension.get())) |
- continue; |
- event_router->DispatchEventToExtension( |
- extension->id(), |
- make_scoped_ptr(new Event( |
- extensions::api::file_system::OnVolumeListChanged::kEventName, |
- extensions::api::file_system::OnVolumeListChanged::Create( |
- event_args)))); |
- } |
-} |
- |
ConsentProvider::ConsentProvider(DelegateInterface* delegate) |
: delegate_(delegate) { |
DCHECK(delegate_); |
@@ -409,6 +361,7 @@ |
content::RenderViewHost* host) |
: profile_(profile), host_(host) { |
DCHECK(profile_); |
+ DCHECK(host_); |
} |
ConsentProviderDelegate::~ConsentProviderDelegate() { |
@@ -425,7 +378,6 @@ |
const base::WeakPtr<file_manager::Volume>& volume, |
bool writable, |
const file_system_api::ConsentProvider::ShowDialogCallback& callback) { |
- DCHECK(host_); |
content::WebContents* const foreground_contents = |
GetWebContentsForRenderViewHost(profile_, host_); |
// If there is no web contents handle, then the method is most probably |
@@ -1448,9 +1400,22 @@ |
if (!consent_provider.IsGrantable(*extension())) |
return RespondNow(Error(kNotSupportedOnNonKioskSessionError)); |
+ |
+ using file_manager::VolumeManager; |
+ VolumeManager* const volume_manager = |
+ VolumeManager::Get(chrome_details_.GetProfile()); |
+ DCHECK(volume_manager); |
+ |
using extensions::api::file_system::Volume; |
+ const auto& volume_list = volume_manager->GetVolumeList(); |
std::vector<linked_ptr<Volume>> result_volume_list; |
- FillVolumeList(chrome_details_.GetProfile(), &result_volume_list); |
+ // Convert volume_list to result_volume_list. |
+ for (const auto& volume : volume_list) { |
+ const linked_ptr<Volume> result_volume(new Volume); |
+ result_volume->volume_id = volume->volume_id(); |
+ result_volume->writable = !volume->is_read_only(); |
+ result_volume_list.push_back(result_volume); |
+ } |
return RespondNow( |
ArgumentList(extensions::api::file_system::GetVolumeList::Results::Create( |