| 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 "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 | 58 |
| 59 void ContextualSearchSceneLayer::UpdateContextualSearchLayer( | 59 void ContextualSearchSceneLayer::UpdateContextualSearchLayer( |
| 60 JNIEnv* env, | 60 JNIEnv* env, |
| 61 const JavaParamRef<jobject>& object, | 61 const JavaParamRef<jobject>& object, |
| 62 jint search_bar_background_resource_id, | 62 jint search_bar_background_resource_id, |
| 63 jint search_context_resource_id, | 63 jint search_context_resource_id, |
| 64 jint search_term_resource_id, | 64 jint search_term_resource_id, |
| 65 jint search_caption_resource_id, | 65 jint search_caption_resource_id, |
| 66 jint search_bar_shadow_resource_id, | 66 jint search_bar_shadow_resource_id, |
| 67 jint sprite_resource_id, | 67 jint search_provider_icon_resource_id, |
| 68 jint search_provider_icon_sprite_metadata_resource_id, | |
| 69 jint quick_action_icon_resource_id, | 68 jint quick_action_icon_resource_id, |
| 70 jint arrow_up_resource_id, | 69 jint arrow_up_resource_id, |
| 71 jint close_icon_resource_id, | 70 jint close_icon_resource_id, |
| 72 jint progress_bar_background_resource_id, | 71 jint progress_bar_background_resource_id, |
| 73 jint progress_bar_resource_id, | 72 jint progress_bar_resource_id, |
| 74 jint search_promo_resource_id, | 73 jint search_promo_resource_id, |
| 75 jint peek_promo_ripple_resource_id, | 74 jint peek_promo_ripple_resource_id, |
| 76 jint peek_promo_text_resource_id, | 75 jint peek_promo_text_resource_id, |
| 77 jfloat dp_to_px, | 76 jfloat dp_to_px, |
| 78 jfloat base_page_brightness, | 77 jfloat base_page_brightness, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 96 jfloat search_context_opacity, | 95 jfloat search_context_opacity, |
| 97 jfloat search_text_layer_min_height, | 96 jfloat search_text_layer_min_height, |
| 98 jfloat search_term_opacity, | 97 jfloat search_term_opacity, |
| 99 jfloat search_term_caption_spacing, | 98 jfloat search_term_caption_spacing, |
| 100 jfloat search_caption_animation_percentage, | 99 jfloat search_caption_animation_percentage, |
| 101 jboolean search_caption_visible, | 100 jboolean search_caption_visible, |
| 102 jboolean search_bar_border_visible, | 101 jboolean search_bar_border_visible, |
| 103 jfloat search_bar_border_height, | 102 jfloat search_bar_border_height, |
| 104 jboolean search_bar_shadow_visible, | 103 jboolean search_bar_shadow_visible, |
| 105 jfloat search_bar_shadow_opacity, | 104 jfloat search_bar_shadow_opacity, |
| 106 jboolean search_provider_icon_sprite_visible, | |
| 107 jfloat search_provider_icon_sprite_completion_percentage, | |
| 108 jboolean quick_action_icon_visible, | 105 jboolean quick_action_icon_visible, |
| 109 jboolean thumbnail_visible, | 106 jboolean thumbnail_visible, |
| 110 jstring j_thumbnail_url, | 107 jstring j_thumbnail_url, |
| 111 jfloat static_image_visibility_percentage, | 108 jfloat custom_image_visibility_percentage, |
| 112 jint static_image_size, | 109 jint bar_image_size, |
| 113 jfloat arrow_icon_opacity, | 110 jfloat arrow_icon_opacity, |
| 114 jfloat arrow_icon_rotation, | 111 jfloat arrow_icon_rotation, |
| 115 jfloat close_icon_opacity, | 112 jfloat close_icon_opacity, |
| 116 jboolean progress_bar_visible, | 113 jboolean progress_bar_visible, |
| 117 jfloat progress_bar_height, | 114 jfloat progress_bar_height, |
| 118 jfloat progress_bar_opacity, | 115 jfloat progress_bar_opacity, |
| 119 jint progress_bar_completion, | 116 jint progress_bar_completion, |
| 120 jfloat divider_line_visibility_percentage, | 117 jfloat divider_line_visibility_percentage, |
| 121 jfloat divider_line_width, | 118 jfloat divider_line_width, |
| 122 jfloat divider_line_height, | 119 jfloat divider_line_height, |
| 123 jint divider_line_color, | 120 jint divider_line_color, |
| 124 jfloat divider_line_x_offset, | 121 jfloat divider_line_x_offset, |
| 125 jboolean touch_highlight_visible, | 122 jboolean touch_highlight_visible, |
| 126 jfloat touch_highlight_x_offset, | 123 jfloat touch_highlight_x_offset, |
| 127 jfloat touch_highlight_width, | 124 jfloat touch_highlight_width, |
| 128 jobject j_profile) { | 125 jobject j_profile) { |
| 129 | |
| 130 // Load the thumbnail if necessary. | 126 // Load the thumbnail if necessary. |
| 131 std::string thumbnail_url = | 127 std::string thumbnail_url = |
| 132 base::android::ConvertJavaStringToUTF8(env, j_thumbnail_url); | 128 base::android::ConvertJavaStringToUTF8(env, j_thumbnail_url); |
| 133 if (thumbnail_url != thumbnail_url_) { | 129 if (thumbnail_url != thumbnail_url_) { |
| 134 thumbnail_url_ = thumbnail_url; | 130 thumbnail_url_ = thumbnail_url; |
| 135 FetchThumbnail(j_profile); | 131 FetchThumbnail(j_profile); |
| 136 } | 132 } |
| 137 | 133 |
| 138 // NOTE(pedrosimonetti): The WebContents might not exist at this time if | 134 // NOTE(pedrosimonetti): The WebContents might not exist at this time if |
| 139 // the Contextual Search Result has not been requested yet. In this case, | 135 // the Contextual Search Result has not been requested yet. In this case, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 152 filters.Append( | 148 filters.Append( |
| 153 cc::FilterOperation::CreateBrightnessFilter(base_page_brightness)); | 149 cc::FilterOperation::CreateBrightnessFilter(base_page_brightness)); |
| 154 } | 150 } |
| 155 content_container_->SetFilters(filters); | 151 content_container_->SetFilters(filters); |
| 156 } | 152 } |
| 157 | 153 |
| 158 // Move the base page contents up. | 154 // Move the base page contents up. |
| 159 content_container_->SetPosition(gfx::PointF(0.0f, base_page_offset)); | 155 content_container_->SetPosition(gfx::PointF(0.0f, base_page_offset)); |
| 160 | 156 |
| 161 contextual_search_layer_->SetProperties( | 157 contextual_search_layer_->SetProperties( |
| 162 search_bar_background_resource_id, | 158 search_bar_background_resource_id, search_context_resource_id, |
| 163 search_context_resource_id, | 159 search_term_resource_id, search_caption_resource_id, |
| 164 search_term_resource_id, | 160 search_bar_shadow_resource_id, search_provider_icon_resource_id, |
| 165 search_caption_resource_id, | 161 quick_action_icon_resource_id, arrow_up_resource_id, |
| 166 search_bar_shadow_resource_id, | 162 close_icon_resource_id, progress_bar_background_resource_id, |
| 167 sprite_resource_id, | 163 progress_bar_resource_id, search_promo_resource_id, |
| 168 search_provider_icon_sprite_metadata_resource_id, | 164 peek_promo_ripple_resource_id, peek_promo_text_resource_id, dp_to_px, |
| 169 quick_action_icon_resource_id, | 165 content_layer, search_promo_visible, search_promo_height, |
| 170 arrow_up_resource_id, | 166 search_promo_opacity, search_peek_promo_visible, search_peek_promo_height, |
| 171 close_icon_resource_id, | 167 search_peek_promo_padding, search_peek_promo_ripple_width, |
| 172 progress_bar_background_resource_id, | 168 search_peek_promo_ripple_opacity, search_peek_promo_text_opacity, |
| 173 progress_bar_resource_id, | 169 search_panel_x, search_panel_y, search_panel_width, search_panel_height, |
| 174 search_promo_resource_id, | 170 search_bar_margin_side, search_bar_height, search_context_opacity, |
| 175 peek_promo_ripple_resource_id, | 171 search_text_layer_min_height, search_term_opacity, |
| 176 peek_promo_text_resource_id, | 172 search_term_caption_spacing, search_caption_animation_percentage, |
| 177 dp_to_px, | 173 search_caption_visible, search_bar_border_visible, |
| 178 content_layer, | 174 search_bar_border_height, search_bar_shadow_visible, |
| 179 search_promo_visible, | 175 search_bar_shadow_opacity, quick_action_icon_visible, thumbnail_visible, |
| 180 search_promo_height, | 176 custom_image_visibility_percentage, bar_image_size, arrow_icon_opacity, |
| 181 search_promo_opacity, | 177 arrow_icon_rotation, close_icon_opacity, progress_bar_visible, |
| 182 search_peek_promo_visible, | 178 progress_bar_height, progress_bar_opacity, progress_bar_completion, |
| 183 search_peek_promo_height, | 179 divider_line_visibility_percentage, divider_line_width, |
| 184 search_peek_promo_padding, | 180 divider_line_height, divider_line_color, divider_line_x_offset, |
| 185 search_peek_promo_ripple_width, | 181 touch_highlight_visible, touch_highlight_x_offset, touch_highlight_width); |
| 186 search_peek_promo_ripple_opacity, | |
| 187 search_peek_promo_text_opacity, | |
| 188 search_panel_x, | |
| 189 search_panel_y, | |
| 190 search_panel_width, | |
| 191 search_panel_height, | |
| 192 search_bar_margin_side, | |
| 193 search_bar_height, | |
| 194 search_context_opacity, | |
| 195 search_text_layer_min_height, | |
| 196 search_term_opacity, | |
| 197 search_term_caption_spacing, | |
| 198 search_caption_animation_percentage, | |
| 199 search_caption_visible, | |
| 200 search_bar_border_visible, | |
| 201 search_bar_border_height, | |
| 202 search_bar_shadow_visible, | |
| 203 search_bar_shadow_opacity, | |
| 204 search_provider_icon_sprite_visible, | |
| 205 search_provider_icon_sprite_completion_percentage, | |
| 206 quick_action_icon_visible, | |
| 207 thumbnail_visible, | |
| 208 static_image_visibility_percentage, | |
| 209 static_image_size, | |
| 210 arrow_icon_opacity, | |
| 211 arrow_icon_rotation, | |
| 212 close_icon_opacity, | |
| 213 progress_bar_visible, | |
| 214 progress_bar_height, | |
| 215 progress_bar_opacity, | |
| 216 progress_bar_completion, | |
| 217 divider_line_visibility_percentage, | |
| 218 divider_line_width, | |
| 219 divider_line_height, | |
| 220 divider_line_color, | |
| 221 divider_line_x_offset, | |
| 222 touch_highlight_visible, | |
| 223 touch_highlight_x_offset, | |
| 224 touch_highlight_width); | |
| 225 | 182 |
| 226 // Make the layer visible if it is not already. | 183 // Make the layer visible if it is not already. |
| 227 contextual_search_layer_->layer()->SetHideLayerAndSubtree(false); | 184 contextual_search_layer_->layer()->SetHideLayerAndSubtree(false); |
| 228 } | 185 } |
| 229 | 186 |
| 230 void ContextualSearchSceneLayer::FetchThumbnail(jobject j_profile) { | 187 void ContextualSearchSceneLayer::FetchThumbnail(jobject j_profile) { |
| 231 if (thumbnail_url_.empty()) | 188 if (thumbnail_url_.empty()) |
| 232 return; | 189 return; |
| 233 | 190 |
| 234 GURL gurl(thumbnail_url_); | 191 GURL gurl(thumbnail_url_); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 ContextualSearchSceneLayer* tree_provider = | 244 ContextualSearchSceneLayer* tree_provider = |
| 288 new ContextualSearchSceneLayer(env, jobj); | 245 new ContextualSearchSceneLayer(env, jobj); |
| 289 return reinterpret_cast<intptr_t>(tree_provider); | 246 return reinterpret_cast<intptr_t>(tree_provider); |
| 290 } | 247 } |
| 291 | 248 |
| 292 bool RegisterContextualSearchSceneLayer(JNIEnv* env) { | 249 bool RegisterContextualSearchSceneLayer(JNIEnv* env) { |
| 293 return RegisterNativesImpl(env); | 250 return RegisterNativesImpl(env); |
| 294 } | 251 } |
| 295 | 252 |
| 296 } // namespace android | 253 } // namespace android |
| OLD | NEW |