Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(945)

Unified Diff: ui/base/cursor/cursors_android.cc

Issue 2878403002: Support setting mouse cursor icon in Android N. (Closed)
Patch Set: Support setting mouse cursor icon in Android N Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..9f9330b0228b0595c878f087072e1ade5dfe811c
--- /dev/null
+++ b/ui/base/cursor/cursors_android.cc
@@ -0,0 +1,54 @@
+// 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 "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"
+#include "ui/resources/grit/ui_resources.h"
+
+using blink::WebCursorInfo;
+
+namespace ui {
+
+bool GetCursorBitmap(int type, SkBitmap* bitmap) {
+ DCHECK(bitmap);
+ int resource_id;
+ switch (type) {
+ // TODO(jaebaek): set types correctly
+ // after fixing http://crbug.com/584424.
+ case WebCursorInfo::kTypeMove:
+ resource_id = IDR_ANDROID_CURSOR_MOVE;
+ break;
+ case WebCursorInfo::kTypeMiddlePanning:
+ resource_id = IDR_ANDROID_CURSOR_MIDDLE_PANNING;
+ break;
+ case WebCursorInfo::kTypeEastWestResize:
+ case WebCursorInfo::kTypeNorthSouthResize:
+ case WebCursorInfo::kTypeEastResize:
+ case WebCursorInfo::kTypeNorthResize:
+ case WebCursorInfo::kTypeNorthEastResize:
+ case WebCursorInfo::kTypeNorthWestResize:
+ case WebCursorInfo::kTypeSouthResize:
+ case WebCursorInfo::kTypeSouthEastResize:
+ case WebCursorInfo::kTypeSouthWestResize:
+ case WebCursorInfo::kTypeWestResize:
+ case WebCursorInfo::kTypeProgress:
+ case WebCursorInfo::kTypeNotAllowed:
+ default:
boliu 2017/05/24 18:24:07 avoid default
jaebaek 2017/05/29 12:40:03 I also drop this file.
+ return false;
+ }
+
+ const SkBitmap* cursor_bitmap = ResourceBundle::GetSharedInstance()
+ .GetImageSkiaNamed(resource_id)
+ ->bitmap();
+ if (!cursor_bitmap)
+ return false;
+ *bitmap = *cursor_bitmap;
+ return true;
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698