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 "ui/base/cursor/image_cursors.h" | 5 #include "ui/base/cursor/image_cursors.h" |
6 | 6 |
7 #include <float.h> | 7 #include <float.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 CursorType::kNorthWestSouthEastResize, | 53 CursorType::kNorthWestSouthEastResize, |
54 CursorType::kGrab, | 54 CursorType::kGrab, |
55 CursorType::kGrabbing, | 55 CursorType::kGrabbing, |
56 }; | 56 }; |
57 | 57 |
58 const CursorType kAnimatedCursorIds[] = {CursorType::kWait, | 58 const CursorType kAnimatedCursorIds[] = {CursorType::kWait, |
59 CursorType::kProgress}; | 59 CursorType::kProgress}; |
60 | 60 |
61 } // namespace | 61 } // namespace |
62 | 62 |
63 ImageCursors::ImageCursors() : cursor_size_(CursorSize::kNormal) {} | 63 ImageCursors::ImageCursors() |
| 64 : cursor_size_(CursorSize::kNormal), weak_ptr_factory_(this) {} |
64 | 65 |
65 ImageCursors::~ImageCursors() { | 66 ImageCursors::~ImageCursors() { |
66 } | 67 } |
67 | 68 |
68 float ImageCursors::GetScale() const { | 69 float ImageCursors::GetScale() const { |
69 if (!cursor_loader_) { | 70 if (!cursor_loader_) { |
70 NOTREACHED(); | 71 NOTREACHED(); |
71 // Returning default on release build as it's not serious enough to crash | 72 // Returning default on release build as it's not serious enough to crash |
72 // even if this ever happens. | 73 // even if this ever happens. |
73 return 1.0f; | 74 return 1.0f; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 cursor_size_ = cursor_size; | 136 cursor_size_ = cursor_size; |
136 | 137 |
137 if (cursor_loader_.get()) | 138 if (cursor_loader_.get()) |
138 ReloadCursors(); | 139 ReloadCursors(); |
139 } | 140 } |
140 | 141 |
141 void ImageCursors::SetPlatformCursor(gfx::NativeCursor* cursor) { | 142 void ImageCursors::SetPlatformCursor(gfx::NativeCursor* cursor) { |
142 cursor_loader_->SetPlatformCursor(cursor); | 143 cursor_loader_->SetPlatformCursor(cursor); |
143 } | 144 } |
144 | 145 |
| 146 base::WeakPtr<ImageCursors> ImageCursors::GetWeakPtr() { |
| 147 return weak_ptr_factory_.GetWeakPtr(); |
| 148 } |
| 149 |
145 } // namespace ui | 150 } // namespace ui |
OLD | NEW |