| 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/gfx/canvas.h" | 9 #include "app/gfx/canvas.h" |
| 10 #include "app/gfx/gdi_util.h" | 10 #include "app/gfx/gdi_util.h" |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 - kRightMargin, | 267 - kRightMargin, |
| 268 height() - kOptionsMenuHeight | 268 height() - kOptionsMenuHeight |
| 269 - kShelfBorderTopOverlap | 269 - kShelfBorderTopOverlap |
| 270 - kBottomMargin, | 270 - kBottomMargin, |
| 271 kOptionsMenuWidth, | 271 kOptionsMenuWidth, |
| 272 kOptionsMenuHeight); | 272 kOptionsMenuHeight); |
| 273 AddChildView(options_menu_button_); | 273 AddChildView(options_menu_button_); |
| 274 | 274 |
| 275 const std::wstring source_label_text = l10n_util::GetStringF( | 275 const std::wstring source_label_text = l10n_util::GetStringF( |
| 276 IDS_NOTIFICATION_BALLOON_SOURCE_LABEL, | 276 IDS_NOTIFICATION_BALLOON_SOURCE_LABEL, |
| 277 ASCIIToWide(this->balloon_->notification().origin_url().spec())); | 277 this->balloon_->notification().display_source()); |
| 278 | 278 |
| 279 views::Label* source_label = new views::Label(source_label_text); | 279 views::Label* source_label = new views::Label(source_label_text); |
| 280 source_label->SetFont(ResourceBundle::GetSharedInstance().GetFont( | 280 source_label->SetFont(ResourceBundle::GetSharedInstance().GetFont( |
| 281 ResourceBundle::SmallFont)); | 281 ResourceBundle::SmallFont)); |
| 282 source_label->SetColor(BrowserThemeProvider::kDefaultColorTabText); | 282 source_label->SetColor(BrowserThemeProvider::kDefaultColorTabText); |
| 283 source_label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 283 source_label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 284 source_label->SetBounds(kLeftLabelMargin, | 284 source_label->SetBounds(kLeftLabelMargin, |
| 285 height() - kDismissButtonHeight | 285 height() - kDismissButtonHeight |
| 286 - kShelfBorderTopOverlap | 286 - kShelfBorderTopOverlap |
| 287 - kBottomMargin, | 287 - kBottomMargin, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 303 CreateOptionsMenu(); | 303 CreateOptionsMenu(); |
| 304 options_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); | 304 options_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); |
| 305 } | 305 } |
| 306 | 306 |
| 307 void BalloonViewImpl::CreateOptionsMenu() { | 307 void BalloonViewImpl::CreateOptionsMenu() { |
| 308 if (options_menu_contents_.get()) | 308 if (options_menu_contents_.get()) |
| 309 return; | 309 return; |
| 310 | 310 |
| 311 const std::wstring label_text = l10n_util::GetStringF( | 311 const std::wstring label_text = l10n_util::GetStringF( |
| 312 IDS_NOTIFICATION_BALLOON_REVOKE_MESSAGE, | 312 IDS_NOTIFICATION_BALLOON_REVOKE_MESSAGE, |
| 313 ASCIIToWide(this->balloon_->notification().origin_url().spec())); | 313 this->balloon_->notification().display_source()); |
| 314 | 314 |
| 315 options_menu_contents_.reset(new views::SimpleMenuModel(this)); | 315 options_menu_contents_.reset(new views::SimpleMenuModel(this)); |
| 316 options_menu_contents_->AddItem(kRevokePermissionCommand, label_text); | 316 options_menu_contents_->AddItem(kRevokePermissionCommand, label_text); |
| 317 | 317 |
| 318 options_menu_menu_.reset(new views::Menu2(options_menu_contents_.get())); | 318 options_menu_menu_.reset(new views::Menu2(options_menu_contents_.get())); |
| 319 } | 319 } |
| 320 | 320 |
| 321 void BalloonViewImpl::GetContentsMask(const gfx::Rect& rect, | 321 void BalloonViewImpl::GetContentsMask(const gfx::Rect& rect, |
| 322 gfx::Path* path) const { | 322 gfx::Path* path) const { |
| 323 // This needs to remove areas that look like the following from each corner: | 323 // This needs to remove areas that look like the following from each corner: |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 NOTREACHED(); | 427 NOTREACHED(); |
| 428 return; | 428 return; |
| 429 } | 429 } |
| 430 | 430 |
| 431 // If the renderer process attached to this balloon is disconnected | 431 // If the renderer process attached to this balloon is disconnected |
| 432 // (e.g., because of a crash), we want to close the balloon. | 432 // (e.g., because of a crash), we want to close the balloon. |
| 433 notification_registrar_.Remove(this, | 433 notification_registrar_.Remove(this, |
| 434 NotificationType::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon_)); | 434 NotificationType::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon_)); |
| 435 Close(false); | 435 Close(false); |
| 436 } | 436 } |
| OLD | NEW |