Chromium Code Reviews| 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 #include "content/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 77 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
| 78 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" | 78 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
| 79 #include "content/renderer/drop_data_builder.h" | 79 #include "content/renderer/drop_data_builder.h" |
| 80 #include "content/renderer/gpu/render_widget_compositor.h" | 80 #include "content/renderer/gpu/render_widget_compositor.h" |
| 81 #include "content/renderer/history_serialization.h" | 81 #include "content/renderer/history_serialization.h" |
| 82 #include "content/renderer/idle_user_detector.h" | 82 #include "content/renderer/idle_user_detector.h" |
| 83 #include "content/renderer/ime_event_guard.h" | 83 #include "content/renderer/ime_event_guard.h" |
| 84 #include "content/renderer/input/input_handler_manager.h" | 84 #include "content/renderer/input/input_handler_manager.h" |
| 85 #include "content/renderer/internal_document_state_data.h" | 85 #include "content/renderer/internal_document_state_data.h" |
| 86 #include "content/renderer/media/audio_device_factory.h" | 86 #include "content/renderer/media/audio_device_factory.h" |
| 87 #include "content/renderer/media/media_stream_dispatcher.h" | |
| 87 #include "content/renderer/media/video_capture_impl_manager.h" | 88 #include "content/renderer/media/video_capture_impl_manager.h" |
| 88 #include "content/renderer/navigation_state_impl.h" | 89 #include "content/renderer/navigation_state_impl.h" |
| 89 #include "content/renderer/render_frame_impl.h" | 90 #include "content/renderer/render_frame_impl.h" |
| 90 #include "content/renderer/render_frame_proxy.h" | 91 #include "content/renderer/render_frame_proxy.h" |
| 91 #include "content/renderer/render_process.h" | 92 #include "content/renderer/render_process.h" |
| 92 #include "content/renderer/render_thread_impl.h" | 93 #include "content/renderer/render_thread_impl.h" |
| 93 #include "content/renderer/render_widget_fullscreen_pepper.h" | 94 #include "content/renderer/render_widget_fullscreen_pepper.h" |
| 94 #include "content/renderer/renderer_webapplicationcachehost_impl.h" | 95 #include "content/renderer/renderer_webapplicationcachehost_impl.h" |
| 95 #include "content/renderer/resizing_mode_selector.h" | 96 #include "content/renderer/resizing_mode_selector.h" |
| 96 #include "content/renderer/savable_resources.h" | 97 #include "content/renderer/savable_resources.h" |
| (...skipping 2174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2271 WebView* doomed = webview_; | 2272 WebView* doomed = webview_; |
| 2272 RenderWidget::Close(); | 2273 RenderWidget::Close(); |
| 2273 webview_ = nullptr; | 2274 webview_ = nullptr; |
| 2274 g_view_map.Get().erase(doomed); | 2275 g_view_map.Get().erase(doomed); |
| 2275 g_routing_id_view_map.Get().erase(GetRoutingID()); | 2276 g_routing_id_view_map.Get().erase(GetRoutingID()); |
| 2276 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID())); | 2277 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID())); |
| 2277 } | 2278 } |
| 2278 | 2279 |
| 2279 void RenderViewImpl::OnPageWasHidden() { | 2280 void RenderViewImpl::OnPageWasHidden() { |
| 2280 #if defined(OS_ANDROID) && BUILDFLAG(ENABLE_WEBRTC) | 2281 #if defined(OS_ANDROID) && BUILDFLAG(ENABLE_WEBRTC) |
| 2281 RenderThreadImpl::current()->video_capture_impl_manager()-> | 2282 SuspendVideoCaptureDevices(true); |
| 2282 SuspendDevices(true); | 2283 |
| 2283 if (speech_recognition_dispatcher_) | 2284 if (speech_recognition_dispatcher_) |
| 2284 speech_recognition_dispatcher_->AbortAllRecognitions(); | 2285 speech_recognition_dispatcher_->AbortAllRecognitions(); |
| 2285 #endif | 2286 #endif |
| 2286 | 2287 |
| 2287 if (webview()) { | 2288 if (webview()) { |
| 2288 // TODO(lfg): It's not correct to defer the page visibility to the main | 2289 // TODO(lfg): It's not correct to defer the page visibility to the main |
| 2289 // frame. Currently, this is done because the main frame may override the | 2290 // frame. Currently, this is done because the main frame may override the |
| 2290 // visibility of the page when prerendering. In order to fix this, | 2291 // visibility of the page when prerendering. In order to fix this, |
| 2291 // prerendering must be made aware of OOPIFs. https://crbug.com/440544 | 2292 // prerendering must be made aware of OOPIFs. https://crbug.com/440544 |
| 2292 blink::WebPageVisibilityState visibilityState = | 2293 blink::WebPageVisibilityState visibilityState = |
| 2293 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState() | 2294 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState() |
| 2294 : blink::WebPageVisibilityStateHidden; | 2295 : blink::WebPageVisibilityStateHidden; |
| 2295 webview()->setVisibilityState(visibilityState, false); | 2296 webview()->setVisibilityState(visibilityState, false); |
| 2296 } | 2297 } |
| 2297 } | 2298 } |
| 2298 | 2299 |
| 2299 void RenderViewImpl::OnPageWasShown() { | 2300 void RenderViewImpl::OnPageWasShown() { |
| 2300 #if defined(OS_ANDROID) && BUILDFLAG(ENABLE_WEBRTC) | 2301 #if defined(OS_ANDROID) && BUILDFLAG(ENABLE_WEBRTC) |
| 2301 RenderThreadImpl::current()->video_capture_impl_manager()-> | 2302 SuspendVideoCaptureDevices(false); |
| 2302 SuspendDevices(false); | |
| 2303 #endif | 2303 #endif |
| 2304 | 2304 |
| 2305 if (webview()) { | 2305 if (webview()) { |
| 2306 blink::WebPageVisibilityState visibilityState = | 2306 blink::WebPageVisibilityState visibilityState = |
| 2307 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState() | 2307 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState() |
| 2308 : blink::WebPageVisibilityStateVisible; | 2308 : blink::WebPageVisibilityStateVisible; |
| 2309 webview()->setVisibilityState(visibilityState, false); | 2309 webview()->setVisibilityState(visibilityState, false); |
| 2310 } | 2310 } |
| 2311 } | 2311 } |
| 2312 | 2312 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2561 handled = true; | 2561 handled = true; |
| 2562 break; | 2562 break; |
| 2563 } | 2563 } |
| 2564 case TAP_MULTIPLE_TARGETS_STRATEGY_NONE: | 2564 case TAP_MULTIPLE_TARGETS_STRATEGY_NONE: |
| 2565 // No-op. | 2565 // No-op. |
| 2566 break; | 2566 break; |
| 2567 } | 2567 } |
| 2568 | 2568 |
| 2569 return handled; | 2569 return handled; |
| 2570 } | 2570 } |
| 2571 | |
| 2572 void RenderViewImpl::SuspendVideoCaptureDevices(bool suspend) { | |
|
tommi (sloooow) - chröme
2017/03/21 09:21:17
can we have a thread check for this function?
braveyao
2017/03/22 00:45:33
There is no thread check yet in this file. Add thr
miu
2017/03/22 23:09:42
IMHO, it's not necessary: I think it's generally-k
braveyao
2017/03/23 03:44:19
Acknowledged.
| |
| 2573 if (!main_render_frame_) | |
| 2574 return; | |
| 2575 | |
| 2576 MediaStreamDispatcher* media_stream_dispatcher = | |
| 2577 main_render_frame_->GetMediaStreamDispatcher(); | |
| 2578 if (media_stream_dispatcher) { | |
|
tommi (sloooow) - chröme
2017/03/21 09:21:18
Could GetMediaStreamDispatcher() ever return null
braveyao
2017/03/22 00:45:33
Just the codes[1] shows there is such possibility.
| |
| 2579 StreamDeviceInfoArray video_array; | |
| 2580 media_stream_dispatcher->GetVideoCaptureDevices(video_array); | |
| 2581 for (const StreamDeviceInfo& device_it : video_array) { | |
|
tommi (sloooow) - chröme
2017/03/21 09:21:17
|device_it| isn't correct. Suggest |device_info| i
braveyao
2017/03/22 00:45:33
Done.
| |
| 2582 if (suspend) | |
|
tommi (sloooow) - chröme
2017/03/21 09:21:17
use {} as per coding guidelines
braveyao
2017/03/22 00:45:33
Done.
| |
| 2583 RenderThreadImpl::current()->video_capture_impl_manager()->Suspend( | |
| 2584 device_it.session_id); | |
| 2585 else | |
| 2586 RenderThreadImpl::current()->video_capture_impl_manager()->Resume( | |
| 2587 device_it.session_id); | |
| 2588 } | |
| 2589 } | |
| 2590 } | |
| 2571 #endif // defined(OS_ANDROID) | 2591 #endif // defined(OS_ANDROID) |
| 2572 | 2592 |
| 2573 unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const { | 2593 unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const { |
| 2574 return history_list_length_; | 2594 return history_list_length_; |
| 2575 } | 2595 } |
| 2576 | 2596 |
| 2577 void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) { | 2597 void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) { |
| 2578 if (enable) { | 2598 if (enable) { |
| 2579 if (has_focus()) | 2599 if (has_focus()) |
| 2580 return; | 2600 return; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2712 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2732 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2713 } | 2733 } |
| 2714 | 2734 |
| 2715 std::unique_ptr<InputEventAck> ack( | 2735 std::unique_ptr<InputEventAck> ack( |
| 2716 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type(), | 2736 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type(), |
| 2717 INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); | 2737 INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); |
| 2718 OnInputEventAck(std::move(ack)); | 2738 OnInputEventAck(std::move(ack)); |
| 2719 } | 2739 } |
| 2720 | 2740 |
| 2721 } // namespace content | 2741 } // namespace content |
| OLD | NEW |