Chromium Code Reviews| Index: ui/base/cursor/cursors_android.cc |
| diff --git a/ui/base/cursor/cursors_android.cc b/ui/base/cursor/cursors_android.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b6e3e807f9b6bdfb5fdf2ea39e470c60d1e3ac4c |
| --- /dev/null |
| +++ b/ui/base/cursor/cursors_android.cc |
| @@ -0,0 +1,66 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/base/cursor/cursors_android.h" |
| + |
| +#include "content/app/resources/grit/content_resources.h" |
| +#include "third_party/WebKit/public/platform/WebCursorInfo.h" |
| +#include "third_party/skia/include/core/SkBitmap.h" |
| +#include "ui/base/resource/resource_bundle.h" |
| +#include "ui/gfx/image/image_skia.h" |
| + |
| +using blink::WebCursorInfo; |
| + |
| +namespace ui { |
| + |
| +bool GetCursorBitmap(int type, SkBitmap* bitmap) { |
| + DCHECK(bitmap); |
| + int resource_id; |
| + switch (type) { |
| + case WebCursorInfo::kTypeEastResize: |
| + resource_id = IDR_ANDROID_EAST_RESIZE_CURSOR; |
| + break; |
| + case WebCursorInfo::kTypeNorthResize: |
| + resource_id = IDR_ANDROID_NORTH_RESIZE_CURSOR; |
| + break; |
| + case WebCursorInfo::kTypeNorthEastResize: |
| + resource_id = IDR_ANDROID_NORTHEAST_RESIZE_CURSOR; |
| + break; |
| + case WebCursorInfo::kTypeNorthWestResize: |
| + resource_id = IDR_ANDROID_NORTHWEST_RESIZE_CURSOR; |
| + break; |
| + case WebCursorInfo::kTypeSouthResize: |
| + resource_id = IDR_ANDROID_SOUTH_RESIZE_CURSOR; |
| + break; |
| + case WebCursorInfo::kTypeSouthEastResize: |
| + resource_id = IDR_ANDROID_SOUTHEAST_RESIZE_CURSOR; |
| + break; |
| + case WebCursorInfo::kTypeSouthWestResize: |
| + resource_id = IDR_ANDROID_SOUTHWEST_RESIZE_CURSOR; |
| + break; |
| + case WebCursorInfo::kTypeWestResize: |
| + resource_id = IDR_ANDROID_WEST_RESIZE_CURSOR; |
| + break; |
| + case WebCursorInfo::kTypeMove: |
| + resource_id = IDR_ANDROID_MOVE_CURSOR; |
| + break; |
| + // TODO(jaebaek): set PROGRESS, MIDDLE_PANNING and NOT_ALLOWED |
| + // types correctly after fixing http://crbug.com/584424. |
| + case WebCursorInfo::kTypeMiddlePanning: |
| + case WebCursorInfo::kTypeProgress: |
| + case WebCursorInfo::kTypeNotAllowed: |
| + default: |
| + return false; |
| + } |
| + |
| + const SkBitmap* cursor_bitmap = ResourceBundle::GetSharedInstance() |
| + .GetImageSkiaNamed(resource_id) |
|
aelias_OOO_until_Jul13
2017/05/23 22:43:26
Hmm, sorry to go back on previous code review sugg
jaebaek
2017/05/24 11:26:15
Can I just return false for all the cases here and
|
| + ->bitmap(); |
| + if (!cursor_bitmap) |
| + return false; |
| + *bitmap = *cursor_bitmap; |
| + return true; |
| +} |
| + |
| +} // namespace ui |