OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_DESKTOP_CAPTURE_DESKTOP_CAPTURE_BASE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DESKTOP_CAPTURE_DESKTOP_CAPTURE_BASE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_DESKTOP_CAPTURE_DESKTOP_CAPTURE_BASE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DESKTOP_CAPTURE_DESKTOP_CAPTURE_BASE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "chrome/browser/extensions/chrome_extension_function.h" | 12 #include "chrome/browser/extensions/chrome_extension_function.h" |
13 #include "chrome/browser/media/desktop_media_list.h" | 13 #include "chrome/browser/media/desktop_media_list.h" |
14 #include "chrome/browser/media/desktop_media_picker.h" | 14 #include "chrome/browser/media/desktop_media_picker.h" |
15 #include "chrome/common/extensions/api/desktop_capture.h" | 15 #include "chrome/common/extensions/api/desktop_capture.h" |
16 #include "content/public/browser/web_contents_observer.h" | 16 #include "content/public/browser/web_contents_observer.h" |
17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
18 | 18 |
19 namespace extensions { | 19 namespace extensions { |
20 | 20 |
21 class DesktopCaptureChooseDesktopMediaFunctionBase | 21 class DesktopCaptureChooseDesktopMediaFunctionBase |
22 : public ChromeAsyncExtensionFunction, | 22 : public ChromeAsyncExtensionFunction, |
23 public content::WebContentsObserver { | 23 public content::WebContentsObserver { |
24 public: | 24 public: |
25 // Factory creating DesktopMediaList and DesktopMediaPicker instances. | 25 // Factory creating DesktopMediaList and DesktopMediaPicker instances. |
26 // Used for tests to supply fake picker. | 26 // Used for tests to supply fake picker. |
27 class PickerFactory { | 27 class PickerFactory { |
28 public: | 28 public: |
29 virtual scoped_ptr<DesktopMediaList> CreateModel(bool show_screens, | 29 virtual std::unique_ptr<DesktopMediaList> CreateModel(bool show_screens, |
30 bool show_windows, | 30 bool show_windows, |
31 bool show_tabs, | 31 bool show_tabs, |
32 bool show_audio) = 0; | 32 bool show_audio) = 0; |
33 virtual scoped_ptr<DesktopMediaPicker> CreatePicker() = 0; | 33 virtual std::unique_ptr<DesktopMediaPicker> CreatePicker() = 0; |
| 34 |
34 protected: | 35 protected: |
35 virtual ~PickerFactory() {} | 36 virtual ~PickerFactory() {} |
36 }; | 37 }; |
37 | 38 |
38 // Used to set PickerFactory used to create mock DesktopMediaPicker instances | 39 // Used to set PickerFactory used to create mock DesktopMediaPicker instances |
39 // for tests. Calling tests keep ownership of the factory. Can be called with | 40 // for tests. Calling tests keep ownership of the factory. Can be called with |
40 // |factory| set to NULL at the end of the test. | 41 // |factory| set to NULL at the end of the test. |
41 static void SetPickerFactoryForTests(PickerFactory* factory); | 42 static void SetPickerFactoryForTests(PickerFactory* factory); |
42 | 43 |
43 DesktopCaptureChooseDesktopMediaFunctionBase(); | 44 DesktopCaptureChooseDesktopMediaFunctionBase(); |
(...skipping 18 matching lines...) Expand all Loading... |
62 | 63 |
63 private: | 64 private: |
64 // content::WebContentsObserver overrides. | 65 // content::WebContentsObserver overrides. |
65 void WebContentsDestroyed() override; | 66 void WebContentsDestroyed() override; |
66 | 67 |
67 void OnPickerDialogResults(content::DesktopMediaID source); | 68 void OnPickerDialogResults(content::DesktopMediaID source); |
68 | 69 |
69 // URL of page that desktop capture was requested for. | 70 // URL of page that desktop capture was requested for. |
70 GURL origin_; | 71 GURL origin_; |
71 | 72 |
72 scoped_ptr<DesktopMediaPicker> picker_; | 73 std::unique_ptr<DesktopMediaPicker> picker_; |
73 }; | 74 }; |
74 | 75 |
75 class DesktopCaptureCancelChooseDesktopMediaFunctionBase | 76 class DesktopCaptureCancelChooseDesktopMediaFunctionBase |
76 : public ChromeSyncExtensionFunction { | 77 : public ChromeSyncExtensionFunction { |
77 public: | 78 public: |
78 DesktopCaptureCancelChooseDesktopMediaFunctionBase(); | 79 DesktopCaptureCancelChooseDesktopMediaFunctionBase(); |
79 | 80 |
80 protected: | 81 protected: |
81 ~DesktopCaptureCancelChooseDesktopMediaFunctionBase() override; | 82 ~DesktopCaptureCancelChooseDesktopMediaFunctionBase() override; |
82 | 83 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 std::map<RequestId, DesktopCaptureChooseDesktopMediaFunctionBase*>; | 116 std::map<RequestId, DesktopCaptureChooseDesktopMediaFunctionBase*>; |
116 | 117 |
117 RequestsMap requests_; | 118 RequestsMap requests_; |
118 | 119 |
119 DISALLOW_COPY_AND_ASSIGN(DesktopCaptureRequestsRegistry); | 120 DISALLOW_COPY_AND_ASSIGN(DesktopCaptureRequestsRegistry); |
120 }; | 121 }; |
121 | 122 |
122 } // namespace extensions | 123 } // namespace extensions |
123 | 124 |
124 #endif // CHROME_BROWSER_EXTENSIONS_API_DESKTOP_CAPTURE_DESKTOP_CAPTURE_BASE_H_ | 125 #endif // CHROME_BROWSER_EXTENSIONS_API_DESKTOP_CAPTURE_DESKTOP_CAPTURE_BASE_H_ |
OLD | NEW |