OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/android/compositor/scene_layer/contextual_search_scene_
layer.h" | 5 #include "chrome/browser/android/compositor/scene_layer/contextual_search_scene_
layer.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" |
8 #include "chrome/browser/android/compositor/layer/contextual_search_layer.h" | 9 #include "chrome/browser/android/compositor/layer/contextual_search_layer.h" |
9 #include "content/public/browser/android/content_view_core.h" | 10 #include "content/public/browser/android/content_view_core.h" |
10 #include "jni/ContextualSearchSceneLayer_jni.h" | 11 #include "jni/ContextualSearchSceneLayer_jni.h" |
11 #include "ui/android/resources/resource_manager_impl.h" | 12 #include "ui/android/resources/resource_manager_impl.h" |
12 | 13 |
13 namespace chrome { | 14 namespace chrome { |
14 namespace android { | 15 namespace android { |
15 | 16 |
16 ContextualSearchSceneLayer::ContextualSearchSceneLayer(JNIEnv* env, | 17 ContextualSearchSceneLayer::ContextualSearchSceneLayer(JNIEnv* env, |
17 jobject jobj) | 18 jobject jobj) |
(...skipping 26 matching lines...) Expand all Loading... |
44 jfloat search_panel_height, | 45 jfloat search_panel_height, |
45 jfloat search_bar_margin_side, | 46 jfloat search_bar_margin_side, |
46 jfloat search_bar_height, | 47 jfloat search_bar_height, |
47 jfloat search_context_opacity, | 48 jfloat search_context_opacity, |
48 jfloat search_term_opacity, | 49 jfloat search_term_opacity, |
49 jboolean search_bar_border_visible, | 50 jboolean search_bar_border_visible, |
50 jfloat search_bar_border_y, | 51 jfloat search_bar_border_y, |
51 jfloat search_bar_border_height, | 52 jfloat search_bar_border_height, |
52 jboolean search_bar_shadow_visible, | 53 jboolean search_bar_shadow_visible, |
53 jfloat search_bar_shadow_opacity, | 54 jfloat search_bar_shadow_opacity, |
| 55 jboolean search_provider_icon_sprite_visible, |
| 56 jfloat search_provider_icon_sprite_size, |
| 57 jintArray search_provider_icon_sprite_rects, |
| 58 jboolean search_provider_icon_sprite_paint_previous_frames, |
54 jfloat arrow_icon_opacity, | 59 jfloat arrow_icon_opacity, |
55 jfloat arrow_icon_rotation, | 60 jfloat arrow_icon_rotation, |
56 jboolean close_icon_visible, | 61 jboolean close_icon_visible, |
57 jfloat close_icon_opacity, | 62 jfloat close_icon_opacity, |
58 jboolean progress_bar_visible, | 63 jboolean progress_bar_visible, |
59 jfloat progress_bar_y, | 64 jfloat progress_bar_y, |
60 jfloat progress_bar_height, | 65 jfloat progress_bar_height, |
61 jfloat progress_bar_opacity, | 66 jfloat progress_bar_opacity, |
62 jint progress_bar_completion, | 67 jint progress_bar_completion, |
63 jobject jresource_manager) { | 68 jobject jresource_manager) { |
64 ui::ResourceManager* resource_manager = | 69 ui::ResourceManager* resource_manager = |
65 ui::ResourceManagerImpl::FromJavaObject(jresource_manager); | 70 ui::ResourceManagerImpl::FromJavaObject(jresource_manager); |
66 // Lazily construct the contextual search layer, as the feature is only | 71 // Lazily construct the contextual search layer, as the feature is only |
67 // conditionally enabled. | 72 // conditionally enabled. |
68 if (!contextual_search_layer_.get()) { | 73 if (!contextual_search_layer_.get()) { |
69 if (!resource_manager) | 74 if (!resource_manager) |
70 return; | 75 return; |
71 contextual_search_layer_ = ContextualSearchLayer::Create(resource_manager); | 76 contextual_search_layer_ = ContextualSearchLayer::Create(resource_manager); |
72 layer_->AddChild(contextual_search_layer_->layer()); | 77 layer_->AddChild(contextual_search_layer_->layer()); |
73 } | 78 } |
74 | 79 |
75 // NOTE(pedrosimonetti): The ContentViewCore might not exist at this time if | 80 // NOTE(pedrosimonetti): The ContentViewCore might not exist at this time if |
76 // the Contextual Search Result has not been requested yet. In this case, | 81 // the Contextual Search Result has not been requested yet. In this case, |
77 // we'll pass NULL to Contextual Search's Layer Tree. | 82 // we'll pass NULL to Contextual Search's Layer Tree. |
78 content::ContentViewCore* content_view_core = | 83 content::ContentViewCore* content_view_core = |
79 !jcontent_view_core ? NULL | 84 !jcontent_view_core ? NULL |
80 : content::ContentViewCore::GetNativeContentViewCore( | 85 : content::ContentViewCore::GetNativeContentViewCore( |
81 env, jcontent_view_core); | 86 env, jcontent_view_core); |
82 | 87 |
| 88 std::vector<int> search_provider_icon_sprite_rects_array; |
| 89 base::android::JavaIntArrayToIntVector( |
| 90 env, search_provider_icon_sprite_rects, |
| 91 &search_provider_icon_sprite_rects_array); |
| 92 |
83 contextual_search_layer_->SetProperties( | 93 contextual_search_layer_->SetProperties( |
84 search_bar_background_resource_id, | 94 search_bar_background_resource_id, |
85 search_context_resource_id, | 95 search_context_resource_id, |
86 search_term_resource_id, | 96 search_term_resource_id, |
87 search_bar_shadow_resource_id, | 97 search_bar_shadow_resource_id, |
88 search_provider_icon_resource_id, | 98 search_provider_icon_resource_id, |
89 arrow_up_resource_id, | 99 arrow_up_resource_id, |
90 close_icon_resource_id, | 100 close_icon_resource_id, |
91 progress_bar_background_resource_id, | 101 progress_bar_background_resource_id, |
92 progress_bar_resource_id, | 102 progress_bar_resource_id, |
93 search_promo_resource_id, | 103 search_promo_resource_id, |
94 content_view_core, | 104 content_view_core, |
95 search_promo_visible, | 105 search_promo_visible, |
96 search_promo_height, | 106 search_promo_height, |
97 search_promo_opacity, | 107 search_promo_opacity, |
98 search_panel_X, | 108 search_panel_X, |
99 search_panel_y, | 109 search_panel_y, |
100 search_panel_width, | 110 search_panel_width, |
101 search_panel_height, | 111 search_panel_height, |
102 search_bar_margin_side, | 112 search_bar_margin_side, |
103 search_bar_height, | 113 search_bar_height, |
104 search_context_opacity, | 114 search_context_opacity, |
105 search_term_opacity, | 115 search_term_opacity, |
106 search_bar_border_visible, | 116 search_bar_border_visible, |
107 search_bar_border_y, | 117 search_bar_border_y, |
108 search_bar_border_height, | 118 search_bar_border_height, |
109 search_bar_shadow_visible, | 119 search_bar_shadow_visible, |
110 search_bar_shadow_opacity, | 120 search_bar_shadow_opacity, |
| 121 search_provider_icon_sprite_visible, |
| 122 search_provider_icon_sprite_size, |
| 123 search_provider_icon_sprite_rects_array, |
| 124 search_provider_icon_sprite_paint_previous_frames, |
111 arrow_icon_opacity, | 125 arrow_icon_opacity, |
112 arrow_icon_rotation, | 126 arrow_icon_rotation, |
113 close_icon_visible, | 127 close_icon_visible, |
114 close_icon_opacity, | 128 close_icon_opacity, |
115 progress_bar_visible, | 129 progress_bar_visible, |
116 progress_bar_y, | 130 progress_bar_y, |
117 progress_bar_height, | 131 progress_bar_height, |
118 progress_bar_opacity, | 132 progress_bar_opacity, |
119 progress_bar_completion); | 133 progress_bar_completion); |
120 } | 134 } |
121 | 135 |
122 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& jobj) { | 136 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& jobj) { |
123 // This will automatically bind to the Java object and pass ownership there. | 137 // This will automatically bind to the Java object and pass ownership there. |
124 ContextualSearchSceneLayer* tree_provider = | 138 ContextualSearchSceneLayer* tree_provider = |
125 new ContextualSearchSceneLayer(env, jobj); | 139 new ContextualSearchSceneLayer(env, jobj); |
126 return reinterpret_cast<intptr_t>(tree_provider); | 140 return reinterpret_cast<intptr_t>(tree_provider); |
127 } | 141 } |
128 | 142 |
129 bool RegisterContextualSearchSceneLayer(JNIEnv* env) { | 143 bool RegisterContextualSearchSceneLayer(JNIEnv* env) { |
130 return RegisterNativesImpl(env); | 144 return RegisterNativesImpl(env); |
131 } | 145 } |
132 | 146 |
133 } // namespace android | 147 } // namespace android |
134 } // namespace chrome | 148 } // namespace chrome |
OLD | NEW |