OLD | NEW |
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 "content/browser/web_contents/aura/gesture_nav_simple.h" | 5 #include "content/browser/web_contents/aura/gesture_nav_simple.h" |
6 | 6 |
7 #include "cc/layers/layer.h" | 7 #include "cc/layers/layer.h" |
8 #include "content/browser/frame_host/navigation_controller_impl.h" | 8 #include "content/browser/frame_host/navigation_controller_impl.h" |
9 #include "content/browser/renderer_host/overscroll_controller.h" | 9 #include "content/browser/renderer_host/overscroll_controller.h" |
10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 public: | 49 public: |
50 explicit DeleteAfterAnimation(scoped_ptr<T> object) | 50 explicit DeleteAfterAnimation(scoped_ptr<T> object) |
51 : object_(object.Pass()) {} | 51 : object_(object.Pass()) {} |
52 | 52 |
53 private: | 53 private: |
54 friend class base::DeleteHelper<DeleteAfterAnimation<T> >; | 54 friend class base::DeleteHelper<DeleteAfterAnimation<T> >; |
55 | 55 |
56 virtual ~DeleteAfterAnimation() {} | 56 virtual ~DeleteAfterAnimation() {} |
57 | 57 |
58 // ui::ImplicitAnimationObserver: | 58 // ui::ImplicitAnimationObserver: |
59 virtual void OnImplicitAnimationsCompleted() OVERRIDE { | 59 virtual void OnImplicitAnimationsCompleted() override { |
60 // Deleting an observer when a ScopedLayerAnimationSettings is iterating | 60 // Deleting an observer when a ScopedLayerAnimationSettings is iterating |
61 // over them can cause a crash (which can happen during tests). So instead, | 61 // over them can cause a crash (which can happen during tests). So instead, |
62 // schedule this observer to be deleted soon. | 62 // schedule this observer to be deleted soon. |
63 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); | 63 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); |
64 } | 64 } |
65 | 65 |
66 scoped_ptr<T> object_; | 66 scoped_ptr<T> object_; |
67 DISALLOW_COPY_AND_ASSIGN(DeleteAfterAnimation); | 67 DISALLOW_COPY_AND_ASSIGN(DeleteAfterAnimation); |
68 }; | 68 }; |
69 | 69 |
70 } // namespace | 70 } // namespace |
71 | 71 |
72 // A layer delegate that paints the shield with the arrow in it. | 72 // A layer delegate that paints the shield with the arrow in it. |
73 class ArrowLayerDelegate : public ui::LayerDelegate { | 73 class ArrowLayerDelegate : public ui::LayerDelegate { |
74 public: | 74 public: |
75 explicit ArrowLayerDelegate(int resource_id) | 75 explicit ArrowLayerDelegate(int resource_id) |
76 : image_(GetContentClient()->GetNativeImageNamed(resource_id)), | 76 : image_(GetContentClient()->GetNativeImageNamed(resource_id)), |
77 left_arrow_(resource_id == IDR_BACK_ARROW) { | 77 left_arrow_(resource_id == IDR_BACK_ARROW) { |
78 CHECK(!image_.IsEmpty()); | 78 CHECK(!image_.IsEmpty()); |
79 } | 79 } |
80 | 80 |
81 virtual ~ArrowLayerDelegate() {} | 81 virtual ~ArrowLayerDelegate() {} |
82 | 82 |
83 bool left() const { return left_arrow_; } | 83 bool left() const { return left_arrow_; } |
84 | 84 |
85 private: | 85 private: |
86 // ui::LayerDelegate: | 86 // ui::LayerDelegate: |
87 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { | 87 virtual void OnPaintLayer(gfx::Canvas* canvas) override { |
88 SkPaint paint; | 88 SkPaint paint; |
89 paint.setColor(SkColorSetARGB(0xa0, 0, 0, 0)); | 89 paint.setColor(SkColorSetARGB(0xa0, 0, 0, 0)); |
90 paint.setStyle(SkPaint::kFill_Style); | 90 paint.setStyle(SkPaint::kFill_Style); |
91 paint.setAntiAlias(true); | 91 paint.setAntiAlias(true); |
92 | 92 |
93 canvas->DrawCircle( | 93 canvas->DrawCircle( |
94 gfx::Point(left_arrow_ ? 0 : kArrowWidth, kArrowHeight / 2), | 94 gfx::Point(left_arrow_ ? 0 : kArrowWidth, kArrowHeight / 2), |
95 kArrowWidth, | 95 kArrowWidth, |
96 paint); | 96 paint); |
97 canvas->DrawImageInt(*image_.ToImageSkia(), | 97 canvas->DrawImageInt(*image_.ToImageSkia(), |
98 left_arrow_ ? 0 : kArrowWidth - image_.Width(), | 98 left_arrow_ ? 0 : kArrowWidth - image_.Width(), |
99 (kArrowHeight - image_.Height()) / 2); | 99 (kArrowHeight - image_.Height()) / 2); |
100 } | 100 } |
101 | 101 |
102 virtual void OnDelegatedFrameDamage( | 102 virtual void OnDelegatedFrameDamage( |
103 const gfx::Rect& damage_rect_in_dip) OVERRIDE {} | 103 const gfx::Rect& damage_rect_in_dip) override {} |
104 | 104 |
105 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE {} | 105 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) override {} |
106 | 106 |
107 virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE { | 107 virtual base::Closure PrepareForLayerBoundsChange() override { |
108 return base::Closure(); | 108 return base::Closure(); |
109 } | 109 } |
110 | 110 |
111 const gfx::Image& image_; | 111 const gfx::Image& image_; |
112 const bool left_arrow_; | 112 const bool left_arrow_; |
113 | 113 |
114 DISALLOW_COPY_AND_ASSIGN(ArrowLayerDelegate); | 114 DISALLOW_COPY_AND_ASSIGN(ArrowLayerDelegate); |
115 }; | 115 }; |
116 | 116 |
117 GestureNavSimple::GestureNavSimple(WebContentsImpl* web_contents) | 117 GestureNavSimple::GestureNavSimple(WebContentsImpl* web_contents) |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 clip_layer_->SetBounds(window->layer()->bounds()); | 227 clip_layer_->SetBounds(window->layer()->bounds()); |
228 clip_layer_->SetMasksToBounds(true); | 228 clip_layer_->SetMasksToBounds(true); |
229 clip_layer_->Add(arrow_.get()); | 229 clip_layer_->Add(arrow_.get()); |
230 | 230 |
231 ui::Layer* parent = window->layer()->parent(); | 231 ui::Layer* parent = window->layer()->parent(); |
232 parent->Add(clip_layer_.get()); | 232 parent->Add(clip_layer_.get()); |
233 parent->StackAtTop(clip_layer_.get()); | 233 parent->StackAtTop(clip_layer_.get()); |
234 } | 234 } |
235 | 235 |
236 } // namespace content | 236 } // namespace content |
OLD | NEW |