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 |
| 69 void ImageCursors::Initialize() { |
| 70 if (!cursor_loader_) |
| 71 cursor_loader_.reset(CursorLoader::Create()); |
| 72 } |
| 73 |
68 float ImageCursors::GetScale() const { | 74 float ImageCursors::GetScale() const { |
69 if (!cursor_loader_) { | 75 if (!cursor_loader_) { |
70 NOTREACHED(); | 76 NOTREACHED(); |
71 // Returning default on release build as it's not serious enough to crash | 77 // Returning default on release build as it's not serious enough to crash |
72 // even if this ever happens. | 78 // even if this ever happens. |
73 return 1.0f; | 79 return 1.0f; |
74 } | 80 } |
75 return cursor_loader_->scale(); | 81 return cursor_loader_->scale(); |
76 } | 82 } |
77 | 83 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 cursor_size_ = cursor_size; | 141 cursor_size_ = cursor_size; |
136 | 142 |
137 if (cursor_loader_.get()) | 143 if (cursor_loader_.get()) |
138 ReloadCursors(); | 144 ReloadCursors(); |
139 } | 145 } |
140 | 146 |
141 void ImageCursors::SetPlatformCursor(gfx::NativeCursor* cursor) { | 147 void ImageCursors::SetPlatformCursor(gfx::NativeCursor* cursor) { |
142 cursor_loader_->SetPlatformCursor(cursor); | 148 cursor_loader_->SetPlatformCursor(cursor); |
143 } | 149 } |
144 | 150 |
| 151 base::WeakPtr<ImageCursors> ImageCursors::GetWeakPtr() { |
| 152 return weak_ptr_factory_.GetWeakPtr(); |
| 153 } |
| 154 |
145 } // namespace ui | 155 } // namespace ui |
OLD | NEW |