| 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 const std::string& mime_type, |
| 40 const GURL& original_url); |
| 41 |
| 29 // ProfileKeyedAPI implementation. | 42 // ProfileKeyedAPI implementation. |
| 30 static ProfileKeyedAPIFactory<StreamsPrivateAPI>* GetFactoryInstance(); | 43 static ProfileKeyedAPIFactory<StreamsPrivateAPI>* GetFactoryInstance(); |
| 31 | 44 |
| 45 // content::NotificationObserver implementation. |
| 46 virtual void Observe(int type, |
| 47 const content::NotificationSource& source, |
| 48 const content::NotificationDetails& details) OVERRIDE; |
| 49 |
| 32 private: | 50 private: |
| 33 friend class ProfileKeyedAPIFactory<StreamsPrivateAPI>; | 51 friend class ProfileKeyedAPIFactory<StreamsPrivateAPI>; |
| 52 typedef std::map<std::string, |
| 53 std::map<GURL, |
| 54 linked_ptr<content::StreamHandle> > > StreamMap; |
| 55 |
| 56 void OnStreamClosed(const std::string& extension_id, const GURL& url); |
| 34 | 57 |
| 35 // ProfileKeyedAPI implementation. | 58 // ProfileKeyedAPI implementation. |
| 36 static const char* service_name() { | 59 static const char* service_name() { |
| 37 return "StreamsPrivateAPI"; | 60 return "StreamsPrivateAPI"; |
| 38 } | 61 } |
| 39 static const bool kServiceIsNULLWhileTesting = true; | 62 static const bool kServiceIsNULLWhileTesting = true; |
| 40 | 63 |
| 41 Profile* const profile_; | 64 Profile* const profile_; |
| 65 content::NotificationRegistrar registrar_; |
| 66 StreamMap streams_; |
| 67 base::WeakPtrFactory<StreamsPrivateAPI> weak_ptr_factory_; |
| 42 }; | 68 }; |
| 43 | 69 |
| 44 } // namespace extensions | 70 } // namespace extensions |
| 45 | 71 |
| 46 #endif // CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_ | 72 #endif // CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_ |
| OLD | NEW |