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

Side by Side Diff: Source/modules/device_orientation/DeviceOrientationInspectorAgent.cpp

Issue 165443003: Pass implementation object to supplemental classes by reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "modules/device_orientation/DeviceOrientationInspectorAgent.h" 6 #include "modules/device_orientation/DeviceOrientationInspectorAgent.h"
7 7
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/frame/Frame.h" 9 #include "core/frame/Frame.h"
10 #include "core/inspector/InspectorController.h" 10 #include "core/inspector/InspectorController.h"
11 #include "core/page/Page.h" 11 #include "core/page/Page.h"
12 12
13 #include "modules/device_orientation/DeviceOrientationController.h" 13 #include "modules/device_orientation/DeviceOrientationController.h"
14 #include "modules/device_orientation/DeviceOrientationData.h" 14 #include "modules/device_orientation/DeviceOrientationData.h"
15 15
16 namespace WebCore { 16 namespace WebCore {
17 17
18 void DeviceOrientationInspectorAgent::provideTo(Page* page) 18 void DeviceOrientationInspectorAgent::provideTo(Page& page)
19 { 19 {
20 OwnPtr<DeviceOrientationInspectorAgent> deviceOrientationAgent(adoptPtr(new DeviceOrientationInspectorAgent(page))); 20 OwnPtr<DeviceOrientationInspectorAgent> deviceOrientationAgent(adoptPtr(new DeviceOrientationInspectorAgent(page)));
21 page->inspectorController().registerModuleAgent(deviceOrientationAgent.relea se()); 21 page.inspectorController().registerModuleAgent(deviceOrientationAgent.releas e());
22 } 22 }
23 23
24 DeviceOrientationInspectorAgent::~DeviceOrientationInspectorAgent() 24 DeviceOrientationInspectorAgent::~DeviceOrientationInspectorAgent()
25 { 25 {
26 } 26 }
27 27
28 DeviceOrientationInspectorAgent::DeviceOrientationInspectorAgent(Page* page) 28 DeviceOrientationInspectorAgent::DeviceOrientationInspectorAgent(Page& page)
29 : InspectorBaseAgent<DeviceOrientationInspectorAgent>("DeviceOrientation") 29 : InspectorBaseAgent<DeviceOrientationInspectorAgent>("DeviceOrientation")
30 , m_page(page) 30 , m_page(page)
31 { 31 {
32 } 32 }
33 33
34 void DeviceOrientationInspectorAgent::setDeviceOrientationOverride(ErrorString* error, double alpha, double beta, double gamma) 34 void DeviceOrientationInspectorAgent::setDeviceOrientationOverride(ErrorString* error, double alpha, double beta, double gamma)
35 { 35 {
36 DeviceOrientationController* controller = DeviceOrientationController::from( m_page->mainFrame()->document()); 36 ASSERT(m_page.mainFrame()->document());
37 if (!controller) { 37 DeviceOrientationController& controller = DeviceOrientationController::from( *m_page.mainFrame()->document());
38 *error = "Internal error: unable to override device orientation"; 38 controller.didChangeDeviceOrientation(DeviceOrientationData::create(true, al pha, true, beta, true, gamma).get());
39 return;
40 }
41 controller->didChangeDeviceOrientation(DeviceOrientationData::create(true, a lpha, true, beta, true, gamma).get());
42 } 39 }
43 40
44 void DeviceOrientationInspectorAgent::clearDeviceOrientationOverride(ErrorString * error) 41 void DeviceOrientationInspectorAgent::clearDeviceOrientationOverride(ErrorString * error)
45 { 42 {
46 setDeviceOrientationOverride(error, 0, 0, 0); 43 setDeviceOrientationOverride(error, 0, 0, 0);
47 } 44 }
48 45
49 } // namespace WebCore 46 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698