OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 "content/shell/renderer/test_runner/mock_presentation_client.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "content/shell/renderer/test_runner/mock_presentation_service.h" |
| 9 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nController.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 MockPresentationClient::MockPresentationClient(MockPresentationService* service) |
| 14 : controller_(nullptr), |
| 15 screen_availability_(false), |
| 16 service_(service) { |
| 17 DCHECK(service_); |
| 18 service_->RegisterPresentationClientMock(this); |
| 19 } |
| 20 |
| 21 MockPresentationClient::~MockPresentationClient() { |
| 22 DCHECK(!controller_); |
| 23 if (service_) |
| 24 service_->UnregisterPresentationClientMock(this); |
| 25 } |
| 26 |
| 27 void MockPresentationClient::SetScreenAvailability(bool available) { |
| 28 if (screen_availability_ == available) |
| 29 return; |
| 30 screen_availability_ = available; |
| 31 |
| 32 if (!controller_) |
| 33 return; |
| 34 if (!controller_->isAvailableChangeWatched()) |
| 35 return; |
| 36 controller_->didChangeAvailability(screen_availability_); |
| 37 } |
| 38 |
| 39 void MockPresentationClient::Reset() { |
| 40 screen_availability_ = false; |
| 41 service_ = nullptr; |
| 42 } |
| 43 |
| 44 void MockPresentationClient::setController( |
| 45 blink::WebPresentationController* controller) { |
| 46 DCHECK(controller_ != controller && (!controller || !controller_)) |
| 47 << "Either one of the new or the old controller must be null, " |
| 48 "controller_ is " << controller_ << ", controller is " << controller; |
| 49 |
| 50 controller_ = controller; |
| 51 } |
| 52 |
| 53 void MockPresentationClient::updateAvailableChangeWatched(bool watched) { |
| 54 if (!watched) |
| 55 return; |
| 56 DCHECK(controller_); |
| 57 if (screen_availability_) |
| 58 controller_->didChangeAvailability(screen_availability_); |
| 59 } |
| 60 |
| 61 } // namespace content |
OLD | NEW |