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 | 10 |
11 #include "base/scoped_observer.h" | 11 #include "base/scoped_observer.h" |
12 #include "extensions/browser/browser_context_keyed_api_factory.h" | 12 #include "extensions/browser/browser_context_keyed_api_factory.h" |
13 #include "extensions/browser/extension_function.h" | 13 #include "extensions/browser/extension_function.h" |
14 #include "extensions/browser/extension_registry_observer.h" | 14 #include "extensions/browser/extension_registry_observer.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 class BrowserContext; | 17 class BrowserContext; |
18 class StreamHandle; | 18 class StreamHandle; |
| 19 struct StreamInfo; |
19 } | 20 } |
20 | 21 |
21 namespace extensions { | 22 namespace extensions { |
22 class ExtensionRegistry; | 23 class ExtensionRegistry; |
23 | 24 |
24 class StreamsPrivateAPI : public BrowserContextKeyedAPI, | 25 class StreamsPrivateAPI : public BrowserContextKeyedAPI, |
25 public ExtensionRegistryObserver { | 26 public ExtensionRegistryObserver { |
26 public: | 27 public: |
27 // Convenience method to get the StreamsPrivateAPI for a BrowserContext. | 28 // Convenience method to get the StreamsPrivateAPI for a BrowserContext. |
28 static StreamsPrivateAPI* Get(content::BrowserContext* context); | 29 static StreamsPrivateAPI* Get(content::BrowserContext* context); |
29 | 30 |
30 explicit StreamsPrivateAPI(content::BrowserContext* context); | 31 explicit StreamsPrivateAPI(content::BrowserContext* context); |
31 virtual ~StreamsPrivateAPI(); | 32 virtual ~StreamsPrivateAPI(); |
32 | 33 |
33 // Send the onExecuteMimeTypeHandler event to |extension_id|. | 34 // Send the onExecuteMimeTypeHandler event to |extension_id|. |
34 // |web_contents| is used to determine the tabId where the document is being | 35 // |web_contents| is used to determine the tabId where the document is being |
35 // opened. The data for the document will be readable from |stream|, and | 36 // opened. The data for the document will be readable from |stream|, and |
36 // should be |expected_content_size| bytes long. If the viewer is being opened | 37 // should be |expected_content_size| bytes long. If the viewer is being opened |
37 // in a BrowserPlugin, specify a non-empty |view_id| of the plugin. | 38 // in a BrowserPlugin, specify a non-empty |view_id| of the plugin. |
38 void ExecuteMimeTypeHandler(const std::string& extension_id, | 39 void ExecuteMimeTypeHandler(const std::string& extension_id, |
39 content::WebContents* web_contents, | 40 content::WebContents* web_contents, |
40 scoped_ptr<content::StreamHandle> stream, | 41 scoped_ptr<content::StreamInfo> stream, |
41 const std::string& view_id, | 42 const std::string& view_id, |
42 int64 expected_content_size); | 43 int64 expected_content_size); |
43 | 44 |
44 void AbortStream(const std::string& extension_id, | 45 void AbortStream(const std::string& extension_id, |
45 const GURL& stream_url, | 46 const GURL& stream_url, |
46 const base::Closure& callback); | 47 const base::Closure& callback); |
47 | 48 |
48 // BrowserContextKeyedAPI implementation. | 49 // BrowserContextKeyedAPI implementation. |
49 static BrowserContextKeyedAPIFactory<StreamsPrivateAPI>* GetFactoryInstance(); | 50 static BrowserContextKeyedAPIFactory<StreamsPrivateAPI>* GetFactoryInstance(); |
50 | 51 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 90 |
90 private: | 91 private: |
91 void OnClose(); | 92 void OnClose(); |
92 | 93 |
93 std::string stream_url_; | 94 std::string stream_url_; |
94 }; | 95 }; |
95 | 96 |
96 } // namespace extensions | 97 } // namespace extensions |
97 | 98 |
98 #endif // CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_ | 99 #endif // CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_ |
OLD | NEW |