| 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/extensions/file_manager/event_router.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/prefs/pref_change_registrar.h" | 10 #include "base/prefs/pref_change_registrar.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "chromeos/dbus/dbus_thread_manager.h" | 37 #include "chromeos/dbus/dbus_thread_manager.h" |
| 38 #include "chromeos/login/login_state.h" | 38 #include "chromeos/login/login_state.h" |
| 39 #include "chromeos/network/network_handler.h" | 39 #include "chromeos/network/network_handler.h" |
| 40 #include "chromeos/network/network_state_handler.h" | 40 #include "chromeos/network/network_state_handler.h" |
| 41 #include "content/public/browser/browser_thread.h" | 41 #include "content/public/browser/browser_thread.h" |
| 42 #include "content/public/browser/render_process_host.h" | 42 #include "content/public/browser/render_process_host.h" |
| 43 #include "content/public/browser/storage_partition.h" | 43 #include "content/public/browser/storage_partition.h" |
| 44 #include "extensions/browser/event_router.h" | 44 #include "extensions/browser/event_router.h" |
| 45 #include "extensions/browser/extension_host.h" | 45 #include "extensions/browser/extension_host.h" |
| 46 #include "extensions/browser/extension_prefs.h" | 46 #include "extensions/browser/extension_prefs.h" |
| 47 #include "extensions/browser/extension_system.h" | |
| 48 #include "storage/common/fileapi/file_system_types.h" | 47 #include "storage/common/fileapi/file_system_types.h" |
| 49 #include "storage/common/fileapi/file_system_util.h" | 48 #include "storage/common/fileapi/file_system_util.h" |
| 50 | 49 |
| 51 using chromeos::disks::DiskMountManager; | 50 using chromeos::disks::DiskMountManager; |
| 52 using chromeos::NetworkHandler; | 51 using chromeos::NetworkHandler; |
| 53 using content::BrowserThread; | 52 using content::BrowserThread; |
| 54 using drive::DriveIntegrationService; | 53 using drive::DriveIntegrationService; |
| 55 using drive::DriveIntegrationServiceFactory; | 54 using drive::DriveIntegrationServiceFactory; |
| 56 using file_manager::util::EntryDefinition; | 55 using file_manager::util::EntryDefinition; |
| 57 using file_manager::util::FileDefinition; | 56 using file_manager::util::FileDefinition; |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 return "QuotaExceededError"; | 263 return "QuotaExceededError"; |
| 265 case base::File::FILE_ERROR_INVALID_URL: | 264 case base::File::FILE_ERROR_INVALID_URL: |
| 266 return "EncodingError"; | 265 return "EncodingError"; |
| 267 default: | 266 default: |
| 268 return "InvalidModificationError"; | 267 return "InvalidModificationError"; |
| 269 } | 268 } |
| 270 } | 269 } |
| 271 | 270 |
| 272 void GrantAccessForAddedProfileToRunningInstance(Profile* added_profile, | 271 void GrantAccessForAddedProfileToRunningInstance(Profile* added_profile, |
| 273 Profile* running_profile) { | 272 Profile* running_profile) { |
| 274 extensions::ProcessManager* const process_manager = | |
| 275 extensions::ExtensionSystem::Get(running_profile)->process_manager(); | |
| 276 if (!process_manager) | |
| 277 return; | |
| 278 | |
| 279 extensions::ExtensionHost* const extension_host = | 273 extensions::ExtensionHost* const extension_host = |
| 280 process_manager->GetBackgroundHostForExtension(kFileManagerAppId); | 274 extensions::ProcessManager::Get(running_profile) |
| 275 ->GetBackgroundHostForExtension(kFileManagerAppId); |
| 281 if (!extension_host || !extension_host->render_process_host()) | 276 if (!extension_host || !extension_host->render_process_host()) |
| 282 return; | 277 return; |
| 283 | 278 |
| 284 const int id = extension_host->render_process_host()->GetID(); | 279 const int id = extension_host->render_process_host()->GetID(); |
| 285 file_manager::util::SetupProfileFileAccessPermissions(id, added_profile); | 280 file_manager::util::SetupProfileFileAccessPermissions(id, added_profile); |
| 286 } | 281 } |
| 287 | 282 |
| 288 // Checks if we should send a progress event or not according to the | 283 // Checks if we should send a progress event or not according to the |
| 289 // |last_time| of sending an event. If |always| is true, the function always | 284 // |last_time| of sending an event. If |always| is true, the function always |
| 290 // returns true. If the function returns true, the function also updates | 285 // returns true. If the function returns true, the function also updates |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 const content::NotificationSource& source, | 956 const content::NotificationSource& source, |
| 962 const content::NotificationDetails& details) { | 957 const content::NotificationDetails& details) { |
| 963 if (type == chrome::NOTIFICATION_PROFILE_ADDED) { | 958 if (type == chrome::NOTIFICATION_PROFILE_ADDED) { |
| 964 Profile* const added_profile = content::Source<Profile>(source).ptr(); | 959 Profile* const added_profile = content::Source<Profile>(source).ptr(); |
| 965 if (!added_profile->IsOffTheRecord()) | 960 if (!added_profile->IsOffTheRecord()) |
| 966 GrantAccessForAddedProfileToRunningInstance(added_profile, profile_); | 961 GrantAccessForAddedProfileToRunningInstance(added_profile, profile_); |
| 967 } | 962 } |
| 968 } | 963 } |
| 969 | 964 |
| 970 } // namespace file_manager | 965 } // namespace file_manager |
| OLD | NEW |