| 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/streams_private/streams_private_api.h" | 5 #include "chrome/browser/extensions/api/streams_private/streams_private_api.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 event_args->Append(new base::StringValue(stream->GetMimeType())); | 53 event_args->Append(new base::StringValue(stream->GetMimeType())); |
| 54 event_args->Append(new base::StringValue(stream->GetOriginalURL().spec())); | 54 event_args->Append(new base::StringValue(stream->GetOriginalURL().spec())); |
| 55 event_args->Append(new base::StringValue(stream->GetURL().spec())); | 55 event_args->Append(new base::StringValue(stream->GetURL().spec())); |
| 56 | 56 |
| 57 scoped_ptr<Event> event(new Event(events::kOnExecuteMimeTypeHandler, | 57 scoped_ptr<Event> event(new Event(events::kOnExecuteMimeTypeHandler, |
| 58 event_args.Pass())); | 58 event_args.Pass())); |
| 59 | 59 |
| 60 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( | 60 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( |
| 61 extension_id, event.Pass()); | 61 extension_id, event.Pass()); |
| 62 | 62 |
| 63 streams_[extension_id][stream->GetURL()] = | 63 GURL url = stream->GetURL(); |
| 64 make_linked_ptr(stream.release()); | 64 streams_[extension_id][url] = make_linked_ptr(stream.release()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 static base::LazyInstance<ProfileKeyedAPIFactory<StreamsPrivateAPI> > | 67 static base::LazyInstance<ProfileKeyedAPIFactory<StreamsPrivateAPI> > |
| 68 g_factory = LAZY_INSTANCE_INITIALIZER; | 68 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 69 | 69 |
| 70 // static | 70 // static |
| 71 ProfileKeyedAPIFactory<StreamsPrivateAPI>* | 71 ProfileKeyedAPIFactory<StreamsPrivateAPI>* |
| 72 StreamsPrivateAPI::GetFactoryInstance() { | 72 StreamsPrivateAPI::GetFactoryInstance() { |
| 73 return &g_factory.Get(); | 73 return &g_factory.Get(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void StreamsPrivateAPI::Observe(int type, | 76 void StreamsPrivateAPI::Observe(int type, |
| 77 const content::NotificationSource& source, | 77 const content::NotificationSource& source, |
| 78 const content::NotificationDetails& details) { | 78 const content::NotificationDetails& details) { |
| 79 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { | 79 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { |
| 80 const Extension* extension = | 80 const Extension* extension = |
| 81 content::Details<const UnloadedExtensionInfo>(details)->extension; | 81 content::Details<const UnloadedExtensionInfo>(details)->extension; |
| 82 streams_.erase(extension->id()); | 82 streams_.erase(extension->id()); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 } // namespace extensions | 85 } // namespace extensions |
| OLD | NEW |