| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/views/notifications/balloon_view.h" | 5 #include "chrome/browser/views/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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 source_label_->SetBounds(GetLabelBounds()); | 179 source_label_->SetBounds(GetLabelBounds()); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void BalloonViewImpl::RepositionToBalloon() { | 182 void BalloonViewImpl::RepositionToBalloon() { |
| 183 DCHECK(frame_container_); | 183 DCHECK(frame_container_); |
| 184 DCHECK(html_container_); | 184 DCHECK(html_container_); |
| 185 DCHECK(balloon_); | 185 DCHECK(balloon_); |
| 186 | 186 |
| 187 if (!kAnimateEnabled) { | 187 if (!kAnimateEnabled) { |
| 188 frame_container_->SetBounds( | 188 frame_container_->SetBounds( |
| 189 gfx::Rect(balloon_->position().x(), balloon_->position().y(), | 189 gfx::Rect(balloon_->GetPosition().x(), balloon_->GetPosition().y(), |
| 190 GetTotalWidth(), GetTotalHeight())); | 190 GetTotalWidth(), GetTotalHeight())); |
| 191 gfx::Rect contents_rect = GetContentsRectangle(); | 191 gfx::Rect contents_rect = GetContentsRectangle(); |
| 192 html_container_->SetBounds(contents_rect); | 192 html_container_->SetBounds(contents_rect); |
| 193 html_contents_->SetPreferredSize(contents_rect.size()); | 193 html_contents_->SetPreferredSize(contents_rect.size()); |
| 194 RenderWidgetHostView* view = html_contents_->render_view_host()->view(); | 194 RenderWidgetHostView* view = html_contents_->render_view_host()->view(); |
| 195 if (view) | 195 if (view) |
| 196 view->SetSize(contents_rect.size()); | 196 view->SetSize(contents_rect.size()); |
| 197 return; | 197 return; |
| 198 } | 198 } |
| 199 | 199 |
| 200 anim_frame_end_ = gfx::Rect( | 200 anim_frame_end_ = gfx::Rect( |
| 201 balloon_->position().x(), balloon_->position().y(), | 201 balloon_->GetPosition().x(), balloon_->GetPosition().y(), |
| 202 GetTotalWidth(), GetTotalHeight()); | 202 GetTotalWidth(), GetTotalHeight()); |
| 203 frame_container_->GetBounds(&anim_frame_start_, false); | 203 frame_container_->GetBounds(&anim_frame_start_, false); |
| 204 animation_.reset(new SlideAnimation(this)); | 204 animation_.reset(new SlideAnimation(this)); |
| 205 animation_->Show(); | 205 animation_->Show(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void BalloonViewImpl::AnimationProgressed(const Animation* animation) { | 208 void BalloonViewImpl::AnimationProgressed(const Animation* animation) { |
| 209 DCHECK(animation == animation_.get()); | 209 DCHECK(animation == animation_.get()); |
| 210 | 210 |
| 211 // Linear interpolation from start to end position. | 211 // Linear interpolation from start to end position. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 267 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 268 | 268 |
| 269 const std::wstring source_label_text = l10n_util::GetStringF( | 269 const std::wstring source_label_text = l10n_util::GetStringF( |
| 270 IDS_NOTIFICATION_BALLOON_SOURCE_LABEL, | 270 IDS_NOTIFICATION_BALLOON_SOURCE_LABEL, |
| 271 balloon->notification().display_source()); | 271 balloon->notification().display_source()); |
| 272 const std::wstring dismiss_text = | 272 const std::wstring dismiss_text = |
| 273 l10n_util::GetString(IDS_NOTIFICATION_BALLOON_DISMISS_LABEL); | 273 l10n_util::GetString(IDS_NOTIFICATION_BALLOON_DISMISS_LABEL); |
| 274 | 274 |
| 275 balloon_ = balloon; | 275 balloon_ = balloon; |
| 276 | 276 |
| 277 SetBounds(balloon_->position().x(), balloon_->position().y(), | 277 SetBounds(balloon_->GetPosition().x(), balloon_->GetPosition().y(), |
| 278 GetTotalWidth(), GetTotalHeight()); | 278 GetTotalWidth(), GetTotalHeight()); |
| 279 | 279 |
| 280 source_label_ = new views::Label(source_label_text); | 280 source_label_ = new views::Label(source_label_text); |
| 281 AddChildView(source_label_); | 281 AddChildView(source_label_); |
| 282 options_menu_button_ = new views::MenuButton(NULL, L"", this, false); | 282 options_menu_button_ = new views::MenuButton(NULL, L"", this, false); |
| 283 AddChildView(options_menu_button_); | 283 AddChildView(options_menu_button_); |
| 284 close_button_ = new views::ImageButton(this); | 284 close_button_ = new views::ImageButton(this); |
| 285 AddChildView(close_button_); | 285 AddChildView(close_button_); |
| 286 | 286 |
| 287 // We have to create two windows: one for the contents and one for the | 287 // We have to create two windows: one for the contents and one for the |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 NOTREACHED(); | 513 NOTREACHED(); |
| 514 return; | 514 return; |
| 515 } | 515 } |
| 516 | 516 |
| 517 // If the renderer process attached to this balloon is disconnected | 517 // If the renderer process attached to this balloon is disconnected |
| 518 // (e.g., because of a crash), we want to close the balloon. | 518 // (e.g., because of a crash), we want to close the balloon. |
| 519 notification_registrar_.Remove(this, | 519 notification_registrar_.Remove(this, |
| 520 NotificationType::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon_)); | 520 NotificationType::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon_)); |
| 521 Close(false); | 521 Close(false); |
| 522 } | 522 } |
| OLD | NEW |