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_TAB_CAPTURE_TAB_CAPTURE_REGISTRY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_TAB_CAPTURE_TAB_CAPTURE_REGISTRY_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_TAB_CAPTURE_TAB_CAPTURE_REGISTRY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_TAB_CAPTURE_TAB_CAPTURE_REGISTRY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.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/media/media_capture_devices_dispatcher.h" | 14 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
15 #include "chrome/common/extensions/api/tab_capture.h" | 15 #include "chrome/common/extensions/api/tab_capture.h" |
16 #include "content/public/browser/media_request_state.h" | 16 #include "content/public/browser/media_request_state.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 BrowserContext; |
| 24 } |
| 25 |
22 namespace extensions { | 26 namespace extensions { |
23 | 27 |
24 struct TabCaptureRequest; | 28 struct TabCaptureRequest; |
25 class FullscreenObserver; | 29 class FullscreenObserver; |
26 | 30 |
27 namespace tab_capture = extensions::api::tab_capture; | 31 namespace tab_capture = extensions::api::tab_capture; |
28 | 32 |
29 class TabCaptureRegistry : public ProfileKeyedAPI, | 33 class TabCaptureRegistry : public ProfileKeyedAPI, |
30 public content::NotificationObserver, | 34 public content::NotificationObserver, |
31 public MediaCaptureDevicesDispatcher::Observer { | 35 public MediaCaptureDevicesDispatcher::Observer { |
32 public: | 36 public: |
33 typedef std::vector<std::pair<int, tab_capture::TabCaptureState> > | 37 typedef std::vector<std::pair<int, tab_capture::TabCaptureState> > |
34 RegistryCaptureInfo; | 38 RegistryCaptureInfo; |
35 | 39 |
36 static TabCaptureRegistry* Get(Profile* profile); | 40 static TabCaptureRegistry* Get(content::BrowserContext* context); |
37 | 41 |
38 // Used by ProfileKeyedAPI. | 42 // Used by ProfileKeyedAPI. |
39 static ProfileKeyedAPIFactory<TabCaptureRegistry>* GetFactoryInstance(); | 43 static ProfileKeyedAPIFactory<TabCaptureRegistry>* GetFactoryInstance(); |
40 | 44 |
41 // List all pending, active and stopped capture requests. | 45 // List all pending, active and stopped capture requests. |
42 const RegistryCaptureInfo GetCapturedTabs( | 46 const RegistryCaptureInfo GetCapturedTabs( |
43 const std::string& extension_id) const; | 47 const std::string& extension_id) const; |
44 | 48 |
45 // Add a tab capture request to the registry when a stream is requested | 49 // Add a tab capture request to the registry when a stream is requested |
46 // through the API. | 50 // through the API. |
47 bool AddRequest(int render_process_id, | 51 bool AddRequest(int render_process_id, |
48 int render_view_id, | 52 int render_view_id, |
49 const std::string& extension_id, | 53 const std::string& extension_id, |
50 int tab_id, | 54 int tab_id, |
51 tab_capture::TabCaptureState status); | 55 tab_capture::TabCaptureState status); |
52 | 56 |
53 // The MediaStreamDevicesController will verify the request before creating | 57 // The MediaStreamDevicesController will verify the request before creating |
54 // the stream by checking the registry here. | 58 // the stream by checking the registry here. |
55 bool VerifyRequest(int render_process_id, int render_view_id); | 59 bool VerifyRequest(int render_process_id, int render_view_id); |
56 | 60 |
57 private: | 61 private: |
58 friend class ProfileKeyedAPIFactory<TabCaptureRegistry>; | 62 friend class ProfileKeyedAPIFactory<TabCaptureRegistry>; |
59 friend class FullscreenObserver; | 63 friend class FullscreenObserver; |
60 | 64 |
61 explicit TabCaptureRegistry(Profile* profile); | 65 explicit TabCaptureRegistry(content::BrowserContext* context); |
62 virtual ~TabCaptureRegistry(); | 66 virtual ~TabCaptureRegistry(); |
63 | 67 |
64 // Used by ProfileKeyedAPI. | 68 // Used by ProfileKeyedAPI. |
65 static const char* service_name() { | 69 static const char* service_name() { |
66 return "TabCaptureRegistry"; | 70 return "TabCaptureRegistry"; |
67 } | 71 } |
68 | 72 |
69 static const bool kServiceIsCreatedWithBrowserContext = false; | 73 static const bool kServiceIsCreatedWithBrowserContext = false; |
70 static const bool kServiceRedirectedInIncognito = true; | 74 static const bool kServiceRedirectedInIncognito = true; |
71 | 75 |
(...skipping 19 matching lines...) Expand all Loading... |
91 content::NotificationRegistrar registrar_; | 95 content::NotificationRegistrar registrar_; |
92 Profile* const profile_; | 96 Profile* const profile_; |
93 ScopedVector<TabCaptureRequest> requests_; | 97 ScopedVector<TabCaptureRequest> requests_; |
94 | 98 |
95 DISALLOW_COPY_AND_ASSIGN(TabCaptureRegistry); | 99 DISALLOW_COPY_AND_ASSIGN(TabCaptureRegistry); |
96 }; | 100 }; |
97 | 101 |
98 } // namespace extensions | 102 } // namespace extensions |
99 | 103 |
100 #endif // CHROME_BROWSER_EXTENSIONS_API_TAB_CAPTURE_TAB_CAPTURE_REGISTRY_H_ | 104 #endif // CHROME_BROWSER_EXTENSIONS_API_TAB_CAPTURE_TAB_CAPTURE_REGISTRY_H_ |
OLD | NEW |