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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } | 47 } |
48 | 48 |
49 // DesktopMediaPicker interface. | 49 // DesktopMediaPicker interface. |
50 virtual void Show(content::WebContents* web_contents, | 50 virtual void Show(content::WebContents* web_contents, |
51 gfx::NativeWindow context, | 51 gfx::NativeWindow context, |
52 gfx::NativeWindow parent, | 52 gfx::NativeWindow parent, |
53 const base::string16& app_name, | 53 const base::string16& app_name, |
54 const base::string16& target_name, | 54 const base::string16& target_name, |
55 scoped_ptr<DesktopMediaList> model, | 55 scoped_ptr<DesktopMediaList> model, |
56 const DoneCallback& done_callback) OVERRIDE { | 56 const DoneCallback& done_callback) OVERRIDE { |
57 if (!expectation_->cancelled) { | 57 EXPECT_TRUE(web_contents); |
| 58 if (!expectation_->cancelled || !web_contents) { |
58 // Post a task to call the callback asynchronously. | 59 // Post a task to call the callback asynchronously. |
59 base::ThreadTaskRunnerHandle::Get()->PostTask( | 60 base::ThreadTaskRunnerHandle::Get()->PostTask( |
60 FROM_HERE, | 61 FROM_HERE, |
61 base::Bind(&FakeDesktopMediaPicker::CallCallback, | 62 base::Bind(&FakeDesktopMediaPicker::CallCallback, |
62 weak_factory_.GetWeakPtr(), done_callback)); | 63 weak_factory_.GetWeakPtr(), done_callback)); |
63 } else { | 64 } else { |
64 // If we expect the dialog to be cancelled then store the callback to | 65 // If we expect the dialog to be cancelled then store the callback to |
65 // retain reference to the callback handler. | 66 // retain reference to the callback handler. |
66 done_callback_ = done_callback; | 67 done_callback_ = done_callback; |
67 } | 68 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 EXPECT_TRUE(result); | 235 EXPECT_TRUE(result); |
235 EXPECT_TRUE(test_flags[2].picker_created); | 236 EXPECT_TRUE(test_flags[2].picker_created); |
236 EXPECT_FALSE(test_flags[2].picker_deleted); | 237 EXPECT_FALSE(test_flags[2].picker_deleted); |
237 | 238 |
238 web_contents->Close(); | 239 web_contents->Close(); |
239 destroyed_watcher.Wait(); | 240 destroyed_watcher.Wait(); |
240 EXPECT_TRUE(test_flags[2].picker_deleted); | 241 EXPECT_TRUE(test_flags[2].picker_deleted); |
241 } | 242 } |
242 | 243 |
243 } // namespace extensions | 244 } // namespace extensions |
OLD | NEW |