Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4350)

Unified Diff: chrome/browser/chromeos/extensions/file_manager/event_router.cc

Issue 566433004: Add notification and observer to copy the file between other users. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/extensions/file_manager/event_router.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..07df00d3deff738509b6fc344260264c7c40ca97 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,14 @@ 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_);
+ }
+}
+
} // namespace file_manager
« no previous file with comments | « chrome/browser/chromeos/extensions/file_manager/event_router.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698