OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/extensions/extension_view.h" | 5 #include "chrome/browser/extensions/extension_view.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_host.h" | 7 #include "chrome/browser/extensions/extension_host.h" |
8 #include "chrome/browser/renderer_host/render_view_host.h" | 8 #include "chrome/browser/renderer_host/render_view_host.h" |
9 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 9 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
11 #include "chrome/browser/renderer_host/render_widget_host_view_win.h" | 11 #include "chrome/browser/renderer_host/render_widget_host_view_win.h" |
12 #endif | 12 #endif |
| 13 #include "chrome/common/notification_service.h" |
| 14 #include "chrome/common/notification_type.h" |
13 #include "views/widget/widget.h" | 15 #include "views/widget/widget.h" |
14 | 16 |
15 ExtensionView::ExtensionView(ExtensionHost* host, Browser* browser) | 17 ExtensionView::ExtensionView(ExtensionHost* host, Browser* browser) |
16 : host_(host), browser_(browser), | 18 : host_(host), browser_(browser), |
17 initialized_(false), pending_preferred_width_(0), container_(NULL) { | 19 initialized_(false), pending_preferred_width_(0), container_(NULL) { |
18 host_->set_view(this); | 20 host_->set_view(this); |
| 21 registrar_.Add(this, NotificationType::BROWSER_CLOSED, |
| 22 Source<Browser>(browser_)); |
19 } | 23 } |
20 | 24 |
21 ExtensionView::~ExtensionView() { | 25 ExtensionView::~ExtensionView() { |
22 if (native_view()) | 26 if (native_view()) |
23 Detach(); | 27 Detach(); |
24 } | 28 } |
25 | 29 |
26 Extension* ExtensionView::extension() const { | 30 Extension* ExtensionView::extension() const { |
27 return host_->extension(); | 31 return host_->extension(); |
28 } | 32 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 host_->CreateRenderView(view); | 117 host_->CreateRenderView(view); |
114 SetVisible(false); | 118 SetVisible(false); |
115 | 119 |
116 if (!pending_background_.empty()) { | 120 if (!pending_background_.empty()) { |
117 render_view_host()->view()->SetBackground(pending_background_); | 121 render_view_host()->view()->SetBackground(pending_background_); |
118 pending_background_.reset(); | 122 pending_background_.reset(); |
119 } | 123 } |
120 } | 124 } |
121 } | 125 } |
122 | 126 |
| 127 void ExtensionView::Observe(NotificationType type, |
| 128 const NotificationSource& source, |
| 129 const NotificationDetails& details) { |
| 130 if (type == NotificationType::BROWSER_CLOSED) { |
| 131 delete host_; // which in turn deletes this |
| 132 } else { |
| 133 NOTREACHED(); |
| 134 } |
| 135 } |
| 136 |
123 void ExtensionView::HandleMouseEvent() { | 137 void ExtensionView::HandleMouseEvent() { |
124 if (container_) | 138 if (container_) |
125 container_->OnExtensionMouseEvent(this); | 139 container_->OnExtensionMouseEvent(this); |
126 } | 140 } |
127 | 141 |
128 void ExtensionView::HandleMouseLeave() { | 142 void ExtensionView::HandleMouseLeave() { |
129 if (container_) | 143 if (container_) |
130 container_->OnExtensionMouseLeave(this); | 144 container_->OnExtensionMouseLeave(this); |
131 } | 145 } |
OLD | NEW |