OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "components/web_contents_delegate_android/validation_message_bubble_and
roid.h" | 5 #include "components/web_contents_delegate_android/validation_message_bubble_and
roid.h" |
6 | 6 |
7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
8 #include "content/public/browser/android/content_view_core.h" | 8 #include "content/public/browser/android/content_view_core.h" |
9 #include "content/public/browser/render_view_host.h" | 9 #include "content/public/browser/render_view_host.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 const base::string16& main_text, | 36 const base::string16& main_text, |
37 const base::string16& sub_text) { | 37 const base::string16& sub_text) { |
38 base::android::ScopedJavaLocalRef<jobject> java_content_view_core = | 38 base::android::ScopedJavaLocalRef<jobject> java_content_view_core = |
39 GetJavaContentViewCoreFrom(widget_host); | 39 GetJavaContentViewCoreFrom(widget_host); |
40 if (java_content_view_core.is_null()) | 40 if (java_content_view_core.is_null()) |
41 return; | 41 return; |
42 | 42 |
43 JNIEnv* env = base::android::AttachCurrentThread(); | 43 JNIEnv* env = base::android::AttachCurrentThread(); |
44 java_validation_message_bubble_.Reset( | 44 java_validation_message_bubble_.Reset( |
45 Java_ValidationMessageBubble_createAndShow( | 45 Java_ValidationMessageBubble_createAndShow( |
46 env, | 46 env, java_content_view_core, anchor_in_root_view.x(), |
47 java_content_view_core.obj(), | 47 anchor_in_root_view.y(), anchor_in_root_view.width(), |
48 anchor_in_root_view.x(), | |
49 anchor_in_root_view.y(), | |
50 anchor_in_root_view.width(), | |
51 anchor_in_root_view.height(), | 48 anchor_in_root_view.height(), |
52 ConvertUTF16ToJavaString(env, main_text).obj(), | 49 ConvertUTF16ToJavaString(env, main_text), |
53 ConvertUTF16ToJavaString(env, sub_text).obj())); | 50 ConvertUTF16ToJavaString(env, sub_text))); |
54 } | 51 } |
55 | 52 |
56 ValidationMessageBubbleAndroid::~ValidationMessageBubbleAndroid() { | 53 ValidationMessageBubbleAndroid::~ValidationMessageBubbleAndroid() { |
57 Java_ValidationMessageBubble_close(base::android::AttachCurrentThread(), | 54 Java_ValidationMessageBubble_close(base::android::AttachCurrentThread(), |
58 java_validation_message_bubble_.obj()); | 55 java_validation_message_bubble_); |
59 } | 56 } |
60 | 57 |
61 void ValidationMessageBubbleAndroid::SetPositionRelativeToAnchor( | 58 void ValidationMessageBubbleAndroid::SetPositionRelativeToAnchor( |
62 RenderWidgetHost* widget_host, const gfx::Rect& anchor_in_root_view) { | 59 RenderWidgetHost* widget_host, const gfx::Rect& anchor_in_root_view) { |
63 base::android::ScopedJavaLocalRef<jobject> java_content_view_core = | 60 base::android::ScopedJavaLocalRef<jobject> java_content_view_core = |
64 GetJavaContentViewCoreFrom(widget_host); | 61 GetJavaContentViewCoreFrom(widget_host); |
65 if (java_content_view_core.is_null()) | 62 if (java_content_view_core.is_null()) |
66 return; | 63 return; |
67 | 64 |
68 Java_ValidationMessageBubble_setPositionRelativeToAnchor( | 65 Java_ValidationMessageBubble_setPositionRelativeToAnchor( |
69 base::android::AttachCurrentThread(), | 66 base::android::AttachCurrentThread(), java_validation_message_bubble_, |
70 java_validation_message_bubble_.obj(), | 67 java_content_view_core, anchor_in_root_view.x(), anchor_in_root_view.y(), |
71 java_content_view_core.obj(), | 68 anchor_in_root_view.width(), anchor_in_root_view.height()); |
72 anchor_in_root_view.x(), | |
73 anchor_in_root_view.y(), | |
74 anchor_in_root_view.width(), | |
75 anchor_in_root_view.height()); | |
76 } | 69 } |
77 | 70 |
78 } // namespace web_contents_delegate_android | 71 } // namespace web_contents_delegate_android |
OLD | NEW |