| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 const std::wstring source_label_text = l10n_util::GetStringF( | 65 const std::wstring source_label_text = l10n_util::GetStringF( |
| 66 IDS_NOTIFICATION_BALLOON_SOURCE_LABEL, | 66 IDS_NOTIFICATION_BALLOON_SOURCE_LABEL, |
| 67 balloon->notification().display_source()); | 67 balloon->notification().display_source()); |
| 68 const std::wstring options_text = | 68 const std::wstring options_text = |
| 69 l10n_util::GetString(IDS_NOTIFICATION_OPTIONS_MENU_LABEL); | 69 l10n_util::GetString(IDS_NOTIFICATION_OPTIONS_MENU_LABEL); |
| 70 const std::wstring dismiss_text = | 70 const std::wstring dismiss_text = |
| 71 l10n_util::GetString(IDS_NOTIFICATION_BALLOON_DISMISS_LABEL); | 71 l10n_util::GetString(IDS_NOTIFICATION_BALLOON_DISMISS_LABEL); |
| 72 balloon_ = balloon; | 72 balloon_ = balloon; |
| 73 | 73 |
| 74 html_contents_ = new BalloonViewHost(balloon); | 74 html_contents_ = new BalloonViewHost(balloon); |
| 75 AddChildView(html_contents_); | 75 AddChildView(html_contents_->view()); |
| 76 if (controls_) { | 76 if (controls_) { |
| 77 close_button_ = new views::TextButton(this, dismiss_text); | 77 close_button_ = new views::TextButton(this, dismiss_text); |
| 78 close_button_->SetIcon(*rb.GetBitmapNamed(IDR_BALLOON_CLOSE)); | 78 close_button_->SetIcon(*rb.GetBitmapNamed(IDR_BALLOON_CLOSE)); |
| 79 close_button_->SetHoverIcon(*rb.GetBitmapNamed(IDR_BALLOON_CLOSE_HOVER)); | 79 close_button_->SetHoverIcon(*rb.GetBitmapNamed(IDR_BALLOON_CLOSE_HOVER)); |
| 80 close_button_->SetFont(rb.GetFont(ResourceBundle::SmallFont)); | 80 close_button_->SetFont(rb.GetFont(ResourceBundle::SmallFont)); |
| 81 close_button_->SetEnabledColor(SK_ColorWHITE); | 81 close_button_->SetEnabledColor(SK_ColorWHITE); |
| 82 close_button_->SetHoverColor(SK_ColorDKGRAY); | 82 close_button_->SetHoverColor(SK_ColorDKGRAY); |
| 83 close_button_->set_alignment(views::TextButton::ALIGN_CENTER); | 83 close_button_->set_alignment(views::TextButton::ALIGN_CENTER); |
| 84 close_button_->set_icon_placement(views::TextButton::ICON_ON_RIGHT); | 84 close_button_->set_icon_placement(views::TextButton::ICON_ON_RIGHT); |
| 85 AddChildView(close_button_); | 85 AddChildView(close_button_); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 102 source_label_->SetColor(SK_ColorWHITE); | 102 source_label_->SetColor(SK_ColorWHITE); |
| 103 source_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 103 source_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 104 AddChildView(source_label_); | 104 AddChildView(source_label_); |
| 105 } | 105 } |
| 106 notification_registrar_.Add(this, | 106 notification_registrar_.Add(this, |
| 107 NotificationType::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon)); | 107 NotificationType::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon)); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void BalloonViewImpl::Update() { | 110 void BalloonViewImpl::Update() { |
| 111 stale_ = false; | 111 stale_ = false; |
| 112 html_contents_->render_view_host()->NavigateToURL( | 112 if (html_contents_->render_view_host()) |
| 113 balloon_->notification().content_url()); | 113 html_contents_->render_view_host()->NavigateToURL( |
| 114 balloon_->notification().content_url()); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void BalloonViewImpl::Close(bool by_user) { | 117 void BalloonViewImpl::Close(bool by_user) { |
| 117 MessageLoop::current()->PostTask( | 118 MessageLoop::current()->PostTask( |
| 118 FROM_HERE, | 119 FROM_HERE, |
| 119 method_factory_.NewRunnableMethod( | 120 method_factory_.NewRunnableMethod( |
| 120 &BalloonViewImpl::DelayedClose, by_user)); | 121 &BalloonViewImpl::DelayedClose, by_user)); |
| 121 } | 122 } |
| 122 | 123 |
| 123 gfx::Size BalloonViewImpl::GetSize() const { | 124 gfx::Size BalloonViewImpl::GetSize() const { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 138 button_size = close_button_->GetPreferredSize(); | 139 button_size = close_button_->GetPreferredSize(); |
| 139 } | 140 } |
| 140 | 141 |
| 141 SetBounds(x(), y(), | 142 SetBounds(x(), y(), |
| 142 balloon_->content_size().width(), | 143 balloon_->content_size().width(), |
| 143 balloon_->content_size().height() + | 144 balloon_->content_size().height() + |
| 144 button_size.height()); | 145 button_size.height()); |
| 145 int x = width() - button_size.width(); | 146 int x = width() - button_size.width(); |
| 146 int y = height() - button_size.height(); | 147 int y = height() - button_size.height(); |
| 147 | 148 |
| 148 html_contents_->SetBounds(0, 0, width(), y); | 149 html_contents_->view()->SetBounds(0, 0, width(), y); |
| 149 if (html_contents_->render_view_host()) { | 150 if (html_contents_->render_view_host()) { |
| 150 RenderWidgetHostView* view = html_contents_->render_view_host()->view(); | 151 RenderWidgetHostView* view = html_contents_->render_view_host()->view(); |
| 151 if (view) | 152 if (view) |
| 152 view->SetSize(gfx::Size(width(), y)); | 153 view->SetSize(gfx::Size(width(), y)); |
| 153 } | 154 } |
| 154 if (controls_) { | 155 if (controls_) { |
| 155 close_button_->SetBounds(x, y, button_size.width(), button_size.height()); | 156 close_button_->SetBounds(x, y, button_size.width(), button_size.height()); |
| 156 x -= close_button_->GetPreferredSize().width(); | 157 x -= close_button_->GetPreferredSize().width(); |
| 157 options_menu_button_->SetBounds( | 158 options_menu_button_->SetBounds( |
| 158 x, y, button_size.width(), button_size.height()); | 159 x, y, button_size.width(), button_size.height()); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 options_menu_menu_.reset(new views::Menu2(options_menu_contents_.get())); | 243 options_menu_menu_.reset(new views::Menu2(options_menu_contents_.get())); |
| 243 } | 244 } |
| 244 | 245 |
| 245 void BalloonViewImpl::DelayedClose(bool by_user) { | 246 void BalloonViewImpl::DelayedClose(bool by_user) { |
| 246 html_contents_->Shutdown(); | 247 html_contents_->Shutdown(); |
| 247 html_contents_ = NULL; | 248 html_contents_ = NULL; |
| 248 balloon_->OnClose(by_user); | 249 balloon_->OnClose(by_user); |
| 249 } | 250 } |
| 250 | 251 |
| 251 } // namespace chromeos | 252 } // namespace chromeos |
| OLD | NEW |