commit | 4f51d5d775713e1b428ad8fa5ee131c411753f3c | [log] [tgz] |
---|---|---|
author | François Doray <[email protected]> | Mon Dec 03 22:26:24 2018 |
committer | Commit Bot <[email protected]> | Mon Dec 03 22:26:24 2018 |
tree | 142b805a2234614fb47ed597ec76a35827e3def6 | |
parent | 5aac4743177366d4c83ce11c4d29de9cead786eb [diff] [blame] |
content: Fix WebContentsUserData for usage across components. Prior to this CL https://chromium-review.googlesource.com/1093015, the UserDataKey of a class T derived from WebContentsUserData<T> was the address of a static member variable of WebContentsUserData<T>. Storage had to be allocated for that static member variable. Unfortunately, it was not possible to allocate the storage if T was an exported class. Since https://chromium-review.googlesource.com/1093015, the UserDataKey of a class T derived from WebContentsUserData<T> is the address of a local static variable in a static method of WebContentsUserData<T>. Unfortunately, since the method is defined in a header file (it has to because it is part of a templated class), it can be instantiated multiple times and return different values if it is referenced from different components (e.g. in a component build). With this CL, the UserDataKey of a class T derived from WebContentsUserData<T> is the address of a static member variable of T. This solution works fine with exported classes, but it requires adding macros to declare/define the static member variable in T. [email protected] Bug: 589840 Change-Id: Ie618c09f1ab5db1e11ac3e7a86405577872e932f Reviewed-on: https://chromium-review.googlesource.com/c/1354402 Commit-Queue: François Doray <[email protected]> Reviewed-by: François Doray <[email protected]> Reviewed-by: Avi Drissman <[email protected]> Cr-Commit-Position: refs/heads/master@{#613290}
diff --git a/chrome/browser/ui/android/context_menu_helper.h b/chrome/browser/ui/android/context_menu_helper.h index e58f8b5..d810624 100644 --- a/chrome/browser/ui/android/context_menu_helper.h +++ b/chrome/browser/ui/android/context_menu_helper.h
@@ -85,6 +85,8 @@ int render_frame_id_; int render_process_id_; + WEB_CONTENTS_USER_DATA_KEY_DECL(); + DISALLOW_COPY_AND_ASSIGN(ContextMenuHelper); };