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

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 2734943003: Device Service: Decouple Wake Lock from //content (Closed)
Patch Set: Bugfix Created 3 years, 9 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
OLDNEW
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 "content/browser/frame_host/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 #include "content/public/common/file_chooser_file_info.h" 89 #include "content/public/common/file_chooser_file_info.h"
90 #include "content/public/common/file_chooser_params.h" 90 #include "content/public/common/file_chooser_params.h"
91 #include "content/public/common/isolated_world_ids.h" 91 #include "content/public/common/isolated_world_ids.h"
92 #include "content/public/common/service_manager_connection.h" 92 #include "content/public/common/service_manager_connection.h"
93 #include "content/public/common/service_names.mojom.h" 93 #include "content/public/common/service_names.mojom.h"
94 #include "content/public/common/url_constants.h" 94 #include "content/public/common/url_constants.h"
95 #include "content/public/common/url_utils.h" 95 #include "content/public/common/url_utils.h"
96 #include "device/generic_sensor/sensor_provider_impl.h" 96 #include "device/generic_sensor/sensor_provider_impl.h"
97 #include "device/geolocation/geolocation_service_context.h" 97 #include "device/geolocation/geolocation_service_context.h"
98 #include "device/vibration/vibration_manager_impl.h" 98 #include "device/vibration/vibration_manager_impl.h"
99 #include "device/wake_lock/wake_lock_service_context.h" 99 #include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h"
100 #include "device/wake_lock/public/interfaces/wake_lock_service_context.mojom.h"
100 #include "media/base/media_switches.h" 101 #include "media/base/media_switches.h"
101 #include "media/media_features.h" 102 #include "media/media_features.h"
102 #include "media/mojo/interfaces/media_service.mojom.h" 103 #include "media/mojo/interfaces/media_service.mojom.h"
103 #include "media/mojo/interfaces/remoting.mojom.h" 104 #include "media/mojo/interfaces/remoting.mojom.h"
104 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" 105 #include "mojo/public/cpp/bindings/associated_interface_ptr.h"
105 #include "mojo/public/cpp/bindings/strong_binding.h" 106 #include "mojo/public/cpp/bindings/strong_binding.h"
106 #include "services/service_manager/public/cpp/connector.h" 107 #include "services/service_manager/public/cpp/connector.h"
107 #include "services/service_manager/public/cpp/interface_provider.h" 108 #include "services/service_manager/public/cpp/interface_provider.h"
108 #include "ui/accessibility/ax_tree.h" 109 #include "ui/accessibility/ax_tree.h"
109 #include "ui/accessibility/ax_tree_id_registry.h" 110 #include "ui/accessibility/ax_tree_id_registry.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 case blink::WebTextDirectionLeftToRight: 160 case blink::WebTextDirectionLeftToRight:
160 return base::i18n::LEFT_TO_RIGHT; 161 return base::i18n::LEFT_TO_RIGHT;
161 case blink::WebTextDirectionRightToLeft: 162 case blink::WebTextDirectionRightToLeft:
162 return base::i18n::RIGHT_TO_LEFT; 163 return base::i18n::RIGHT_TO_LEFT;
163 default: 164 default:
164 NOTREACHED(); 165 NOTREACHED();
165 return base::i18n::UNKNOWN_DIRECTION; 166 return base::i18n::UNKNOWN_DIRECTION;
166 } 167 }
167 } 168 }
168 169
170 void BindWakeLockRequest(device::mojom::WakeLockServiceContext* context,
171 device::mojom::WakeLockServiceRequest request) {
172 context->BindWakeLock(std::move(request));
173 }
174
169 // Ensure that we reset nav_entry_id_ in OnDidCommitProvisionalLoad if any of 175 // Ensure that we reset nav_entry_id_ in OnDidCommitProvisionalLoad if any of
170 // the validations fail and lead to an early return. Call disable() once we 176 // the validations fail and lead to an early return. Call disable() once we
171 // know the commit will be successful. Resetting nav_entry_id_ avoids acting on 177 // know the commit will be successful. Resetting nav_entry_id_ avoids acting on
172 // any UpdateState or UpdateTitle messages after an ignored commit. 178 // any UpdateState or UpdateTitle messages after an ignored commit.
173 class ScopedCommitStateResetter { 179 class ScopedCommitStateResetter {
174 public: 180 public:
175 explicit ScopedCommitStateResetter(RenderFrameHostImpl* render_frame_host) 181 explicit ScopedCommitStateResetter(RenderFrameHostImpl* render_frame_host)
176 : render_frame_host_(render_frame_host), disabled_(false) {} 182 : render_frame_host_(render_frame_host), disabled_(false) {}
177 183
178 ~ScopedCommitStateResetter() { 184 ~ScopedCommitStateResetter() {
(...skipping 2103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2282 // this object and destruction of any GeolocationServicesImpls created via 2288 // this object and destruction of any GeolocationServicesImpls created via
2283 // the below service registry, the reason being that the destruction of the 2289 // the below service registry, the reason being that the destruction of the
2284 // latter is triggered by receiving a message that the pipe was closed from 2290 // latter is triggered by receiving a message that the pipe was closed from
2285 // the renderer side. Hence, supply the reference to this object as a weak 2291 // the renderer side. Hence, supply the reference to this object as a weak
2286 // pointer. 2292 // pointer.
2287 GetInterfaceRegistry()->AddInterface( 2293 GetInterfaceRegistry()->AddInterface(
2288 base::Bind(&device::GeolocationServiceContext::CreateService, 2294 base::Bind(&device::GeolocationServiceContext::CreateService,
2289 base::Unretained(geolocation_service_context))); 2295 base::Unretained(geolocation_service_context)));
2290 } 2296 }
2291 2297
2292 device::WakeLockServiceContext* wake_lock_service_context = 2298 device::mojom::WakeLockServiceContext* wake_lock_service_context =
2293 delegate_ ? delegate_->GetWakeLockServiceContext() : nullptr; 2299 delegate_ ? delegate_->GetWakeLockServiceContext() : nullptr;
2294 if (wake_lock_service_context) { 2300 if (wake_lock_service_context) {
2295 // WakeLockServiceContext is owned by WebContentsImpl so it will outlive 2301 // WakeLockServiceContext is owned by WebContentsImpl so it will outlive
2296 // this RenderFrameHostImpl, hence a raw pointer can be bound to service 2302 // this RenderFrameHostImpl, hence a raw pointer can be bound to service
2297 // factory callback. 2303 // factory callback.
2298 GetInterfaceRegistry()->AddInterface<device::mojom::WakeLockService>( 2304 GetInterfaceRegistry()->AddInterface<device::mojom::WakeLockService>(
2299 base::Bind(&device::WakeLockServiceContext::CreateService, 2305 base::Bind(&BindWakeLockRequest,
2300 base::Unretained(wake_lock_service_context))); 2306 base::Unretained(wake_lock_service_context)));
2301 } 2307 }
2302 2308
2303 if (!permission_service_context_) 2309 if (!permission_service_context_)
2304 permission_service_context_.reset(new PermissionServiceContext(this)); 2310 permission_service_context_.reset(new PermissionServiceContext(this));
2305 2311
2306 GetInterfaceRegistry()->AddInterface( 2312 GetInterfaceRegistry()->AddInterface(
2307 base::Bind(&PermissionServiceContext::CreateService, 2313 base::Bind(&PermissionServiceContext::CreateService,
2308 base::Unretained(permission_service_context_.get()))); 2314 base::Unretained(permission_service_context_.get())));
2309 2315
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
3458 // There is no pending NavigationEntry in these cases, so pass 0 as the 3464 // There is no pending NavigationEntry in these cases, so pass 0 as the
3459 // pending_nav_entry_id. If the previous handle was a prematurely aborted 3465 // pending_nav_entry_id. If the previous handle was a prematurely aborted
3460 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. 3466 // navigation loaded via LoadDataWithBaseURL, propagate the entry id.
3461 return NavigationHandleImpl::Create( 3467 return NavigationHandleImpl::Create(
3462 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, 3468 params.url, params.redirects, frame_tree_node_, is_renderer_initiated,
3463 params.was_within_same_page, base::TimeTicks::Now(), 3469 params.was_within_same_page, base::TimeTicks::Now(),
3464 entry_id_for_data_nav, false); // started_from_context_menu 3470 entry_id_for_data_nav, false); // started_from_context_menu
3465 } 3471 }
3466 3472
3467 } // namespace content 3473 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698