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/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <utility> | 10 #include <utility> |
(...skipping 2582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2593 return nullptr; | 2593 return nullptr; |
2594 | 2594 |
2595 return guest->GetMainFrame(); | 2595 return guest->GetMainFrame(); |
2596 } | 2596 } |
2597 | 2597 |
2598 device::GeolocationServiceContext* | 2598 device::GeolocationServiceContext* |
2599 WebContentsImpl::GetGeolocationServiceContext() { | 2599 WebContentsImpl::GetGeolocationServiceContext() { |
2600 return geolocation_service_context_.get(); | 2600 return geolocation_service_context_.get(); |
2601 } | 2601 } |
2602 | 2602 |
2603 device::mojom::WakeLockContext* WebContentsImpl::GetWakeLockServiceContext() { | 2603 device::mojom::WakeLockContext* WebContentsImpl::GetWakeLockContext() { |
2604 if (!wake_lock_context_host_) | 2604 if (!wake_lock_context_host_) |
2605 wake_lock_context_host_.reset(new WakeLockContextHost(this)); | 2605 wake_lock_context_host_.reset(new WakeLockContextHost(this)); |
2606 return wake_lock_context_host_->GetWakeLockContext(); | 2606 return wake_lock_context_host_->GetWakeLockContext(); |
2607 } | 2607 } |
2608 | 2608 |
| 2609 void WebContentsImpl::ConnectToBlinkWakeLock( |
| 2610 device::mojom::WakeLockServiceRequest request) { |
| 2611 // WebContents creates a long-lived connection to one WakeLockServiceImpl. |
| 2612 // All the frames' requests are added into the BindingSet of |
| 2613 // WakeLockServiceImpl via this connection. |
| 2614 if (!blink_wake_lock_) { |
| 2615 device::mojom::WakeLockContext* wake_lock_context = GetWakeLockContext(); |
| 2616 if (!wake_lock_context) { |
| 2617 return; |
| 2618 } |
| 2619 wake_lock_context->GetWakeLock( |
| 2620 device::PowerSaveBlocker::PowerSaveBlockerType:: |
| 2621 kPowerSaveBlockPreventDisplaySleep, |
| 2622 device::PowerSaveBlocker::Reason::kReasonOther, "Wake Lock API", |
| 2623 mojo::MakeRequest(&blink_wake_lock_)); |
| 2624 } |
| 2625 blink_wake_lock_->AddClient(std::move(request)); |
| 2626 } |
| 2627 |
2609 void WebContentsImpl::OnShowValidationMessage( | 2628 void WebContentsImpl::OnShowValidationMessage( |
2610 RenderViewHostImpl* source, | 2629 RenderViewHostImpl* source, |
2611 const gfx::Rect& anchor_in_root_view, | 2630 const gfx::Rect& anchor_in_root_view, |
2612 const base::string16& main_text, | 2631 const base::string16& main_text, |
2613 const base::string16& sub_text) { | 2632 const base::string16& sub_text) { |
2614 // TODO(nick): Should we consider |source| here or pass it to the delegate? | 2633 // TODO(nick): Should we consider |source| here or pass it to the delegate? |
2615 if (delegate_) | 2634 if (delegate_) |
2616 delegate_->ShowValidationMessage( | 2635 delegate_->ShowValidationMessage( |
2617 this, anchor_in_root_view, main_text, sub_text); | 2636 this, anchor_in_root_view, main_text, sub_text); |
2618 } | 2637 } |
(...skipping 2955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5574 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); | 5593 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); |
5575 if (!render_view_host) | 5594 if (!render_view_host) |
5576 continue; | 5595 continue; |
5577 render_view_host_set.insert(render_view_host); | 5596 render_view_host_set.insert(render_view_host); |
5578 } | 5597 } |
5579 for (RenderViewHost* render_view_host : render_view_host_set) | 5598 for (RenderViewHost* render_view_host : render_view_host_set) |
5580 render_view_host->OnWebkitPreferencesChanged(); | 5599 render_view_host->OnWebkitPreferencesChanged(); |
5581 } | 5600 } |
5582 | 5601 |
5583 } // namespace content | 5602 } // namespace content |
OLD | NEW |