| 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" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/extensions/event_router.h" | 12 #include "chrome/browser/extensions/event_router.h" |
| 13 #include "chrome/browser/extensions/extension_function_registry.h" | 13 #include "chrome/browser/extensions/extension_function_registry.h" |
| 14 #include "chrome/browser/extensions/extension_input_module_constants.h" | 14 #include "chrome/browser/extensions/extension_input_module_constants.h" |
| 15 #include "chrome/browser/extensions/extension_system.h" | 15 #include "chrome/browser/extensions/extension_system.h" |
| 16 #include "chrome/browser/extensions/extension_tab_util.h" | 16 #include "chrome/browser/extensions/extension_tab_util.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/common/extensions/mime_types_handler.h" | |
| 19 #include "content/public/browser/stream_handle.h" | 18 #include "content/public/browser/stream_handle.h" |
| 20 | 19 |
| 21 namespace keys = extension_input_module_constants; | 20 namespace keys = extension_input_module_constants; |
| 22 | 21 |
| 23 namespace events { | 22 namespace events { |
| 24 | 23 |
| 25 const char kOnExecuteMimeTypeHandler[] = | 24 const char kOnExecuteMimeTypeHandler[] = |
| 26 "streamsPrivate.onExecuteMimeTypeHandler"; | 25 "streamsPrivate.onExecuteMimeTypeHandler"; |
| 27 | 26 |
| 28 } // namespace events | 27 } // namespace events |
| 29 | 28 |
| 30 namespace extensions { | 29 namespace extensions { |
| 31 | 30 |
| 32 // static | 31 // static |
| 33 StreamsPrivateAPI* StreamsPrivateAPI::Get(Profile* profile) { | 32 StreamsPrivateAPI* StreamsPrivateAPI::Get(Profile* profile) { |
| 34 return GetFactoryInstance()->GetForProfile(profile); | 33 return GetFactoryInstance()->GetForProfile(profile); |
| 35 } | 34 } |
| 36 | 35 |
| 37 StreamsPrivateAPI::StreamsPrivateAPI(Profile* profile) | 36 StreamsPrivateAPI::StreamsPrivateAPI(Profile* profile) |
| 38 : profile_(profile), | 37 : profile_(profile), |
| 39 weak_ptr_factory_(this) { | 38 weak_ptr_factory_(this) { |
| 40 (new MimeTypesHandlerParser)->Register(); | |
| 41 | |
| 42 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 39 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 43 content::Source<Profile>(profile)); | 40 content::Source<Profile>(profile)); |
| 44 } | 41 } |
| 45 | 42 |
| 46 StreamsPrivateAPI::~StreamsPrivateAPI() { | 43 StreamsPrivateAPI::~StreamsPrivateAPI() { |
| 47 } | 44 } |
| 48 | 45 |
| 49 void StreamsPrivateAPI::ExecuteMimeTypeHandler( | 46 void StreamsPrivateAPI::ExecuteMimeTypeHandler( |
| 50 const std::string& extension_id, | 47 const std::string& extension_id, |
| 51 const content::WebContents* web_contents, | 48 const content::WebContents* web_contents, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 80 void StreamsPrivateAPI::Observe(int type, | 77 void StreamsPrivateAPI::Observe(int type, |
| 81 const content::NotificationSource& source, | 78 const content::NotificationSource& source, |
| 82 const content::NotificationDetails& details) { | 79 const content::NotificationDetails& details) { |
| 83 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { | 80 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { |
| 84 const Extension* extension = | 81 const Extension* extension = |
| 85 content::Details<const UnloadedExtensionInfo>(details)->extension; | 82 content::Details<const UnloadedExtensionInfo>(details)->extension; |
| 86 streams_.erase(extension->id()); | 83 streams_.erase(extension->id()); |
| 87 } | 84 } |
| 88 } | 85 } |
| 89 } // namespace extensions | 86 } // namespace extensions |
| OLD | NEW |