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 #ifndef CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 13 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
14 #include "chrome/browser/extensions/extension_function.h" | 14 #include "chrome/browser/extensions/extension_function.h" |
15 #include "chrome/browser/profiles/profile_keyed_service.h" | 15 #include "chrome/browser/profiles/profile_keyed_service.h" |
16 #include "chrome/common/extensions/extension.h" | 16 #include "chrome/common/extensions/extension.h" |
17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
19 | 19 |
20 class Profile; | 20 class Profile; |
21 | 21 |
| 22 namespace content { |
| 23 class StreamHandle; |
| 24 } |
| 25 |
22 namespace extensions { | 26 namespace extensions { |
23 | 27 |
24 class StreamsPrivateAPI : public ProfileKeyedAPI { | 28 class StreamsPrivateAPI : public ProfileKeyedAPI, |
| 29 public content::NotificationObserver { |
25 public: | 30 public: |
| 31 // Convenience method to get the StreamsPrivateAPI for a profile. |
| 32 static StreamsPrivateAPI* Get(Profile* profile); |
| 33 |
26 explicit StreamsPrivateAPI(Profile* profile); | 34 explicit StreamsPrivateAPI(Profile* profile); |
27 virtual ~StreamsPrivateAPI(); | 35 virtual ~StreamsPrivateAPI(); |
28 | 36 |
| 37 void ExecuteMimeTypeHandler(const std::string& extension_id, |
| 38 scoped_ptr<content::StreamHandle> stream); |
| 39 |
29 // ProfileKeyedAPI implementation. | 40 // ProfileKeyedAPI implementation. |
30 static ProfileKeyedAPIFactory<StreamsPrivateAPI>* GetFactoryInstance(); | 41 static ProfileKeyedAPIFactory<StreamsPrivateAPI>* GetFactoryInstance(); |
31 | 42 |
| 43 // content::NotificationObserver implementation. |
| 44 virtual void Observe(int type, |
| 45 const content::NotificationSource& source, |
| 46 const content::NotificationDetails& details) OVERRIDE; |
| 47 |
32 private: | 48 private: |
33 friend class ProfileKeyedAPIFactory<StreamsPrivateAPI>; | 49 friend class ProfileKeyedAPIFactory<StreamsPrivateAPI>; |
| 50 typedef std::map<std::string, |
| 51 std::map<GURL, |
| 52 linked_ptr<content::StreamHandle> > > StreamMap; |
34 | 53 |
35 // ProfileKeyedAPI implementation. | 54 // ProfileKeyedAPI implementation. |
36 static const char* service_name() { | 55 static const char* service_name() { |
37 return "StreamsPrivateAPI"; | 56 return "StreamsPrivateAPI"; |
38 } | 57 } |
39 static const bool kServiceIsNULLWhileTesting = true; | 58 static const bool kServiceIsNULLWhileTesting = true; |
40 | 59 |
41 Profile* const profile_; | 60 Profile* const profile_; |
| 61 content::NotificationRegistrar registrar_; |
| 62 StreamMap streams_; |
| 63 base::WeakPtrFactory<StreamsPrivateAPI> weak_ptr_factory_; |
42 }; | 64 }; |
43 | 65 |
44 } // namespace extensions | 66 } // namespace extensions |
45 | 67 |
46 #endif // CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_ | 68 #endif // CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_ |
OLD | NEW |