OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include <queue> | 5 #include <queue> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "chrome/browser/extensions/api/desktop_capture/desktop_capture_api.h" | 10 #include "chrome/browser/extensions/api/desktop_capture/desktop_capture_api.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 : source_(source), | 31 : source_(source), |
32 expect_cancelled_(expect_cancelled), | 32 expect_cancelled_(expect_cancelled), |
33 weak_factory_(this) { | 33 weak_factory_(this) { |
34 } | 34 } |
35 virtual ~FakeDesktopMediaPicker() {} | 35 virtual ~FakeDesktopMediaPicker() {} |
36 | 36 |
37 // DesktopMediaPicker interface. | 37 // DesktopMediaPicker interface. |
38 virtual void Show(gfx::NativeWindow context, | 38 virtual void Show(gfx::NativeWindow context, |
39 gfx::NativeWindow parent, | 39 gfx::NativeWindow parent, |
40 const string16& app_name, | 40 const string16& app_name, |
41 scoped_ptr<DesktopMediaPickerModel> model, | 41 scoped_ptr<DesktopMediaList> model, |
42 const DoneCallback& done_callback) OVERRIDE { | 42 const DoneCallback& done_callback) OVERRIDE { |
43 if (!expect_cancelled_) { | 43 if (!expect_cancelled_) { |
44 // Post a task to call the callback asynchronously. | 44 // Post a task to call the callback asynchronously. |
45 base::ThreadTaskRunnerHandle::Get()->PostTask( | 45 base::ThreadTaskRunnerHandle::Get()->PostTask( |
46 FROM_HERE, | 46 FROM_HERE, |
47 base::Bind(&FakeDesktopMediaPicker::CallCallback, | 47 base::Bind(&FakeDesktopMediaPicker::CallCallback, |
48 weak_factory_.GetWeakPtr(), done_callback)); | 48 weak_factory_.GetWeakPtr(), done_callback)); |
49 } else { | 49 } else { |
50 // If we expect the dialog to be canceled then store the callback to | 50 // If we expect the dialog to be canceled then store the callback to |
51 // retain reference to the callback handler. | 51 // retain reference to the callback handler. |
(...skipping 28 matching lines...) Expand all Loading... |
80 FakeDesktopMediaPickerFactory() {} | 80 FakeDesktopMediaPickerFactory() {} |
81 virtual ~FakeDesktopMediaPickerFactory() {} | 81 virtual ~FakeDesktopMediaPickerFactory() {} |
82 | 82 |
83 void SetExpectations(const Expectation* expectation_array, int size) { | 83 void SetExpectations(const Expectation* expectation_array, int size) { |
84 for (int i = 0; i < size; ++i) { | 84 for (int i = 0; i < size; ++i) { |
85 expectations_.push(expectation_array[i]); | 85 expectations_.push(expectation_array[i]); |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 // DesktopCaptureChooseDesktopMediaFunction::PickerFactory interface. | 89 // DesktopCaptureChooseDesktopMediaFunction::PickerFactory interface. |
90 virtual scoped_ptr<DesktopMediaPickerModel> CreateModel( | 90 virtual scoped_ptr<DesktopMediaList> CreateModel( |
91 scoped_ptr<webrtc::ScreenCapturer> screen_capturer, | 91 scoped_ptr<webrtc::ScreenCapturer> screen_capturer, |
92 scoped_ptr<webrtc::WindowCapturer> window_capturer) OVERRIDE { | 92 scoped_ptr<webrtc::WindowCapturer> window_capturer) OVERRIDE { |
93 EXPECT_TRUE(!expectations_.empty()); | 93 EXPECT_TRUE(!expectations_.empty()); |
94 if (!expectations_.empty()) { | 94 if (!expectations_.empty()) { |
95 EXPECT_EQ(expectations_.front().screens, !!screen_capturer.get()); | 95 EXPECT_EQ(expectations_.front().screens, !!screen_capturer.get()); |
96 EXPECT_EQ(expectations_.front().windows, !!window_capturer.get()); | 96 EXPECT_EQ(expectations_.front().windows, !!window_capturer.get()); |
97 } | 97 } |
98 return scoped_ptr<DesktopMediaPickerModel>( | 98 return scoped_ptr<DesktopMediaList>(new NativeDesktopMediaList( |
99 new DesktopMediaPickerModelImpl(screen_capturer.Pass(), | 99 screen_capturer.Pass(), window_capturer.Pass())); |
100 window_capturer.Pass())); | |
101 } | 100 } |
102 virtual scoped_ptr<DesktopMediaPicker> CreatePicker() OVERRIDE { | 101 virtual scoped_ptr<DesktopMediaPicker> CreatePicker() OVERRIDE { |
103 content::DesktopMediaID next_source; | 102 content::DesktopMediaID next_source; |
104 bool expect_cancelled = false; | 103 bool expect_cancelled = false; |
105 if (!expectations_.empty()) { | 104 if (!expectations_.empty()) { |
106 next_source = expectations_.front().selected_source; | 105 next_source = expectations_.front().selected_source; |
107 expect_cancelled = expectations_.front().cancelled; | 106 expect_cancelled = expectations_.front().cancelled; |
108 expectations_.pop(); | 107 expectations_.pop(); |
109 } | 108 } |
110 return scoped_ptr<DesktopMediaPicker>( | 109 return scoped_ptr<DesktopMediaPicker>( |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 "getStream()", &result)); | 215 "getStream()", &result)); |
217 EXPECT_TRUE(result); | 216 EXPECT_TRUE(result); |
218 | 217 |
219 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 218 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
220 browser()->tab_strip_model()->GetActiveWebContents(), | 219 browser()->tab_strip_model()->GetActiveWebContents(), |
221 "getStreamWithInvalidId()", &result)); | 220 "getStreamWithInvalidId()", &result)); |
222 EXPECT_TRUE(result); | 221 EXPECT_TRUE(result); |
223 } | 222 } |
224 | 223 |
225 } // namespace extensions | 224 } // namespace extensions |
OLD | NEW |