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 <vector> | 8 #include <vector> |
8 | 9 |
| 10 #include "base/bind.h" |
9 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
10 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
11 #include "chrome/browser/chromeos/notifications/balloon_view_host.h" | 13 #include "chrome/browser/chromeos/notifications/balloon_view_host.h" |
12 #include "chrome/browser/chromeos/notifications/notification_panel.h" | 14 #include "chrome/browser/chromeos/notifications/notification_panel.h" |
13 #include "chrome/browser/notifications/balloon.h" | 15 #include "chrome/browser/notifications/balloon.h" |
14 #include "chrome/browser/notifications/desktop_notification_service.h" | 16 #include "chrome/browser/notifications/desktop_notification_service.h" |
15 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 17 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
16 #include "chrome/browser/notifications/notification.h" | 18 #include "chrome/browser/notifications/notification.h" |
17 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/ui/views/notifications/balloon_view_host.h" | 20 #include "chrome/browser/ui/views/notifications/balloon_view_host.h" |
19 #include "chrome/common/chrome_notification_types.h" | 21 #include "chrome/common/chrome_notification_types.h" |
20 #include "content/browser/renderer_host/render_view_host.h" | 22 #include "content/browser/renderer_host/render_view_host.h" |
21 #include "content/browser/renderer_host/render_widget_host_view.h" | 23 #include "content/browser/renderer_host/render_widget_host_view.h" |
22 #include "chrome/common/chrome_notification_types.h" | |
23 #include "content/public/browser/notification_details.h" | 24 #include "content/public/browser/notification_details.h" |
24 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
25 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
26 #include "grit/theme_resources.h" | 27 #include "grit/theme_resources.h" |
27 #include "grit/theme_resources_standard.h" | 28 #include "grit/theme_resources_standard.h" |
28 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
29 #include "ui/base/models/simple_menu_model.h" | 30 #include "ui/base/models/simple_menu_model.h" |
30 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
31 #include "views/background.h" | 32 #include "views/background.h" |
32 #include "views/controls/button/button.h" | 33 #include "views/controls/button/button.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 scoped_ptr<ui::SimpleMenuModel> options_menu_contents_; | 192 scoped_ptr<ui::SimpleMenuModel> options_menu_contents_; |
192 scoped_ptr<views::MenuRunner> menu_runner_; | 193 scoped_ptr<views::MenuRunner> menu_runner_; |
193 views::MenuButton* options_menu_button_; | 194 views::MenuButton* options_menu_button_; |
194 | 195 |
195 DISALLOW_COPY_AND_ASSIGN(NotificationControlView); | 196 DISALLOW_COPY_AND_ASSIGN(NotificationControlView); |
196 }; | 197 }; |
197 | 198 |
198 BalloonViewImpl::BalloonViewImpl(bool sticky, bool controls, bool web_ui) | 199 BalloonViewImpl::BalloonViewImpl(bool sticky, bool controls, bool web_ui) |
199 : balloon_(NULL), | 200 : balloon_(NULL), |
200 html_contents_(NULL), | 201 html_contents_(NULL), |
201 method_factory_(this), | |
202 stale_(false), | 202 stale_(false), |
203 sticky_(sticky), | 203 sticky_(sticky), |
204 controls_(controls), | 204 controls_(controls), |
205 closed_(false), | 205 closed_(false), |
206 web_ui_(web_ui) { | 206 web_ui_(web_ui) { |
207 // This object is not to be deleted by the views hierarchy, | 207 // This object is not to be deleted by the views hierarchy, |
208 // as it is owned by the balloon. | 208 // as it is owned by the balloon. |
209 set_parent_owned(false); | 209 set_parent_owned(false); |
210 } | 210 } |
211 | 211 |
(...skipping 24 matching lines...) Expand all Loading... |
236 stale_ = false; | 236 stale_ = false; |
237 if (html_contents_->render_view_host()) | 237 if (html_contents_->render_view_host()) |
238 html_contents_->render_view_host()->NavigateToURL( | 238 html_contents_->render_view_host()->NavigateToURL( |
239 balloon_->notification().content_url()); | 239 balloon_->notification().content_url()); |
240 } | 240 } |
241 | 241 |
242 void BalloonViewImpl::Close(bool by_user) { | 242 void BalloonViewImpl::Close(bool by_user) { |
243 closed_ = true; | 243 closed_ = true; |
244 MessageLoop::current()->PostTask( | 244 MessageLoop::current()->PostTask( |
245 FROM_HERE, | 245 FROM_HERE, |
246 method_factory_.NewRunnableMethod( | 246 base::Bind(&BalloonViewImpl::DelayedClose, AsWeakPtr(), by_user)); |
247 &BalloonViewImpl::DelayedClose, by_user)); | |
248 } | 247 } |
249 | 248 |
250 gfx::Size BalloonViewImpl::GetSize() const { | 249 gfx::Size BalloonViewImpl::GetSize() const { |
251 // Not used. The layout is managed by the Panel. | 250 // Not used. The layout is managed by the Panel. |
252 return gfx::Size(0, 0); | 251 return gfx::Size(0, 0); |
253 } | 252 } |
254 | 253 |
255 BalloonHost* BalloonViewImpl::GetHost() const { | 254 BalloonHost* BalloonViewImpl::GetHost() const { |
256 return html_contents_; | 255 return html_contents_; |
257 } | 256 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 service->DenyPermission(balloon_->notification().origin_url()); | 358 service->DenyPermission(balloon_->notification().origin_url()); |
360 } | 359 } |
361 | 360 |
362 gfx::NativeView BalloonViewImpl::GetParentNativeView() { | 361 gfx::NativeView BalloonViewImpl::GetParentNativeView() { |
363 RenderWidgetHostView* view = html_contents_->render_view_host()->view(); | 362 RenderWidgetHostView* view = html_contents_->render_view_host()->view(); |
364 DCHECK(view); | 363 DCHECK(view); |
365 return view->GetNativeView(); | 364 return view->GetNativeView(); |
366 } | 365 } |
367 | 366 |
368 } // namespace chromeos | 367 } // namespace chromeos |
OLD | NEW |