Chromium Code Reviews| 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 content::RenderWidgetHostView* rwhv = nullptr; | |
| 70 if (web_contents()) | |
| 71 rwhv = web_contents()->GetRenderWidgetHostView(); | |
| 72 if (rwhv) | |
|
sky
2016/05/02 20:04:33
nit: move inside if block on 70 (or early return i
chrishtr
2016/05/02 20:24:02
Done.
| |
| 73 rwhv->SetBackgroundColor(ntp_background); | |
| 67 } | 74 } |
| 68 | 75 |
| 69 void ContentsWebView::OnLayerRecreated(ui::Layer* old_layer, | 76 void ContentsWebView::OnLayerRecreated(ui::Layer* old_layer, |
| 70 ui::Layer* new_layer) { | 77 ui::Layer* new_layer) { |
| 71 if (!cloned_layer_tree_) | 78 if (!cloned_layer_tree_) |
| 72 return; | 79 return; |
| 73 | 80 |
| 74 // Our layer has been recreated and we have a clone of the WebContents | 81 // 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 | 82 // 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 | 83 // 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( | 114 cloned_layer_tree_->root()->SetBounds( |
| 108 gfx::Rect(origin, cloned_layer_tree_->root()->bounds().size())); | 115 gfx::Rect(origin, cloned_layer_tree_->root()->bounds().size())); |
| 109 layer()->Add(cloned_layer_tree_->root()); | 116 layer()->Add(cloned_layer_tree_->root()); |
| 110 } | 117 } |
| 111 | 118 |
| 112 void ContentsWebView::DestroyClonedLayer() { | 119 void ContentsWebView::DestroyClonedLayer() { |
| 113 cloned_layer_tree_.reset(); | 120 cloned_layer_tree_.reset(); |
| 114 SetPaintToLayer(false); | 121 SetPaintToLayer(false); |
| 115 set_layer_owner_delegate(nullptr); | 122 set_layer_owner_delegate(nullptr); |
| 116 } | 123 } |
| 124 | |
| 125 void ContentsWebView::RenderViewReady() { | |
| 126 // Apply the theme color to be the default background on startup. | |
| 127 OnThemeChanged(); | |
| 128 WebView::RenderViewReady(); | |
| 129 } | |
| OLD | NEW |