| 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/extensions/api/api_resource_event_notifier.h" | 5 #include "chrome/browser/extensions/api/api_resource_event_notifier.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "chrome/browser/extensions/extension_event_router.h" | 8 #include "chrome/browser/extensions/extension_event_router.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 | 10 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 DictionaryValue* event = CreateAPIResourceEvent(event_type); | 74 DictionaryValue* event = CreateAPIResourceEvent(event_type); |
| 75 event->SetInteger(kResultCodeKey, result_code); | 75 event->SetInteger(kResultCodeKey, result_code); |
| 76 DispatchEvent(event); | 76 DispatchEvent(event); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void APIResourceEventNotifier::DispatchEvent(DictionaryValue* event) { | 79 void APIResourceEventNotifier::DispatchEvent(DictionaryValue* event) { |
| 80 ListValue args; | 80 ListValue args; |
| 81 | 81 |
| 82 args.Set(0, event); | 82 args.Set(0, event); |
| 83 std::string json_args; | 83 std::string json_args; |
| 84 base::JSONWriter::Write(&args, false, &json_args); | 84 base::JSONWriter::Write(&args, &json_args); |
| 85 router_->DispatchEventToExtension(src_extension_id_, | 85 router_->DispatchEventToExtension(src_extension_id_, |
| 86 events::kOnAPIResourceEvent, | 86 events::kOnAPIResourceEvent, |
| 87 json_args, profile_, src_url_); | 87 json_args, profile_, src_url_); |
| 88 } | 88 } |
| 89 | 89 |
| 90 DictionaryValue* APIResourceEventNotifier::CreateAPIResourceEvent( | 90 DictionaryValue* APIResourceEventNotifier::CreateAPIResourceEvent( |
| 91 APIResourceEventType event_type) { | 91 APIResourceEventType event_type) { |
| 92 DictionaryValue* event = new DictionaryValue(); | 92 DictionaryValue* event = new DictionaryValue(); |
| 93 event->SetString(kEventTypeKey, APIResourceEventTypeToString(event_type)); | 93 event->SetString(kEventTypeKey, APIResourceEventTypeToString(event_type)); |
| 94 event->SetInteger(kSrcIdKey, src_id_); | 94 event->SetInteger(kSrcIdKey, src_id_); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 112 return kEventTypeDataRead; | 112 return kEventTypeDataRead; |
| 113 case API_RESOURCE_EVENT_WRITE_COMPLETE: | 113 case API_RESOURCE_EVENT_WRITE_COMPLETE: |
| 114 return kEventTypeWriteComplete; | 114 return kEventTypeWriteComplete; |
| 115 } | 115 } |
| 116 | 116 |
| 117 NOTREACHED(); | 117 NOTREACHED(); |
| 118 return std::string(); | 118 return std::string(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace extensions | 121 } // namespace extensions |
| OLD | NEW |