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; | |
15 const SkColor kIncognitoAnonymizeContentColor = 0xFF737373; | |
16 | |
17 namespace chrome { | 14 namespace chrome { |
18 namespace android { | 15 namespace android { |
19 | 16 |
20 // static | 17 // static |
21 scoped_refptr<ToolbarLayer> ToolbarLayer::Create() { | 18 scoped_refptr<ToolbarLayer> ToolbarLayer::Create() { |
22 return make_scoped_refptr(new ToolbarLayer()); | 19 return make_scoped_refptr(new ToolbarLayer()); |
23 } | 20 } |
24 | 21 |
25 scoped_refptr<cc::Layer> ToolbarLayer::layer() { | 22 scoped_refptr<cc::Layer> ToolbarLayer::layer() { |
26 return layer_; | 23 return layer_; |
27 } | 24 } |
28 | 25 |
29 void ToolbarLayer::PushResource( | 26 void ToolbarLayer::PushResource( |
30 ui::ResourceManager::Resource* resource, | 27 ui::ResourceManager::Resource* resource, |
31 bool anonymize, | 28 bool anonymize, |
32 bool anonymize_component_is_incognito, | 29 int toolbar_textbox_background_color, |
33 bool show_debug, | 30 bool show_debug, |
34 float brightness) { | 31 float brightness) { |
35 DCHECK(resource); | 32 DCHECK(resource); |
36 | 33 |
37 // This layer effectively draws over the space it takes for shadows. Set the | 34 // This layer effectively draws over the space it takes for shadows. Set the |
38 // bounds to the non-shadow size so that other things can properly line up. | 35 // bounds to the non-shadow size so that other things can properly line up. |
39 layer_->SetBounds(resource->padding.size()); | 36 layer_->SetBounds(resource->padding.size()); |
40 | 37 |
41 bitmap_layer_->SetUIResourceId(resource->ui_resource->id()); | 38 bitmap_layer_->SetUIResourceId(resource->ui_resource->id()); |
42 bitmap_layer_->SetBounds(resource->size); | 39 bitmap_layer_->SetBounds(resource->size); |
43 | 40 |
44 anonymize_layer_->SetHideLayerAndSubtree(!anonymize); | 41 anonymize_layer_->SetHideLayerAndSubtree(!anonymize); |
45 if (anonymize) { | 42 if (anonymize) { |
46 anonymize_layer_->SetPosition(resource->aperture.origin()); | 43 anonymize_layer_->SetPosition(resource->aperture.origin()); |
47 anonymize_layer_->SetBounds(resource->aperture.size()); | 44 anonymize_layer_->SetBounds(resource->aperture.size()); |
48 anonymize_layer_->SetBackgroundColor(anonymize_component_is_incognito | 45 anonymize_layer_->SetBackgroundColor(toolbar_textbox_background_color); |
49 ? kIncognitoAnonymizeContentColor | |
50 : kNormalAnonymizeContentColor); | |
51 } | 46 } |
52 | 47 |
53 debug_layer_->SetBounds(resource->size); | 48 debug_layer_->SetBounds(resource->size); |
54 if (show_debug && !debug_layer_->parent()) | 49 if (show_debug && !debug_layer_->parent()) |
55 layer_->AddChild(debug_layer_); | 50 layer_->AddChild(debug_layer_); |
56 else if (!show_debug && debug_layer_->parent()) | 51 else if (!show_debug && debug_layer_->parent()) |
57 debug_layer_->RemoveFromParent(); | 52 debug_layer_->RemoveFromParent(); |
58 | 53 |
59 if (brightness != brightness_) { | 54 if (brightness != brightness_) { |
60 brightness_ = brightness; | 55 brightness_ = brightness; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 113 |
119 progress_bar_background_layer_->SetIsDrawable(true); | 114 progress_bar_background_layer_->SetIsDrawable(true); |
120 progress_bar_background_layer_->SetHideLayerAndSubtree(true); | 115 progress_bar_background_layer_->SetHideLayerAndSubtree(true); |
121 layer_->AddChild(progress_bar_background_layer_); | 116 layer_->AddChild(progress_bar_background_layer_); |
122 | 117 |
123 progress_bar_layer_->SetIsDrawable(true); | 118 progress_bar_layer_->SetIsDrawable(true); |
124 progress_bar_layer_->SetHideLayerAndSubtree(true); | 119 progress_bar_layer_->SetHideLayerAndSubtree(true); |
125 layer_->AddChild(progress_bar_layer_); | 120 layer_->AddChild(progress_bar_layer_); |
126 | 121 |
127 anonymize_layer_->SetIsDrawable(true); | 122 anonymize_layer_->SetIsDrawable(true); |
128 anonymize_layer_->SetBackgroundColor(kNormalAnonymizeContentColor); | 123 anonymize_layer_->SetBackgroundColor(SK_ColorWHITE); |
129 layer_->AddChild(anonymize_layer_); | 124 layer_->AddChild(anonymize_layer_); |
130 | 125 |
131 debug_layer_->SetIsDrawable(true); | 126 debug_layer_->SetIsDrawable(true); |
132 debug_layer_->SetBackgroundColor(SK_ColorGREEN); | 127 debug_layer_->SetBackgroundColor(SK_ColorGREEN); |
133 debug_layer_->SetOpacity(0.5f); | 128 debug_layer_->SetOpacity(0.5f); |
134 } | 129 } |
135 | 130 |
136 ToolbarLayer::~ToolbarLayer() { | 131 ToolbarLayer::~ToolbarLayer() { |
137 } | 132 } |
138 | 133 |
139 } // namespace android | 134 } // namespace android |
140 } // namespace chrome | 135 } // namespace chrome |
OLD | NEW |