Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / views / notifications / balloon_view_host.cc
blobc107dc7ad9577a202f439b9fa07a366b3718f600
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/notifications/balloon_view_host.h"
7 #include "chrome/browser/notifications/balloon.h"
8 #include "content/public/browser/content_browser_client.h"
9 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/render_widget_host_view.h"
11 #include "content/public/browser/web_contents.h"
12 #include "ui/views/widget/widget.h"
14 class BalloonViewHostView : public views::NativeViewHost {
15 public:
16 explicit BalloonViewHostView(BalloonViewHost* host)
17 : host_(host),
18 initialized_(false) {
21 virtual void ViewHierarchyChanged(
22 const ViewHierarchyChangedDetails& details) OVERRIDE {
23 NativeViewHost::ViewHierarchyChanged(details);
24 if (details.is_add && GetWidget() && !initialized_) {
25 initialized_ = true;
26 host_->Init(GetWidget()->GetNativeView());
30 private:
31 // The host owns this object.
32 BalloonViewHost* host_;
34 bool initialized_;
37 BalloonViewHost::BalloonViewHost(Balloon* balloon)
38 : BalloonHost(balloon) {
39 native_host_ = new BalloonViewHostView(this);
42 BalloonViewHost::~BalloonViewHost() {
43 Shutdown();
46 void BalloonViewHost::Init(gfx::NativeView parent_native_view) {
47 parent_native_view_ = parent_native_view;
48 BalloonHost::Init();
50 content::RenderWidgetHostView* render_widget_host_view =
51 web_contents_->GetRenderViewHost()->GetView();
53 native_host_->Attach(render_widget_host_view->GetNativeView());