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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_
12 #include "base/values.h"
13 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
14 #include "chrome/browser/extensions/extension_function.h"
15 #include "chrome/common/extensions/extension.h"
16 #include "components/browser_context_keyed_service/browser_context_keyed_service.h"
17 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h"
26 namespace extensions {
28 class StreamsPrivateAPI : public ProfileKeyedAPI,
29 public content::NotificationObserver {
31 // Convenience method to get the StreamsPrivateAPI for a profile.
32 static StreamsPrivateAPI* Get(Profile* profile);
34 explicit StreamsPrivateAPI(Profile* profile);
35 virtual ~StreamsPrivateAPI();
37 void ExecuteMimeTypeHandler(const std::string& extension_id,
38 const content::WebContents* web_contents,
39 scoped_ptr<content::StreamHandle> stream,
40 int64 expected_content_size);
42 // ProfileKeyedAPI implementation.
43 static ProfileKeyedAPIFactory<StreamsPrivateAPI>* GetFactoryInstance();
45 // content::NotificationObserver implementation.
46 virtual void Observe(int type,
47 const content::NotificationSource& source,
48 const content::NotificationDetails& details) OVERRIDE;
51 friend class ProfileKeyedAPIFactory<StreamsPrivateAPI>;
52 typedef std::map<std::string,
54 linked_ptr<content::StreamHandle> > > StreamMap;
56 // ProfileKeyedAPI implementation.
57 static const char* service_name() {
58 return "StreamsPrivateAPI";
60 static const bool kServiceIsNULLWhileTesting = true;
61 static const bool kServiceRedirectedInIncognito = true;
63 Profile* const profile_;
64 content::NotificationRegistrar registrar_;
66 base::WeakPtrFactory<StreamsPrivateAPI> weak_ptr_factory_;
69 } // namespace extensions
71 #endif // CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_