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 14 matching lines...) Expand all Loading... |
25 namespace streams_private = api::streams_private; | 25 namespace streams_private = api::streams_private; |
26 | 26 |
27 // static | 27 // static |
28 StreamsPrivateAPI* StreamsPrivateAPI::Get(content::BrowserContext* context) { | 28 StreamsPrivateAPI* StreamsPrivateAPI::Get(content::BrowserContext* context) { |
29 return GetFactoryInstance()->Get(context); | 29 return GetFactoryInstance()->Get(context); |
30 } | 30 } |
31 | 31 |
32 StreamsPrivateAPI::StreamsPrivateAPI(content::BrowserContext* context) | 32 StreamsPrivateAPI::StreamsPrivateAPI(content::BrowserContext* context) |
33 : profile_(Profile::FromBrowserContext(context)), weak_ptr_factory_(this) { | 33 : profile_(Profile::FromBrowserContext(context)), weak_ptr_factory_(this) { |
34 registrar_.Add(this, | 34 registrar_.Add(this, |
35 chrome::NOTIFICATION_EXTENSION_UNLOADED, | 35 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
36 content::Source<Profile>(profile_)); | 36 content::Source<Profile>(profile_)); |
37 } | 37 } |
38 | 38 |
39 StreamsPrivateAPI::~StreamsPrivateAPI() { | 39 StreamsPrivateAPI::~StreamsPrivateAPI() { |
40 } | 40 } |
41 | 41 |
42 void StreamsPrivateAPI::ExecuteMimeTypeHandler( | 42 void StreamsPrivateAPI::ExecuteMimeTypeHandler( |
43 const std::string& extension_id, | 43 const std::string& extension_id, |
44 const content::WebContents* web_contents, | 44 const content::WebContents* web_contents, |
45 scoped_ptr<content::StreamHandle> stream, | 45 scoped_ptr<content::StreamHandle> stream, |
(...skipping 27 matching lines...) Expand all Loading... |
73 | 73 |
74 // static | 74 // static |
75 BrowserContextKeyedAPIFactory<StreamsPrivateAPI>* | 75 BrowserContextKeyedAPIFactory<StreamsPrivateAPI>* |
76 StreamsPrivateAPI::GetFactoryInstance() { | 76 StreamsPrivateAPI::GetFactoryInstance() { |
77 return g_factory.Pointer(); | 77 return g_factory.Pointer(); |
78 } | 78 } |
79 | 79 |
80 void StreamsPrivateAPI::Observe(int type, | 80 void StreamsPrivateAPI::Observe(int type, |
81 const content::NotificationSource& source, | 81 const content::NotificationSource& source, |
82 const content::NotificationDetails& details) { | 82 const content::NotificationDetails& details) { |
83 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { | 83 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED) { |
84 const Extension* extension = | 84 const Extension* extension = |
85 content::Details<const UnloadedExtensionInfo>(details)->extension; | 85 content::Details<const UnloadedExtensionInfo>(details)->extension; |
86 streams_.erase(extension->id()); | 86 streams_.erase(extension->id()); |
87 } | 87 } |
88 } | 88 } |
89 } // namespace extensions | 89 } // namespace extensions |
OLD | NEW |