| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 11 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/prefs/pref_change_registrar.h" | 14 #include "base/prefs/pref_change_registrar.h" |
| 14 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
| 15 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 16 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
| 17 #include "base/threading/sequenced_worker_pool.h" | 18 #include "base/threading/sequenced_worker_pool.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 95 } |
| 95 | 96 |
| 96 return false; | 97 return false; |
| 97 } | 98 } |
| 98 | 99 |
| 99 // Sends an event named |event_name| with arguments |event_args| to extensions. | 100 // Sends an event named |event_name| with arguments |event_args| to extensions. |
| 100 void BroadcastEvent(Profile* profile, | 101 void BroadcastEvent(Profile* profile, |
| 101 extensions::events::HistogramValue histogram_value, | 102 extensions::events::HistogramValue histogram_value, |
| 102 const std::string& event_name, | 103 const std::string& event_name, |
| 103 scoped_ptr<base::ListValue> event_args) { | 104 scoped_ptr<base::ListValue> event_args) { |
| 104 extensions::EventRouter::Get(profile)->BroadcastEvent(make_scoped_ptr( | 105 extensions::EventRouter::Get(profile) |
| 105 new extensions::Event(histogram_value, event_name, event_args.Pass()))); | 106 ->BroadcastEvent(make_scoped_ptr(new extensions::Event( |
| 107 histogram_value, event_name, std::move(event_args)))); |
| 106 } | 108 } |
| 107 | 109 |
| 108 // Sends an event named |event_name| with arguments |event_args| to an extension | 110 // Sends an event named |event_name| with arguments |event_args| to an extension |
| 109 // of |extention_id|. | 111 // of |extention_id|. |
| 110 void DispatchEventToExtension( | 112 void DispatchEventToExtension( |
| 111 Profile* profile, | 113 Profile* profile, |
| 112 const std::string& extension_id, | 114 const std::string& extension_id, |
| 113 extensions::events::HistogramValue histogram_value, | 115 extensions::events::HistogramValue histogram_value, |
| 114 const std::string& event_name, | 116 const std::string& event_name, |
| 115 scoped_ptr<base::ListValue> event_args) { | 117 scoped_ptr<base::ListValue> event_args) { |
| 116 extensions::EventRouter::Get(profile)->DispatchEventToExtension( | 118 extensions::EventRouter::Get(profile)->DispatchEventToExtension( |
| 117 extension_id, make_scoped_ptr(new extensions::Event( | 119 extension_id, make_scoped_ptr(new extensions::Event( |
| 118 histogram_value, event_name, event_args.Pass()))); | 120 histogram_value, event_name, std::move(event_args)))); |
| 119 } | 121 } |
| 120 | 122 |
| 121 file_manager_private::MountCompletedStatus | 123 file_manager_private::MountCompletedStatus |
| 122 MountErrorToMountCompletedStatus(chromeos::MountError error) { | 124 MountErrorToMountCompletedStatus(chromeos::MountError error) { |
| 123 switch (error) { | 125 switch (error) { |
| 124 case chromeos::MOUNT_ERROR_NONE: | 126 case chromeos::MOUNT_ERROR_NONE: |
| 125 return file_manager_private::MOUNT_COMPLETED_STATUS_SUCCESS; | 127 return file_manager_private::MOUNT_COMPLETED_STATUS_SUCCESS; |
| 126 case chromeos::MOUNT_ERROR_UNKNOWN: | 128 case chromeos::MOUNT_ERROR_UNKNOWN: |
| 127 return file_manager_private::MOUNT_COMPLETED_STATUS_ERROR_UNKNOWN; | 129 return file_manager_private::MOUNT_COMPLETED_STATUS_ERROR_UNKNOWN; |
| 128 case chromeos::MOUNT_ERROR_INTERNAL: | 130 case chromeos::MOUNT_ERROR_INTERNAL: |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 const std::string& extension_id) override { | 352 const std::string& extension_id) override { |
| 351 return file_manager::util::ConvertDrivePathToFileSystemUrl( | 353 return file_manager::util::ConvertDrivePathToFileSystemUrl( |
| 352 profile_, file_path, extension_id); | 354 profile_, file_path, extension_id); |
| 353 } | 355 } |
| 354 | 356 |
| 355 void DispatchEventToExtension( | 357 void DispatchEventToExtension( |
| 356 const std::string& extension_id, | 358 const std::string& extension_id, |
| 357 extensions::events::HistogramValue histogram_value, | 359 extensions::events::HistogramValue histogram_value, |
| 358 const std::string& event_name, | 360 const std::string& event_name, |
| 359 scoped_ptr<base::ListValue> event_args) override { | 361 scoped_ptr<base::ListValue> event_args) override { |
| 360 ::file_manager::DispatchEventToExtension( | 362 ::file_manager::DispatchEventToExtension(profile_, extension_id, |
| 361 profile_, extension_id, histogram_value, event_name, event_args.Pass()); | 363 histogram_value, event_name, |
| 364 std::move(event_args)); |
| 362 } | 365 } |
| 363 | 366 |
| 364 private: | 367 private: |
| 365 Profile* const profile_; | 368 Profile* const profile_; |
| 366 | 369 |
| 367 DISALLOW_COPY_AND_ASSIGN(JobEventRouterImpl); | 370 DISALLOW_COPY_AND_ASSIGN(JobEventRouterImpl); |
| 368 }; | 371 }; |
| 369 | 372 |
| 370 } // namespace | 373 } // namespace |
| 371 | 374 |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 void EventRouter::SetDispatchDirectoryChangeEventImplForTesting( | 976 void EventRouter::SetDispatchDirectoryChangeEventImplForTesting( |
| 974 const DispatchDirectoryChangeEventImplCallback& callback) { | 977 const DispatchDirectoryChangeEventImplCallback& callback) { |
| 975 dispatch_directory_change_event_impl_ = callback; | 978 dispatch_directory_change_event_impl_ = callback; |
| 976 } | 979 } |
| 977 | 980 |
| 978 base::WeakPtr<EventRouter> EventRouter::GetWeakPtr() { | 981 base::WeakPtr<EventRouter> EventRouter::GetWeakPtr() { |
| 979 return weak_factory_.GetWeakPtr(); | 982 return weak_factory_.GetWeakPtr(); |
| 980 } | 983 } |
| 981 | 984 |
| 982 } // namespace file_manager | 985 } // namespace file_manager |
| OLD | NEW |