OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/android/compositor/scene_layer/contextual_search_scene_
layer.h" |
| 6 |
| 7 #include "base/android/jni_android.h" |
| 8 #include "chrome/browser/android/compositor/layer/contextual_search_layer.h" |
| 9 #include "content/public/browser/android/content_view_core.h" |
| 10 #include "jni/ContextualSearchSceneLayer_jni.h" |
| 11 #include "ui/android/resources/resource_manager_impl.h" |
| 12 |
| 13 namespace chrome { |
| 14 namespace android { |
| 15 |
| 16 ContextualSearchSceneLayer::ContextualSearchSceneLayer(JNIEnv* env, |
| 17 jobject jobj) |
| 18 : SceneLayer(env, jobj) { |
| 19 } |
| 20 |
| 21 ContextualSearchSceneLayer::~ContextualSearchSceneLayer() { |
| 22 } |
| 23 |
| 24 void ContextualSearchSceneLayer::UpdateContextualSearchLayer( |
| 25 JNIEnv* env, |
| 26 jobject object, |
| 27 jint search_bar_background_resource_id, |
| 28 jint search_bar_text_resource_id, |
| 29 jint search_bar_shadow_resource_id, |
| 30 jint search_provider_icon_resource_id, |
| 31 jint search_icon_resource_id, |
| 32 jint progress_bar_background_resource_id, |
| 33 jint progress_bar_resource_id, |
| 34 jint search_promo_resource_id, |
| 35 jobject jcontent_view_core, |
| 36 jboolean search_promo_visible, |
| 37 jfloat search_promo_height, |
| 38 jfloat search_promo_opacity, |
| 39 jfloat search_panel_y, |
| 40 jfloat search_panel_width, |
| 41 jfloat search_bar_margin_top, |
| 42 jfloat search_bar_height, |
| 43 jfloat search_bar_text_opacity, |
| 44 jboolean search_bar_border_visible, |
| 45 jfloat search_bar_border_y, |
| 46 jfloat search_bar_border_height, |
| 47 jboolean search_bar_shadow_visible, |
| 48 jfloat search_bar_shadow_opacity, |
| 49 jfloat search_provider_icon_opacity, |
| 50 jfloat search_icon_padding_left, |
| 51 jfloat search_icon_opacity, |
| 52 jboolean progress_bar_visible, |
| 53 jfloat progress_bar_y, |
| 54 jfloat progress_bar_height, |
| 55 jfloat progress_bar_opacity, |
| 56 jint progress_bar_completion, |
| 57 jobject jresource_manager) { |
| 58 ui::ResourceManager* resource_manager = |
| 59 ui::ResourceManagerImpl::FromJavaObject(jresource_manager); |
| 60 // Lazily construct the contextual search layer, as the feature is only |
| 61 // conditionally enabled. |
| 62 if (!contextual_search_layer_.get()) { |
| 63 if (!resource_manager) |
| 64 return; |
| 65 contextual_search_layer_ = ContextualSearchLayer::Create(resource_manager); |
| 66 layer_->AddChild(contextual_search_layer_->layer()); |
| 67 } |
| 68 |
| 69 // NOTE(pedrosimonetti): The ContentViewCore might not exist at this time if |
| 70 // the Contextual Search Result has not been requested yet. In this case, |
| 71 // we'll pass NULL to Contextual Search's Layer Tree. |
| 72 content::ContentViewCore* content_view_core = |
| 73 !jcontent_view_core ? NULL |
| 74 : content::ContentViewCore::GetNativeContentViewCore( |
| 75 env, jcontent_view_core); |
| 76 |
| 77 contextual_search_layer_->SetProperties( |
| 78 search_bar_background_resource_id, |
| 79 search_bar_text_resource_id, |
| 80 search_bar_shadow_resource_id, |
| 81 search_provider_icon_resource_id, |
| 82 search_icon_resource_id, |
| 83 progress_bar_background_resource_id, |
| 84 progress_bar_resource_id, |
| 85 search_promo_resource_id, |
| 86 content_view_core, |
| 87 search_promo_visible, |
| 88 search_promo_height, |
| 89 search_promo_opacity, |
| 90 search_panel_y, |
| 91 search_panel_width, |
| 92 search_bar_margin_top, |
| 93 search_bar_height, |
| 94 search_bar_text_opacity, |
| 95 search_bar_border_visible, |
| 96 search_bar_border_y, |
| 97 search_bar_border_height, |
| 98 search_bar_shadow_visible, |
| 99 search_bar_shadow_opacity, |
| 100 search_provider_icon_opacity, |
| 101 search_icon_padding_left, |
| 102 search_icon_opacity, |
| 103 progress_bar_visible, |
| 104 progress_bar_y, |
| 105 progress_bar_height, |
| 106 progress_bar_opacity, |
| 107 progress_bar_completion); |
| 108 } |
| 109 |
| 110 static jlong Init(JNIEnv* env, jobject jobj) { |
| 111 // This will automatically bind to the Java object and pass ownership there. |
| 112 ContextualSearchSceneLayer* tree_provider = |
| 113 new ContextualSearchSceneLayer(env, jobj); |
| 114 return reinterpret_cast<intptr_t>(tree_provider); |
| 115 } |
| 116 |
| 117 bool RegisterContextualSearchSceneLayer(JNIEnv* env) { |
| 118 return RegisterNativesImpl(env); |
| 119 } |
| 120 |
| 121 } // namespace android |
| 122 } // namespace chrome |
OLD | NEW |