OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chromeos/notifications/balloon_view.h" | 5 #include "chrome/browser/chromeos/notifications/balloon_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 web_ui_(web_ui) { | 207 web_ui_(web_ui) { |
208 // This object is not to be deleted by the views hierarchy, | 208 // This object is not to be deleted by the views hierarchy, |
209 // as it is owned by the balloon. | 209 // as it is owned by the balloon. |
210 set_parent_owned(false); | 210 set_parent_owned(false); |
211 } | 211 } |
212 | 212 |
213 BalloonViewImpl::~BalloonViewImpl() { | 213 BalloonViewImpl::~BalloonViewImpl() { |
214 if (control_view_host_.get()) { | 214 if (control_view_host_.get()) { |
215 control_view_host_->CloseNow(); | 215 control_view_host_->CloseNow(); |
216 } | 216 } |
217 if (html_contents_) { | 217 if (html_contents_.get()) { |
218 html_contents_->Shutdown(); | 218 html_contents_->Shutdown(); |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 //////////////////////////////////////////////////////////////////////////////// | 222 //////////////////////////////////////////////////////////////////////////////// |
223 // BallonViewImpl, BalloonView implementation. | 223 // BallonViewImpl, BalloonView implementation. |
224 | 224 |
225 void BalloonViewImpl::Show(Balloon* balloon) { | 225 void BalloonViewImpl::Show(Balloon* balloon) { |
226 balloon_ = balloon; | 226 balloon_ = balloon; |
227 html_contents_ = new BalloonViewHost(balloon); | 227 html_contents_.reset(new BalloonViewHost(balloon)); |
228 if (web_ui_) | 228 if (web_ui_) |
229 html_contents_->EnableWebUI(); | 229 html_contents_->EnableWebUI(); |
230 AddChildView(html_contents_->view()); | 230 AddChildView(html_contents_->view()); |
231 notification_registrar_.Add(this, | 231 notification_registrar_.Add(this, |
232 chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED, | 232 chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED, |
233 content::Source<Balloon>(balloon)); | 233 content::Source<Balloon>(balloon)); |
234 } | 234 } |
235 | 235 |
236 void BalloonViewImpl::Update() { | 236 void BalloonViewImpl::Update() { |
237 stale_ = false; | 237 stale_ = false; |
(...skipping 10 matching lines...) Expand all Loading... |
248 FROM_HERE, | 248 FROM_HERE, |
249 base::Bind(&BalloonViewImpl::DelayedClose, AsWeakPtr(), by_user)); | 249 base::Bind(&BalloonViewImpl::DelayedClose, AsWeakPtr(), by_user)); |
250 } | 250 } |
251 | 251 |
252 gfx::Size BalloonViewImpl::GetSize() const { | 252 gfx::Size BalloonViewImpl::GetSize() const { |
253 // Not used. The layout is managed by the Panel. | 253 // Not used. The layout is managed by the Panel. |
254 return gfx::Size(0, 0); | 254 return gfx::Size(0, 0); |
255 } | 255 } |
256 | 256 |
257 BalloonHost* BalloonViewImpl::GetHost() const { | 257 BalloonHost* BalloonViewImpl::GetHost() const { |
258 return html_contents_; | 258 return html_contents_.get(); |
259 } | 259 } |
260 | 260 |
261 void BalloonViewImpl::RepositionToBalloon() { | 261 void BalloonViewImpl::RepositionToBalloon() { |
262 // Not used. The layout is managed by the Panel. | 262 // Not used. The layout is managed by the Panel. |
263 } | 263 } |
264 | 264 |
265 //////////////////////////////////////////////////////////////////////////////// | 265 //////////////////////////////////////////////////////////////////////////////// |
266 // views::View interface overrides. | 266 // views::View interface overrides. |
267 | 267 |
268 void BalloonViewImpl::Layout() { | 268 void BalloonViewImpl::Layout() { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 if (control_view_host_.get()) { | 345 if (control_view_host_.get()) { |
346 control_view_host_->Hide(); | 346 control_view_host_->Hide(); |
347 } | 347 } |
348 } | 348 } |
349 | 349 |
350 //////////////////////////////////////////////////////////////////////////////// | 350 //////////////////////////////////////////////////////////////////////////////// |
351 // BalloonViewImpl private. | 351 // BalloonViewImpl private. |
352 | 352 |
353 void BalloonViewImpl::DelayedClose(bool by_user) { | 353 void BalloonViewImpl::DelayedClose(bool by_user) { |
354 html_contents_->Shutdown(); | 354 html_contents_->Shutdown(); |
355 html_contents_ = NULL; | 355 html_contents_.reset(); |
356 balloon_->OnClose(by_user); | 356 balloon_->OnClose(by_user); |
357 } | 357 } |
358 | 358 |
359 void BalloonViewImpl::DenyPermission() { | 359 void BalloonViewImpl::DenyPermission() { |
360 DesktopNotificationService* service = | 360 DesktopNotificationService* service = |
361 DesktopNotificationServiceFactory::GetForProfile(balloon_->profile()); | 361 DesktopNotificationServiceFactory::GetForProfile(balloon_->profile()); |
362 service->DenyPermission(balloon_->notification().origin_url()); | 362 service->DenyPermission(balloon_->notification().origin_url()); |
363 } | 363 } |
364 | 364 |
365 gfx::NativeView BalloonViewImpl::GetParentNativeView() { | 365 gfx::NativeView BalloonViewImpl::GetParentNativeView() { |
366 RenderWidgetHostView* view = | 366 RenderWidgetHostView* view = |
367 html_contents_->tab_contents()->render_view_host()->view(); | 367 html_contents_->tab_contents()->render_view_host()->view(); |
368 DCHECK(view); | 368 DCHECK(view); |
369 return view->GetNativeView(); | 369 return view->GetNativeView(); |
370 } | 370 } |
371 | 371 |
372 } // namespace chromeos | 372 } // namespace chromeos |
OLD | NEW |