Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 2763743002: Android: not to pause screen capture when Chrome is put to background (Closed)
Patch Set: address nits Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after
2270 // We need to grab a pointer to the doomed WebView before we destroy it. 2271 // We need to grab a pointer to the doomed WebView before we destroy it.
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)
2281 RenderThreadImpl::current()->video_capture_impl_manager()-> 2282 SuspendVideoCaptureDevices(true);
2282 SuspendDevices(true); 2283 #if BUILDFLAG(ENABLE_WEBRTC)
2283 if (speech_recognition_dispatcher_) 2284 if (speech_recognition_dispatcher_)
2284 speech_recognition_dispatcher_->AbortAllRecognitions(); 2285 speech_recognition_dispatcher_->AbortAllRecognitions();
2285 #endif 2286 #endif
2287 #endif
2286 2288
2287 if (webview()) { 2289 if (webview()) {
2288 // TODO(lfg): It's not correct to defer the page visibility to the main 2290 // 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 2291 // frame. Currently, this is done because the main frame may override the
2290 // visibility of the page when prerendering. In order to fix this, 2292 // visibility of the page when prerendering. In order to fix this,
2291 // prerendering must be made aware of OOPIFs. https://crbug.com/440544 2293 // prerendering must be made aware of OOPIFs. https://crbug.com/440544
2292 blink::WebPageVisibilityState visibilityState = 2294 blink::WebPageVisibilityState visibilityState =
2293 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState() 2295 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState()
2294 : blink::WebPageVisibilityStateHidden; 2296 : blink::WebPageVisibilityStateHidden;
2295 webview()->setVisibilityState(visibilityState, false); 2297 webview()->setVisibilityState(visibilityState, false);
2296 } 2298 }
2297 } 2299 }
2298 2300
2299 void RenderViewImpl::OnPageWasShown() { 2301 void RenderViewImpl::OnPageWasShown() {
2300 #if defined(OS_ANDROID) && BUILDFLAG(ENABLE_WEBRTC) 2302 #if defined(OS_ANDROID)
2301 RenderThreadImpl::current()->video_capture_impl_manager()-> 2303 SuspendVideoCaptureDevices(false);
2302 SuspendDevices(false);
2303 #endif 2304 #endif
2304 2305
2305 if (webview()) { 2306 if (webview()) {
2306 blink::WebPageVisibilityState visibilityState = 2307 blink::WebPageVisibilityState visibilityState =
2307 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState() 2308 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState()
2308 : blink::WebPageVisibilityStateVisible; 2309 : blink::WebPageVisibilityStateVisible;
2309 webview()->setVisibilityState(visibilityState, false); 2310 webview()->setVisibilityState(visibilityState, false);
2310 } 2311 }
2311 } 2312 }
2312 2313
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
2561 handled = true; 2562 handled = true;
2562 break; 2563 break;
2563 } 2564 }
2564 case TAP_MULTIPLE_TARGETS_STRATEGY_NONE: 2565 case TAP_MULTIPLE_TARGETS_STRATEGY_NONE:
2565 // No-op. 2566 // No-op.
2566 break; 2567 break;
2567 } 2568 }
2568 2569
2569 return handled; 2570 return handled;
2570 } 2571 }
2572
2573 void RenderViewImpl::SuspendVideoCaptureDevices(bool suspend) {
2574 if (!main_render_frame_)
2575 return;
2576
2577 MediaStreamDispatcher* media_stream_dispatcher =
2578 main_render_frame_->GetMediaStreamDispatcher();
2579 if (!media_stream_dispatcher)
2580 return;
2581
2582 StreamDeviceInfoArray video_array =
2583 media_stream_dispatcher->GetNonScreenCaptureDevices();
2584 RenderThreadImpl::current()->video_capture_impl_manager()->SuspendDevices(
2585 video_array, suspend);
2586 }
2571 #endif // defined(OS_ANDROID) 2587 #endif // defined(OS_ANDROID)
2572 2588
2573 unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const { 2589 unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const {
2574 return history_list_length_; 2590 return history_list_length_;
2575 } 2591 }
2576 2592
2577 void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) { 2593 void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) {
2578 if (enable) { 2594 if (enable) {
2579 if (has_focus()) 2595 if (has_focus())
2580 return; 2596 return;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2712 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2728 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2713 } 2729 }
2714 2730
2715 std::unique_ptr<InputEventAck> ack( 2731 std::unique_ptr<InputEventAck> ack(
2716 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type(), 2732 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type(),
2717 INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); 2733 INPUT_EVENT_ACK_STATE_NOT_CONSUMED));
2718 OnInputEventAck(std::move(ack)); 2734 OnInputEventAck(std::move(ack));
2719 } 2735 }
2720 2736
2721 } // namespace content 2737 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698