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 11 matching lines...) Expand all Loading... |
22 namespace events { | 22 namespace events { |
23 | 23 |
24 const char kOnExecuteMimeTypeHandler[] = | 24 const char kOnExecuteMimeTypeHandler[] = |
25 "streamsPrivate.onExecuteMimeTypeHandler"; | 25 "streamsPrivate.onExecuteMimeTypeHandler"; |
26 | 26 |
27 } // namespace events | 27 } // namespace events |
28 | 28 |
29 namespace extensions { | 29 namespace extensions { |
30 | 30 |
31 // static | 31 // static |
32 StreamsPrivateAPI* StreamsPrivateAPI::Get(Profile* profile) { | 32 StreamsPrivateAPI* StreamsPrivateAPI::Get(content::BrowserContext* context) { |
33 return GetFactoryInstance()->GetForProfile(profile); | 33 return GetFactoryInstance()->GetForProfile(context); |
34 } | 34 } |
35 | 35 |
36 StreamsPrivateAPI::StreamsPrivateAPI(Profile* profile) | 36 StreamsPrivateAPI::StreamsPrivateAPI(content::BrowserContext* context) |
37 : profile_(profile), | 37 : profile_(Profile::FromBrowserContext(context)), weak_ptr_factory_(this) { |
38 weak_ptr_factory_(this) { | 38 registrar_.Add(this, |
39 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 39 chrome::NOTIFICATION_EXTENSION_UNLOADED, |
40 content::Source<Profile>(profile)); | 40 content::Source<Profile>(profile_)); |
41 } | 41 } |
42 | 42 |
43 StreamsPrivateAPI::~StreamsPrivateAPI() { | 43 StreamsPrivateAPI::~StreamsPrivateAPI() { |
44 } | 44 } |
45 | 45 |
46 void StreamsPrivateAPI::ExecuteMimeTypeHandler( | 46 void StreamsPrivateAPI::ExecuteMimeTypeHandler( |
47 const std::string& extension_id, | 47 const std::string& extension_id, |
48 const content::WebContents* web_contents, | 48 const content::WebContents* web_contents, |
49 scoped_ptr<content::StreamHandle> stream, | 49 scoped_ptr<content::StreamHandle> stream, |
50 int64 expected_content_size) { | 50 int64 expected_content_size) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 void StreamsPrivateAPI::Observe(int type, | 83 void StreamsPrivateAPI::Observe(int type, |
84 const content::NotificationSource& source, | 84 const content::NotificationSource& source, |
85 const content::NotificationDetails& details) { | 85 const content::NotificationDetails& details) { |
86 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { | 86 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { |
87 const Extension* extension = | 87 const Extension* extension = |
88 content::Details<const UnloadedExtensionInfo>(details)->extension; | 88 content::Details<const UnloadedExtensionInfo>(details)->extension; |
89 streams_.erase(extension->id()); | 89 streams_.erase(extension->id()); |
90 } | 90 } |
91 } | 91 } |
92 } // namespace extensions | 92 } // namespace extensions |
OLD | NEW |