| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "cc/trees/layer_tree_host.h" | 9 #include "cc/trees/layer_tree_host.h" |
| 10 #include "content/renderer/gpu/render_widget_compositor.h" | 10 #include "content/renderer/gpu/render_widget_compositor.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 // Check content::TopControlsState and cc::TopControlsState are kept in sync. |
| 15 COMPILE_ASSERT(int(SHOWN) == int(cc::SHOWN), mismatching_enums); |
| 16 COMPILE_ASSERT(int(HIDDEN) == int(cc::HIDDEN), mismatching_enums); |
| 17 COMPILE_ASSERT(int(BOTH) == int(cc::BOTH), mismatching_enums); |
| 18 |
| 19 cc::TopControlsState ContentToCcTopControlsState( |
| 20 TopControlsState state) { |
| 21 return static_cast<cc::TopControlsState>(state); |
| 22 } |
| 23 |
| 24 // TODO(mvanouwerkerk): Stop calling this code path and delete it. |
| 14 void RenderViewImpl::OnUpdateTopControlsState(bool enable_hiding, | 25 void RenderViewImpl::OnUpdateTopControlsState(bool enable_hiding, |
| 15 bool enable_showing, | 26 bool enable_showing, |
| 16 bool animate) { | 27 bool animate) { |
| 17 // TODO(tedchoc): Investigate why messages are getting here before the | 28 // TODO(tedchoc): Investigate why messages are getting here before the |
| 18 // compositor has been initialized. | 29 // compositor has been initialized. |
| 19 LOG_IF(WARNING, !compositor_) << "OnUpdateTopControlsState was unhandled."; | 30 LOG_IF(WARNING, !compositor_) << "OnUpdateTopControlsState was unhandled."; |
| 31 if (compositor_) { |
| 32 cc::TopControlsState constraints = cc::BOTH; |
| 33 if (!enable_showing) |
| 34 constraints = cc::HIDDEN; |
| 35 if (!enable_hiding) |
| 36 constraints = cc::SHOWN; |
| 37 cc::TopControlsState current = cc::BOTH; |
| 38 compositor_->UpdateTopControlsState(constraints, current, animate); |
| 39 } |
| 40 } |
| 41 |
| 42 void RenderViewImpl::UpdateTopControlsState(TopControlsState constraints, |
| 43 TopControlsState current, |
| 44 bool animate) { |
| 45 cc::TopControlsState constraints_cc = |
| 46 ContentToCcTopControlsState(constraints); |
| 47 cc::TopControlsState current_cc = ContentToCcTopControlsState(current); |
| 20 if (compositor_) | 48 if (compositor_) |
| 21 compositor_->UpdateTopControlsState(enable_hiding, enable_showing, animate); | 49 compositor_->UpdateTopControlsState(constraints_cc, current_cc, animate); |
| 22 } | 50 } |
| 23 | 51 |
| 24 } // namespace content | 52 } // namespace content |
| OLD | NEW |