Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 #include "InternalsScreenOrientation.h" | |
| 7 | |
| 8 #include "core/dom/Document.h" | |
| 9 #include "modules/screen_orientation/ScreenOrientation.h" | |
| 10 #include "modules/screen_orientation/ScreenOrientationController.h" | |
| 11 #include "modules/screen_orientation/testing/ScreenOrientationClientMock.h" | |
| 12 | |
| 13 namespace WebCore { | |
| 14 | |
| 15 void InternalsScreenOrientation::setScreenOrientationClientMock(Internals* inter nals, Document* document) | |
| 16 { | |
| 17 ASSERT(internals && document && document->page()); | |
| 18 ScreenOrientationController* controller = ScreenOrientationController::from( document->page()); | |
| 19 ScreenOrientationClientMock* client = new ScreenOrientationClientMock(); | |
|
Peter Beverloo
2014/02/12 18:19:37
What owns this client? Won't we leak it?
Peter Beverloo
2014/02/12 18:19:37
What/who owns this client? Won't we leak it?
Inactive
2014/02/12 19:38:37
You are right, this was leaked. This is now delete
| |
| 20 controller->setClientForTest(client); | |
| 21 client->setController(controller); | |
| 22 } | |
| 23 | |
| 24 void InternalsScreenOrientation::setScreenOrientation(Internals* internals, Docu ment* document, const AtomicString& orientationString) | |
| 25 { | |
| 26 ASSERT(internals && document && document->page()); | |
| 27 ScreenOrientationClientMock* client = screenOrientationClient(document); | |
| 28 if (!client) | |
| 29 return; | |
| 30 | |
| 31 ScreenOrientationValue orientation = static_cast<ScreenOrientationValue>(Scr eenOrientation::stringToOrientationValues(orientationString)); | |
| 32 if (orientation == OrientationInvalid) | |
| 33 return; | |
| 34 client->setScreenOrientation(orientation); | |
| 35 } | |
| 36 | |
| 37 ScreenOrientationClientMock* InternalsScreenOrientation::screenOrientationClient (Document* document) | |
| 38 { | |
| 39 ScreenOrientationController* controller = ScreenOrientationController::from( document->page()); | |
| 40 if (!controller->hasClientForTest()) | |
| 41 return 0; | |
| 42 return static_cast<ScreenOrientationClientMock*>(controller->client()); | |
| 43 } | |
| 44 | |
| 45 } // namespace WebCore | |
| OLD | NEW |