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/ui/views/frame/contents_web_view.h" | 5 #include "chrome/browser/ui/views/frame/contents_web_view.h" |
6 | 6 |
7 #include "chrome/browser/themes/theme_properties.h" | 7 #include "chrome/browser/themes/theme_properties.h" |
8 #include "chrome/browser/ui/views/status_bubble_views.h" | 8 #include "chrome/browser/ui/views/status_bubble_views.h" |
| 9 #include "content/public/browser/render_widget_host_view.h" |
9 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
10 #include "ui/base/theme_provider.h" | 11 #include "ui/base/theme_provider.h" |
11 #include "ui/compositor/layer_tree_owner.h" | 12 #include "ui/compositor/layer_tree_owner.h" |
12 #include "ui/views/background.h" | 13 #include "ui/views/background.h" |
13 | 14 |
14 #if defined(USE_AURA) | 15 #if defined(USE_AURA) |
15 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
16 #include "ui/wm/core/window_util.h" | 17 #include "ui/wm/core/window_util.h" |
17 #endif | 18 #endif |
18 | 19 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // view is sized specially for fullscreen tab capture. See WebView header | 58 // view is sized specially for fullscreen tab capture. See WebView header |
58 // file comments for more details. | 59 // file comments for more details. |
59 const int kBackgroundBrightness = 0x33; // 20% | 60 const int kBackgroundBrightness = 0x33; // 20% |
60 const SkColor ntp_background = | 61 const SkColor ntp_background = |
61 theme->GetColor(ThemeProperties::COLOR_NTP_BACKGROUND); | 62 theme->GetColor(ThemeProperties::COLOR_NTP_BACKGROUND); |
62 set_background(views::Background::CreateSolidBackground( | 63 set_background(views::Background::CreateSolidBackground( |
63 SkColorGetR(ntp_background) * kBackgroundBrightness / 0xFF, | 64 SkColorGetR(ntp_background) * kBackgroundBrightness / 0xFF, |
64 SkColorGetG(ntp_background) * kBackgroundBrightness / 0xFF, | 65 SkColorGetG(ntp_background) * kBackgroundBrightness / 0xFF, |
65 SkColorGetB(ntp_background) * kBackgroundBrightness / 0xFF, | 66 SkColorGetB(ntp_background) * kBackgroundBrightness / 0xFF, |
66 SkColorGetA(ntp_background))); | 67 SkColorGetA(ntp_background))); |
| 68 |
| 69 |
| 70 if (web_contents()) { |
| 71 content::RenderWidgetHostView* rwhv = |
| 72 web_contents()->GetRenderWidgetHostView(); |
| 73 if (rwhv) |
| 74 rwhv->SetBackgroundColor(ntp_background); |
| 75 } |
67 } | 76 } |
68 | 77 |
69 void ContentsWebView::OnLayerRecreated(ui::Layer* old_layer, | 78 void ContentsWebView::OnLayerRecreated(ui::Layer* old_layer, |
70 ui::Layer* new_layer) { | 79 ui::Layer* new_layer) { |
71 if (!cloned_layer_tree_) | 80 if (!cloned_layer_tree_) |
72 return; | 81 return; |
73 | 82 |
74 // Our layer has been recreated and we have a clone of the WebContents | 83 // Our layer has been recreated and we have a clone of the WebContents |
75 // layer. Combined this means we're about to be destroyed and an animation is | 84 // layer. Combined this means we're about to be destroyed and an animation is |
76 // in effect. The animation cloned our layer, but it won't create another | 85 // in effect. The animation cloned our layer, but it won't create another |
(...skipping 30 matching lines...) Expand all Loading... |
107 cloned_layer_tree_->root()->SetBounds( | 116 cloned_layer_tree_->root()->SetBounds( |
108 gfx::Rect(origin, cloned_layer_tree_->root()->bounds().size())); | 117 gfx::Rect(origin, cloned_layer_tree_->root()->bounds().size())); |
109 layer()->Add(cloned_layer_tree_->root()); | 118 layer()->Add(cloned_layer_tree_->root()); |
110 } | 119 } |
111 | 120 |
112 void ContentsWebView::DestroyClonedLayer() { | 121 void ContentsWebView::DestroyClonedLayer() { |
113 cloned_layer_tree_.reset(); | 122 cloned_layer_tree_.reset(); |
114 SetPaintToLayer(false); | 123 SetPaintToLayer(false); |
115 set_layer_owner_delegate(nullptr); | 124 set_layer_owner_delegate(nullptr); |
116 } | 125 } |
| 126 |
| 127 void ContentsWebView::RenderViewReady() { |
| 128 // Apply the theme color to be the default background on startup. |
| 129 OnThemeChanged(); |
| 130 WebView::RenderViewReady(); |
| 131 } |
OLD | NEW |