| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/layer/toolbar_layer.h" | 5 #include "chrome/browser/android/compositor/layer/toolbar_layer.h" |
| 6 | 6 |
| 7 #include "cc/layers/solid_color_layer.h" | 7 #include "cc/layers/solid_color_layer.h" |
| 8 #include "cc/layers/ui_resource_layer.h" | 8 #include "cc/layers/ui_resource_layer.h" |
| 9 #include "content/public/browser/android/compositor.h" | 9 #include "content/public/browser/android/compositor.h" |
| 10 #include "third_party/skia/include/core/SkColor.h" | 10 #include "third_party/skia/include/core/SkColor.h" |
| 11 #include "ui/android/resources/resource_manager.h" | 11 #include "ui/android/resources/resource_manager.h" |
| 12 #include "ui/android/resources/ui_resource_android.h" | 12 #include "ui/android/resources/ui_resource_android.h" |
| 13 | 13 |
| 14 const SkColor kNormalAnonymizeContentColor = SK_ColorWHITE; | 14 const SkColor kNormalAnonymizeContentColor = SK_ColorWHITE; |
| 15 const SkColor kIncognitoAnonymizeContentColor = 0xFF737373; | |
| 16 | 15 |
| 17 namespace chrome { | 16 namespace chrome { |
| 18 namespace android { | 17 namespace android { |
| 19 | 18 |
| 20 // static | 19 // static |
| 21 scoped_refptr<ToolbarLayer> ToolbarLayer::Create() { | 20 scoped_refptr<ToolbarLayer> ToolbarLayer::Create() { |
| 22 return make_scoped_refptr(new ToolbarLayer()); | 21 return make_scoped_refptr(new ToolbarLayer()); |
| 23 } | 22 } |
| 24 | 23 |
| 25 scoped_refptr<cc::Layer> ToolbarLayer::layer() { | 24 scoped_refptr<cc::Layer> ToolbarLayer::layer() { |
| 26 return layer_; | 25 return layer_; |
| 27 } | 26 } |
| 28 | 27 |
| 29 void ToolbarLayer::PushResource( | 28 void ToolbarLayer::PushResource( |
| 30 ui::ResourceManager::Resource* resource, | 29 ui::ResourceManager::Resource* resource, |
| 31 bool anonymize, | 30 bool anonymize, |
| 32 bool anonymize_component_is_incognito, | 31 int toolbar_textbox_background_color, |
| 33 bool show_debug) { | 32 bool show_debug) { |
| 34 DCHECK(resource); | 33 DCHECK(resource); |
| 35 | 34 |
| 36 // This layer effectively draws over the space it takes for shadows. Set the | 35 // This layer effectively draws over the space it takes for shadows. Set the |
| 37 // bounds to the non-shadow size so that other things can properly line up. | 36 // bounds to the non-shadow size so that other things can properly line up. |
| 38 layer_->SetBounds(resource->padding.size()); | 37 layer_->SetBounds(resource->padding.size()); |
| 39 | 38 |
| 40 bitmap_layer_->SetUIResourceId(resource->ui_resource->id()); | 39 bitmap_layer_->SetUIResourceId(resource->ui_resource->id()); |
| 41 bitmap_layer_->SetBounds(resource->size); | 40 bitmap_layer_->SetBounds(resource->size); |
| 42 | 41 |
| 43 anonymize_layer_->SetHideLayerAndSubtree(!anonymize); | 42 anonymize_layer_->SetHideLayerAndSubtree(!anonymize); |
| 44 if (anonymize) { | 43 if (anonymize) { |
| 45 anonymize_layer_->SetPosition(resource->aperture.origin()); | 44 anonymize_layer_->SetPosition(resource->aperture.origin()); |
| 46 anonymize_layer_->SetBounds(resource->aperture.size()); | 45 anonymize_layer_->SetBounds(resource->aperture.size()); |
| 47 anonymize_layer_->SetBackgroundColor(anonymize_component_is_incognito | 46 anonymize_layer_->SetBackgroundColor(toolbar_textbox_background_color); |
| 48 ? kIncognitoAnonymizeContentColor | |
| 49 : kNormalAnonymizeContentColor); | |
| 50 } | 47 } |
| 51 | 48 |
| 52 debug_layer_->SetBounds(resource->size); | 49 debug_layer_->SetBounds(resource->size); |
| 53 if (show_debug && !debug_layer_->parent()) | 50 if (show_debug && !debug_layer_->parent()) |
| 54 layer_->AddChild(debug_layer_); | 51 layer_->AddChild(debug_layer_); |
| 55 else if (!show_debug && debug_layer_->parent()) | 52 else if (!show_debug && debug_layer_->parent()) |
| 56 debug_layer_->RemoveFromParent(); | 53 debug_layer_->RemoveFromParent(); |
| 57 } | 54 } |
| 58 | 55 |
| 59 void ToolbarLayer::UpdateProgressBar(int progress_bar_x, | 56 void ToolbarLayer::UpdateProgressBar(int progress_bar_x, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 debug_layer_->SetIsDrawable(true); | 118 debug_layer_->SetIsDrawable(true); |
| 122 debug_layer_->SetBackgroundColor(SK_ColorGREEN); | 119 debug_layer_->SetBackgroundColor(SK_ColorGREEN); |
| 123 debug_layer_->SetOpacity(0.5f); | 120 debug_layer_->SetOpacity(0.5f); |
| 124 } | 121 } |
| 125 | 122 |
| 126 ToolbarLayer::~ToolbarLayer() { | 123 ToolbarLayer::~ToolbarLayer() { |
| 127 } | 124 } |
| 128 | 125 |
| 129 } // namespace android | 126 } // namespace android |
| 130 } // namespace chrome | 127 } // namespace chrome |
| OLD | NEW |