This source file includes following definitions.
- status_bubble_
- SetStatusBubble
- NeedsNotificationWhenVisibleBoundsChange
- OnVisibleBoundsChanged
- ViewHierarchyChanged
- OnThemeChanged
#include "chrome/browser/ui/views/frame/contents_web_view.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/views/status_bubble_views.h"
#include "ui/base/theme_provider.h"
#include "ui/views/background.h"
ContentsWebView::ContentsWebView(content::BrowserContext* browser_context)
: views::WebView(browser_context),
status_bubble_(NULL) {
}
ContentsWebView::~ContentsWebView() {
}
void ContentsWebView::SetStatusBubble(StatusBubbleViews* status_bubble) {
status_bubble_ = status_bubble;
DCHECK(!status_bubble_ || status_bubble_->base_view() == this);
if (status_bubble_)
status_bubble_->Reposition();
}
bool ContentsWebView::NeedsNotificationWhenVisibleBoundsChange() const {
return true;
}
void ContentsWebView::OnVisibleBoundsChanged() {
if (status_bubble_)
status_bubble_->Reposition();
}
void ContentsWebView::ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) {
WebView::ViewHierarchyChanged(details);
if (details.is_add)
OnThemeChanged();
}
void ContentsWebView::OnThemeChanged() {
ui::ThemeProvider* const theme = GetThemeProvider();
if (!theme)
return;
const int kBackgroundBrightness = 0x33;
const SkColor ntp_background =
theme->GetColor(ThemeProperties::COLOR_NTP_BACKGROUND);
set_background(views::Background::CreateSolidBackground(
SkColorGetR(ntp_background) * kBackgroundBrightness / 0xFF,
SkColorGetG(ntp_background) * kBackgroundBrightness / 0xFF,
SkColorGetB(ntp_background) * kBackgroundBrightness / 0xFF,
SkColorGetA(ntp_background)));
}