Chromium Code Reviews| Index: chrome/browser/chromeos/extensions/file_manager/event_router.cc |
| diff --git a/chrome/browser/chromeos/extensions/file_manager/event_router.cc b/chrome/browser/chromeos/extensions/file_manager/event_router.cc |
| index 9d8613c329d3b245c347e4bfd86b5169beb19531..97fe727e845c036d2d3d17c51cd70e4dcf595d89 100644 |
| --- a/chrome/browser/chromeos/extensions/file_manager/event_router.cc |
| +++ b/chrome/browser/chromeos/extensions/file_manager/event_router.cc |
| @@ -269,6 +269,22 @@ std::string FileErrorToErrorName(base::File::Error error_code) { |
| } |
| } |
| +void GrantAccessForAddedProfileToRunningInstance(Profile* added_profile, |
| + Profile* running_profile) { |
| + extensions::ProcessManager* const process_manager = |
| + extensions::ExtensionSystem::Get(running_profile)->process_manager(); |
| + if (!process_manager) |
| + return; |
| + |
| + extensions::ExtensionHost* const extension_host = |
| + process_manager->GetBackgroundHostForExtension(kFileManagerAppId); |
| + if (!extension_host || !extension_host->render_process_host()) |
| + return; |
| + |
| + const int id = extension_host->render_process_host()->GetID(); |
| + file_manager::util::SetupProfileFileAccessPermissions(id, added_profile); |
| +} |
| + |
| // Checks if we should send a progress event or not according to the |
| // |last_time| of sending an event. If |always| is true, the function always |
| // returns true. If the function returns true, the function also updates |
| @@ -464,6 +480,10 @@ void EventRouter::ObserveEvents() { |
| pref_change_registrar_->Add(prefs::kDisableDriveHostedFiles, callback); |
| pref_change_registrar_->Add(prefs::kDisableDrive, callback); |
| pref_change_registrar_->Add(prefs::kUse24HourClock, callback); |
| + |
| + notification_registrar_.Add(this, |
| + chrome::NOTIFICATION_PROFILE_ADDED, |
| + content::NotificationService::AllSources()); |
| } |
| // File watch setup routines. |
| @@ -936,4 +956,18 @@ void EventRouter::OnFormatCompleted(const std::string& device_path, |
| // Do nothing. |
| } |
| +void EventRouter::Observe(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) { |
| + if (type == chrome::NOTIFICATION_PROFILE_ADDED) { |
| + Profile* const added_profile = content::Source<Profile>(source).ptr(); |
| + if (!added_profile->IsOffTheRecord()) |
| + GrantAccessForAddedProfileToRunningInstance(added_profile, profile_); |
| + |
| + BroadcastEvent(profile_, |
| + file_browser_private::OnProfileAdded::kEventName, |
|
fukino
2014/09/11 05:00:16
I think there is no listener for onProfileAdded ev
iseki
2014/09/11 05:15:52
It can be removed.
|
| + file_browser_private::OnProfileAdded::Create()); |
| + } |
| +} |
| + |
| } // namespace file_manager |