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

Unified Diff: content/renderer/screen_orientation/mock_screen_orientation_controller.cc

Issue 339913002: Move MockScreenOrientationController to content/shell/renderer/test_runner/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix layer violation Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/screen_orientation/mock_screen_orientation_controller.cc
diff --git a/content/renderer/screen_orientation/mock_screen_orientation_controller.cc b/content/renderer/screen_orientation/mock_screen_orientation_controller.cc
deleted file mode 100644
index 87f73199acb39f9cad3aa1febcf7ffcaa49a78ba..0000000000000000000000000000000000000000
--- a/content/renderer/screen_orientation/mock_screen_orientation_controller.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/renderer/screen_orientation/mock_screen_orientation_controller.h"
-
-#include "base/bind.h"
-#include "base/logging.h"
-#include "base/message_loop/message_loop.h"
-#include "content/renderer/render_view_impl.h"
-
-namespace content {
-
-MockScreenOrientationController::MockScreenOrientationController()
- : RenderViewObserver(NULL),
- current_lock_(blink::WebScreenOrientationLockDefault),
- device_orientation_(blink::WebScreenOrientationPortraitPrimary),
- current_orientation_(blink::WebScreenOrientationPortraitPrimary) {
- // Since MockScreenOrientationController is held by LazyInstance reference,
- // add this ref for it.
- AddRef();
-}
-
-MockScreenOrientationController::~MockScreenOrientationController() {
-}
-
-void MockScreenOrientationController::ResetData() {
- if (render_view_impl())
- render_view_impl()->RemoveObserver(this);
-
- current_lock_ = blink::WebScreenOrientationLockDefault;
- device_orientation_ = blink::WebScreenOrientationPortraitPrimary;
- current_orientation_ = blink::WebScreenOrientationPortraitPrimary;
-}
-
-void MockScreenOrientationController::UpdateDeviceOrientation(
- RenderView* render_view,
- blink::WebScreenOrientationType orientation) {
- if (this->render_view()) {
- // Make sure that render_view_ did not change during test.
- DCHECK_EQ(this->render_view(), render_view);
- } else {
- Observe(render_view);
- }
-
- if (device_orientation_ == orientation)
- return;
- device_orientation_ = orientation;
- if (!IsOrientationAllowedByCurrentLock(orientation))
- return;
- UpdateScreenOrientation(orientation);
-}
-
-RenderViewImpl* MockScreenOrientationController::render_view_impl() const {
- return static_cast<RenderViewImpl*>(render_view());
-}
-
-void MockScreenOrientationController::UpdateScreenOrientation(
- blink::WebScreenOrientationType orientation) {
- if (current_orientation_ == orientation)
- return;
- current_orientation_ = orientation;
- if (render_view_impl())
- render_view_impl()->SetScreenOrientationForTesting(orientation);
-}
-
-bool MockScreenOrientationController::IsOrientationAllowedByCurrentLock(
- blink::WebScreenOrientationType orientation) {
- if (current_lock_ == blink::WebScreenOrientationLockDefault ||
- current_lock_ == blink::WebScreenOrientationLockAny) {
- return true;
- }
-
- switch (orientation) {
- case blink::WebScreenOrientationPortraitPrimary:
- return current_lock_ == blink::WebScreenOrientationLockPortraitPrimary ||
- current_lock_ == blink::WebScreenOrientationLockPortrait;
- case blink::WebScreenOrientationPortraitSecondary:
- return current_lock_ ==
- blink::WebScreenOrientationLockPortraitSecondary ||
- current_lock_ == blink::WebScreenOrientationLockPortrait;
- case blink::WebScreenOrientationLandscapePrimary:
- return current_lock_ == blink::WebScreenOrientationLockLandscapePrimary ||
- current_lock_ == blink::WebScreenOrientationLockLandscape ||
- current_lock_ == blink::WebScreenOrientationLockNatural;
- case blink::WebScreenOrientationLandscapeSecondary:
- return current_lock_ ==
- blink::WebScreenOrientationLockLandscapeSecondary ||
- current_lock_ == blink::WebScreenOrientationLockLandscape;
- default:
- return false;
- }
-}
-
-void MockScreenOrientationController::OnDestruct() {
-}
-
-} // namespace content

Powered by Google App Engine
This is Rietveld 408576698