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 "components/keyed_service/core/keyed_service.h"
14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h"
16 #include "extensions/browser/browser_context_keyed_api_factory.h"
17 #include "extensions/browser/extension_function.h"
18 #include "extensions/common/extension.h"
27 namespace extensions {
29 class StreamsPrivateAPI : public BrowserContextKeyedAPI,
30 public content::NotificationObserver {
32 // Convenience method to get the StreamsPrivateAPI for a profile.
33 static StreamsPrivateAPI* Get(content::BrowserContext* context);
35 explicit StreamsPrivateAPI(content::BrowserContext* context);
36 virtual ~StreamsPrivateAPI();
38 void ExecuteMimeTypeHandler(const std::string& extension_id,
39 const content::WebContents* web_contents,
40 scoped_ptr<content::StreamHandle> stream,
41 int64 expected_content_size);
43 // BrowserContextKeyedAPI implementation.
44 static BrowserContextKeyedAPIFactory<StreamsPrivateAPI>* GetFactoryInstance();
46 // content::NotificationObserver implementation.
47 virtual void Observe(int type,
48 const content::NotificationSource& source,
49 const content::NotificationDetails& details) OVERRIDE;
52 friend class BrowserContextKeyedAPIFactory<StreamsPrivateAPI>;
53 typedef std::map<std::string,
55 linked_ptr<content::StreamHandle> > > StreamMap;
57 // BrowserContextKeyedAPI implementation.
58 static const char* service_name() {
59 return "StreamsPrivateAPI";
61 static const bool kServiceIsNULLWhileTesting = true;
62 static const bool kServiceRedirectedInIncognito = true;
64 Profile* const profile_;
65 content::NotificationRegistrar registrar_;
67 base::WeakPtrFactory<StreamsPrivateAPI> weak_ptr_factory_;
70 } // namespace extensions
72 #endif // CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_