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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/event_router.cc

Issue 883163005: Do not broadcast fileManagerPrivate.onDirectoryChanged event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 148
149 // Sends an event named |event_name| with arguments |event_args| to extensions. 149 // Sends an event named |event_name| with arguments |event_args| to extensions.
150 void BroadcastEvent(Profile* profile, 150 void BroadcastEvent(Profile* profile,
151 const std::string& event_name, 151 const std::string& event_name,
152 scoped_ptr<base::ListValue> event_args) { 152 scoped_ptr<base::ListValue> event_args) {
153 extensions::EventRouter::Get(profile)->BroadcastEvent( 153 extensions::EventRouter::Get(profile)->BroadcastEvent(
154 make_scoped_ptr(new extensions::Event(event_name, event_args.Pass()))); 154 make_scoped_ptr(new extensions::Event(event_name, event_args.Pass())));
155 } 155 }
156 156
157 // Sends an event named |event_name| with arguments |event_args| to an extension
158 // of |extention_id|.
159 void DispatchEventToExtension(Profile* profile,
160 const std::string& extension_id,
161 const std::string& event_name,
162 scoped_ptr<base::ListValue> event_args) {
163 extensions::EventRouter::Get(profile)->DispatchEventToExtension(
164 extension_id,
165 make_scoped_ptr(new extensions::Event(event_name, event_args.Pass())));
166 }
167
157 file_manager_private::MountCompletedStatus 168 file_manager_private::MountCompletedStatus
158 MountErrorToMountCompletedStatus(chromeos::MountError error) { 169 MountErrorToMountCompletedStatus(chromeos::MountError error) {
159 switch (error) { 170 switch (error) {
160 case chromeos::MOUNT_ERROR_NONE: 171 case chromeos::MOUNT_ERROR_NONE:
161 return file_manager_private::MOUNT_COMPLETED_STATUS_SUCCESS; 172 return file_manager_private::MOUNT_COMPLETED_STATUS_SUCCESS;
162 case chromeos::MOUNT_ERROR_UNKNOWN: 173 case chromeos::MOUNT_ERROR_UNKNOWN:
163 return file_manager_private::MOUNT_COMPLETED_STATUS_ERROR_UNKNOWN; 174 return file_manager_private::MOUNT_COMPLETED_STATUS_ERROR_UNKNOWN;
164 case chromeos::MOUNT_ERROR_INTERNAL: 175 case chromeos::MOUNT_ERROR_INTERNAL:
165 return file_manager_private::MOUNT_COMPLETED_STATUS_ERROR_INTERNAL; 176 return file_manager_private::MOUNT_COMPLETED_STATUS_ERROR_INTERNAL;
166 case chromeos::MOUNT_ERROR_INVALID_ARGUMENT: 177 case chromeos::MOUNT_ERROR_INVALID_ARGUMENT:
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 944
934 event.entry.additional_properties.SetString( 945 event.entry.additional_properties.SetString(
935 "fileSystemName", entry_definition.file_system_name); 946 "fileSystemName", entry_definition.file_system_name);
936 event.entry.additional_properties.SetString( 947 event.entry.additional_properties.SetString(
937 "fileSystemRoot", entry_definition.file_system_root_url); 948 "fileSystemRoot", entry_definition.file_system_root_url);
938 event.entry.additional_properties.SetString( 949 event.entry.additional_properties.SetString(
939 "fileFullPath", "/" + entry_definition.full_path.value()); 950 "fileFullPath", "/" + entry_definition.full_path.value());
940 event.entry.additional_properties.SetBoolean("fileIsDirectory", 951 event.entry.additional_properties.SetBoolean("fileIsDirectory",
941 entry_definition.is_directory); 952 entry_definition.is_directory);
942 953
943 BroadcastEvent(profile_, 954 DispatchEventToExtension(
944 file_manager_private::OnDirectoryChanged::kEventName, 955 profile_,
945 file_manager_private::OnDirectoryChanged::Create(event)); 956 *extension_id,
957 file_manager_private::OnDirectoryChanged::kEventName,
958 file_manager_private::OnDirectoryChanged::Create(event));
946 } 959 }
947 960
948 void EventRouter::OnDiskAdded( 961 void EventRouter::OnDiskAdded(
949 const DiskMountManager::Disk& disk, bool mounting) { 962 const DiskMountManager::Disk& disk, bool mounting) {
950 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 963 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
951 // Do nothing. 964 // Do nothing.
952 } 965 }
953 966
954 void EventRouter::OnDiskRemoved(const DiskMountManager::Disk& disk) { 967 void EventRouter::OnDiskRemoved(const DiskMountManager::Disk& disk) {
955 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 968 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 void EventRouter::SetDispatchDirectoryChangeEventImplForTesting( 1046 void EventRouter::SetDispatchDirectoryChangeEventImplForTesting(
1034 const DispatchDirectoryChangeEventImplCallback& callback) { 1047 const DispatchDirectoryChangeEventImplCallback& callback) {
1035 dispatch_directory_change_event_impl_ = callback; 1048 dispatch_directory_change_event_impl_ = callback;
1036 } 1049 }
1037 1050
1038 base::WeakPtr<EventRouter> EventRouter::GetWeakPtr() { 1051 base::WeakPtr<EventRouter> EventRouter::GetWeakPtr() {
1039 return weak_factory_.GetWeakPtr(); 1052 return weak_factory_.GetWeakPtr();
1040 } 1053 }
1041 1054
1042 } // namespace file_manager 1055 } // namespace file_manager
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698