| 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 "chrome/browser/media/native_desktop_media_list.h" | 5 #include "chrome/browser/media/native_desktop_media_list.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "chrome/browser/media/desktop_media_list_observer.h" | 10 #include "chrome/browser/media/desktop_media_list_observer.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 MOCK_METHOD1(OnSourceNameChanged, void(int index)); | 28 MOCK_METHOD1(OnSourceNameChanged, void(int index)); |
| 29 MOCK_METHOD1(OnSourceThumbnailChanged, void(int index)); | 29 MOCK_METHOD1(OnSourceThumbnailChanged, void(int index)); |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 class FakeScreenCapturer : public webrtc::ScreenCapturer { | 32 class FakeScreenCapturer : public webrtc::ScreenCapturer { |
| 33 public: | 33 public: |
| 34 FakeScreenCapturer() {} | 34 FakeScreenCapturer() {} |
| 35 virtual ~FakeScreenCapturer() {} | 35 virtual ~FakeScreenCapturer() {} |
| 36 | 36 |
| 37 // webrtc::ScreenCapturer implementation. | 37 // webrtc::ScreenCapturer implementation. |
| 38 virtual void Start(Callback* callback) OVERRIDE { | 38 virtual void Start(Callback* callback) override { |
| 39 callback_ = callback; | 39 callback_ = callback; |
| 40 } | 40 } |
| 41 | 41 |
| 42 virtual void Capture(const webrtc::DesktopRegion& region) OVERRIDE { | 42 virtual void Capture(const webrtc::DesktopRegion& region) override { |
| 43 DCHECK(callback_); | 43 DCHECK(callback_); |
| 44 webrtc::DesktopFrame* frame = | 44 webrtc::DesktopFrame* frame = |
| 45 new webrtc::BasicDesktopFrame(webrtc::DesktopSize(10, 10)); | 45 new webrtc::BasicDesktopFrame(webrtc::DesktopSize(10, 10)); |
| 46 memset(frame->data(), 0, frame->stride() * frame->size().height()); | 46 memset(frame->data(), 0, frame->stride() * frame->size().height()); |
| 47 callback_->OnCaptureCompleted(frame); | 47 callback_->OnCaptureCompleted(frame); |
| 48 } | 48 } |
| 49 | 49 |
| 50 virtual void SetMouseShapeObserver( | 50 virtual void SetMouseShapeObserver( |
| 51 MouseShapeObserver* mouse_shape_observer) OVERRIDE { | 51 MouseShapeObserver* mouse_shape_observer) override { |
| 52 NOTIMPLEMENTED(); | 52 NOTIMPLEMENTED(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 virtual bool GetScreenList(ScreenList* screens) OVERRIDE { | 55 virtual bool GetScreenList(ScreenList* screens) override { |
| 56 webrtc::ScreenCapturer::Screen screen; | 56 webrtc::ScreenCapturer::Screen screen; |
| 57 screen.id = 0; | 57 screen.id = 0; |
| 58 screens->push_back(screen); | 58 screens->push_back(screen); |
| 59 return true; | 59 return true; |
| 60 } | 60 } |
| 61 | 61 |
| 62 virtual bool SelectScreen(webrtc::ScreenId id) OVERRIDE { | 62 virtual bool SelectScreen(webrtc::ScreenId id) override { |
| 63 EXPECT_EQ(0, id); | 63 EXPECT_EQ(0, id); |
| 64 return true; | 64 return true; |
| 65 } | 65 } |
| 66 | 66 |
| 67 protected: | 67 protected: |
| 68 Callback* callback_; | 68 Callback* callback_; |
| 69 | 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(FakeScreenCapturer); | 70 DISALLOW_COPY_AND_ASSIGN(FakeScreenCapturer); |
| 71 }; | 71 }; |
| 72 | 72 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 83 } | 83 } |
| 84 | 84 |
| 85 // Sets |value| thats going to be used to memset() content of the frames | 85 // Sets |value| thats going to be used to memset() content of the frames |
| 86 // generated for |window_id|. By default generated frames are set to zeros. | 86 // generated for |window_id|. By default generated frames are set to zeros. |
| 87 void SetNextFrameValue(WindowId window_id, int8_t value) { | 87 void SetNextFrameValue(WindowId window_id, int8_t value) { |
| 88 base::AutoLock lock(frame_values_lock_); | 88 base::AutoLock lock(frame_values_lock_); |
| 89 frame_values_[window_id] = value; | 89 frame_values_[window_id] = value; |
| 90 } | 90 } |
| 91 | 91 |
| 92 // webrtc::WindowCapturer implementation. | 92 // webrtc::WindowCapturer implementation. |
| 93 virtual void Start(Callback* callback) OVERRIDE { | 93 virtual void Start(Callback* callback) override { |
| 94 callback_ = callback; | 94 callback_ = callback; |
| 95 } | 95 } |
| 96 | 96 |
| 97 virtual void Capture(const webrtc::DesktopRegion& region) OVERRIDE { | 97 virtual void Capture(const webrtc::DesktopRegion& region) override { |
| 98 DCHECK(callback_); | 98 DCHECK(callback_); |
| 99 | 99 |
| 100 base::AutoLock lock(frame_values_lock_); | 100 base::AutoLock lock(frame_values_lock_); |
| 101 | 101 |
| 102 std::map<WindowId, int8_t>::iterator it = | 102 std::map<WindowId, int8_t>::iterator it = |
| 103 frame_values_.find(selected_window_id_); | 103 frame_values_.find(selected_window_id_); |
| 104 int8_t value = (it != frame_values_.end()) ? it->second : 0; | 104 int8_t value = (it != frame_values_.end()) ? it->second : 0; |
| 105 webrtc::DesktopFrame* frame = | 105 webrtc::DesktopFrame* frame = |
| 106 new webrtc::BasicDesktopFrame(webrtc::DesktopSize(10, 10)); | 106 new webrtc::BasicDesktopFrame(webrtc::DesktopSize(10, 10)); |
| 107 memset(frame->data(), value, frame->stride() * frame->size().height()); | 107 memset(frame->data(), value, frame->stride() * frame->size().height()); |
| 108 callback_->OnCaptureCompleted(frame); | 108 callback_->OnCaptureCompleted(frame); |
| 109 } | 109 } |
| 110 | 110 |
| 111 virtual bool GetWindowList(WindowList* windows) OVERRIDE { | 111 virtual bool GetWindowList(WindowList* windows) override { |
| 112 base::AutoLock lock(window_list_lock_); | 112 base::AutoLock lock(window_list_lock_); |
| 113 *windows = window_list_; | 113 *windows = window_list_; |
| 114 return true; | 114 return true; |
| 115 } | 115 } |
| 116 | 116 |
| 117 virtual bool SelectWindow(WindowId id) OVERRIDE { | 117 virtual bool SelectWindow(WindowId id) override { |
| 118 selected_window_id_ = id; | 118 selected_window_id_ = id; |
| 119 return true; | 119 return true; |
| 120 } | 120 } |
| 121 | 121 |
| 122 virtual bool BringSelectedWindowToFront() OVERRIDE { | 122 virtual bool BringSelectedWindowToFront() override { |
| 123 return true; | 123 return true; |
| 124 } | 124 } |
| 125 | 125 |
| 126 private: | 126 private: |
| 127 Callback* callback_; | 127 Callback* callback_; |
| 128 WindowList window_list_; | 128 WindowList window_list_; |
| 129 base::Lock window_list_lock_; | 129 base::Lock window_list_lock_; |
| 130 | 130 |
| 131 WindowId selected_window_id_; | 131 WindowId selected_window_id_; |
| 132 | 132 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 // Swap the two windows. | 353 // Swap the two windows. |
| 354 webrtc::WindowCapturer::Window temp = list[0]; | 354 webrtc::WindowCapturer::Window temp = list[0]; |
| 355 list[0] = list[1]; | 355 list[0] = list[1]; |
| 356 list[1] = temp; | 356 list[1] = temp; |
| 357 window_capturer_->SetWindowList(list); | 357 window_capturer_->SetWindowList(list); |
| 358 | 358 |
| 359 message_loop_.Run(); | 359 message_loop_.Run(); |
| 360 } | 360 } |
| 361 | 361 |
| 362 } // namespace | 362 } // namespace |
| OLD | NEW |