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