| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/file_util.h" | 8 #include "base/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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 return true; | 165 return true; |
| 166 } | 166 } |
| 167 | 167 |
| 168 return false; | 168 return false; |
| 169 } | 169 } |
| 170 | 170 |
| 171 // Sends an event named |event_name| with arguments |event_args| to extensions. | 171 // Sends an event named |event_name| with arguments |event_args| to extensions. |
| 172 void BroadcastEvent(Profile* profile, | 172 void BroadcastEvent(Profile* profile, |
| 173 const std::string& event_name, | 173 const std::string& event_name, |
| 174 scoped_ptr<base::ListValue> event_args) { | 174 scoped_ptr<base::ListValue> event_args) { |
| 175 extensions::ExtensionSystem::Get(profile)->event_router()-> | 175 extensions::EventRouter::Get(profile)->BroadcastEvent( |
| 176 BroadcastEvent(make_scoped_ptr( | 176 make_scoped_ptr(new extensions::Event(event_name, event_args.Pass()))); |
| 177 new extensions::Event(event_name, event_args.Pass()))); | |
| 178 } | 177 } |
| 179 | 178 |
| 180 file_browser_private::MountCompletedStatus | 179 file_browser_private::MountCompletedStatus |
| 181 MountErrorToMountCompletedStatus(chromeos::MountError error) { | 180 MountErrorToMountCompletedStatus(chromeos::MountError error) { |
| 182 switch (error) { | 181 switch (error) { |
| 183 case chromeos::MOUNT_ERROR_NONE: | 182 case chromeos::MOUNT_ERROR_NONE: |
| 184 return file_browser_private::MOUNT_COMPLETED_STATUS_SUCCESS; | 183 return file_browser_private::MOUNT_COMPLETED_STATUS_SUCCESS; |
| 185 case chromeos::MOUNT_ERROR_UNKNOWN: | 184 case chromeos::MOUNT_ERROR_UNKNOWN: |
| 186 return file_browser_private::MOUNT_COMPLETED_STATUS_ERROR_UNKNOWN; | 185 return file_browser_private::MOUNT_COMPLETED_STATUS_ERROR_UNKNOWN; |
| 187 case chromeos::MOUNT_ERROR_INTERNAL: | 186 case chromeos::MOUNT_ERROR_INTERNAL: |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 if (!ShouldSendProgressEvent(always, &last_copy_progress_event_)) | 551 if (!ShouldSendProgressEvent(always, &last_copy_progress_event_)) |
| 553 return; | 552 return; |
| 554 | 553 |
| 555 BroadcastEvent( | 554 BroadcastEvent( |
| 556 profile_, | 555 profile_, |
| 557 file_browser_private::OnCopyProgress::kEventName, | 556 file_browser_private::OnCopyProgress::kEventName, |
| 558 file_browser_private::OnCopyProgress::Create(copy_id, status)); | 557 file_browser_private::OnCopyProgress::Create(copy_id, status)); |
| 559 } | 558 } |
| 560 | 559 |
| 561 void EventRouter::DefaultNetworkChanged(const chromeos::NetworkState* network) { | 560 void EventRouter::DefaultNetworkChanged(const chromeos::NetworkState* network) { |
| 562 if (!profile_ || | 561 if (!profile_ || !extensions::EventRouter::Get(profile_)) { |
| 563 !extensions::ExtensionSystem::Get(profile_)->event_router()) { | |
| 564 NOTREACHED(); | 562 NOTREACHED(); |
| 565 return; | 563 return; |
| 566 } | 564 } |
| 567 | 565 |
| 568 BroadcastEvent( | 566 BroadcastEvent( |
| 569 profile_, | 567 profile_, |
| 570 file_browser_private::OnDriveConnectionStatusChanged::kEventName, | 568 file_browser_private::OnDriveConnectionStatusChanged::kEventName, |
| 571 file_browser_private::OnDriveConnectionStatusChanged::Create()); | 569 file_browser_private::OnDriveConnectionStatusChanged::Create()); |
| 572 } | 570 } |
| 573 | 571 |
| 574 void EventRouter::OnFileManagerPrefsChanged() { | 572 void EventRouter::OnFileManagerPrefsChanged() { |
| 575 if (!profile_ || | 573 if (!profile_ || !extensions::EventRouter::Get(profile_)) { |
| 576 !extensions::ExtensionSystem::Get(profile_)->event_router()) { | |
| 577 NOTREACHED(); | 574 NOTREACHED(); |
| 578 return; | 575 return; |
| 579 } | 576 } |
| 580 | 577 |
| 581 BroadcastEvent( | 578 BroadcastEvent( |
| 582 profile_, | 579 profile_, |
| 583 file_browser_private::OnPreferencesChanged::kEventName, | 580 file_browser_private::OnPreferencesChanged::kEventName, |
| 584 file_browser_private::OnPreferencesChanged::Create()); | 581 file_browser_private::OnPreferencesChanged::Create()); |
| 585 } | 582 } |
| 586 | 583 |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 } | 927 } |
| 931 } | 928 } |
| 932 | 929 |
| 933 void EventRouter::OnOwnerEntryChanged(aura::Window* window) { | 930 void EventRouter::OnOwnerEntryChanged(aura::Window* window) { |
| 934 BroadcastEvent(profile_, | 931 BroadcastEvent(profile_, |
| 935 file_browser_private::OnDesktopChanged::kEventName, | 932 file_browser_private::OnDesktopChanged::kEventName, |
| 936 file_browser_private::OnDesktopChanged::Create()); | 933 file_browser_private::OnDesktopChanged::Create()); |
| 937 } | 934 } |
| 938 | 935 |
| 939 } // namespace file_manager | 936 } // namespace file_manager |
| OLD | NEW |