forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Messages] Introduce MessageDispatcherBridge::MapToJavaDrawableId
MessageDispatcherBridge::MapToJavaDrawableId allows mapping native resource ID to Java Drawable resource ID for consumers that don't have access to ResourceMapper (e.g. when implementation is in //components). BUG=1233696 [email protected] Change-Id: I4b8396fc6212cc4fe3d52c88a71275b9ae618892 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3087808 Reviewed-by: Lijin Shen <[email protected]> Reviewed-by: Theresa <[email protected]> Reviewed-by: Charlie Harrison <[email protected]> Commit-Queue: Pavel Yatsuk <[email protected]> Cr-Commit-Position: refs/heads/master@{#912753}
- Loading branch information
Pavel Yatsuk
authored and
Chromium LUCI CQ
committed
Aug 17, 2021
1 parent
4128659
commit 9947bf8
Showing
14 changed files
with
96 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2021 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. | ||
|
||
import("//build/config/android/rules.gni") | ||
|
||
android_library("java") { | ||
sources = [ "java/src/org/chromium/chrome/browser/messages/MessagesResourceMapperInitializer.java" ] | ||
|
||
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ] | ||
|
||
deps = [ "//base:base_java" ] | ||
} | ||
|
||
generate_jni("jni_headers") { | ||
sources = [ "java/src/org/chromium/chrome/browser/messages/MessagesResourceMapperInitializer.java" ] | ||
} |
20 changes: 20 additions & 0 deletions
20
...ages/java/src/org/chromium/chrome/browser/messages/MessagesResourceMapperInitializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2021 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. | ||
|
||
package org.chromium.chrome.browser.messages; | ||
|
||
import org.chromium.base.annotations.NativeMethods; | ||
|
||
/** Helper class to initialize ResourceIdMapper for MessageDispatcherBridge. */ | ||
public class MessagesResourceMapperInitializer { | ||
/** Calls native method to initialize ResourceIdMapper for MessageDispatcherBridge. */ | ||
public static void init() { | ||
MessagesResourceMapperInitializerJni.get().init(); | ||
} | ||
|
||
@NativeMethods | ||
interface Natives { | ||
void init(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
chrome/browser/android/messages_resource_mapper_initializer.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2021 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 "chrome/browser/android/messages/jni_headers/MessagesResourceMapperInitializer_jni.h" | ||
#include "chrome/browser/android/resource_mapper.h" | ||
#include "components/messages/android/message_dispatcher_bridge.h" | ||
|
||
// Sets up a callback for MessageDispatcherBridge ResourceIdMapper. This is done | ||
// in chrome/browser/android because ResourceMapper is not available in | ||
// components. | ||
void JNI_MessagesResourceMapperInitializer_Init(JNIEnv* env) { | ||
messages::MessageDispatcherBridge::Get()->SetResourceIdMapper( | ||
base::BindRepeating(&ResourceMapper::MapToJavaDrawableId)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters