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_
11 #include "base/scoped_observer.h"
12 #include "extensions/browser/browser_context_keyed_api_factory.h"
13 #include "extensions/browser/extension_function.h"
14 #include "extensions/browser/extension_registry_observer.h"
21 namespace extensions {
22 class ExtensionRegistry;
24 class StreamsPrivateAPI : public BrowserContextKeyedAPI,
25 public ExtensionRegistryObserver {
27 // Convenience method to get the StreamsPrivateAPI for a BrowserContext.
28 static StreamsPrivateAPI* Get(content::BrowserContext* context);
30 explicit StreamsPrivateAPI(content::BrowserContext* context);
31 virtual ~StreamsPrivateAPI();
33 void ExecuteMimeTypeHandler(const std::string& extension_id,
34 content::WebContents* web_contents,
35 scoped_ptr<content::StreamHandle> stream,
36 int64 expected_content_size);
38 // BrowserContextKeyedAPI implementation.
39 static BrowserContextKeyedAPIFactory<StreamsPrivateAPI>* GetFactoryInstance();
42 friend class BrowserContextKeyedAPIFactory<StreamsPrivateAPI>;
43 typedef std::map<std::string,
45 linked_ptr<content::StreamHandle> > > StreamMap;
47 // ExtensionRegistryObserver implementation.
48 virtual void OnExtensionUnloaded(
49 content::BrowserContext* browser_context,
50 const Extension* extension,
51 UnloadedExtensionInfo::Reason reason) OVERRIDE;
53 // BrowserContextKeyedAPI implementation.
54 static const char* service_name() {
55 return "StreamsPrivateAPI";
57 static const bool kServiceIsNULLWhileTesting = true;
58 static const bool kServiceRedirectedInIncognito = true;
60 content::BrowserContext* const browser_context_;
62 base::WeakPtrFactory<StreamsPrivateAPI> weak_ptr_factory_;
64 // Listen to extension unloaded notifications.
65 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
66 extension_registry_observer_;
69 } // namespace extensions
71 #endif // CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_