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/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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 const int kTopMargin = 2; | 49 const int kTopMargin = 2; |
50 const int kBottomMargin = 0; | 50 const int kBottomMargin = 0; |
51 const int kLeftMargin = 4; | 51 const int kLeftMargin = 4; |
52 const int kRightMargin = 4; | 52 const int kRightMargin = 4; |
53 const int kShelfBorderTopOverlap = 0; | 53 const int kShelfBorderTopOverlap = 0; |
54 | 54 |
55 // Properties of the dismiss button. | 55 // Properties of the dismiss button. |
56 const int kDismissButtonWidth = 14; | 56 const int kDismissButtonWidth = 14; |
57 const int kDismissButtonHeight = 14; | 57 const int kDismissButtonHeight = 14; |
58 const int kDismissButtonRightMargin = 10; | 58 const int kDismissButtonTopMargin = 6; |
| 59 const int kDismissButtonRightMargin = 6; |
59 | 60 |
60 // Properties of the options menu. | 61 // Properties of the options menu. |
61 const int kOptionsButtonWidth = 26; | 62 const int kOptionsButtonWidth = 21; |
62 const int kOptionsButtonHeight = 14; | 63 const int kOptionsButtonHeight = 14; |
63 const int kOptionsButtonRightMargin = 10; | 64 const int kOptionsButtonTopMargin = 5; |
| 65 const int kOptionsButtonRightMargin = 4; |
64 | 66 |
65 // Properties of the origin label. | 67 // Properties of the origin label. |
66 const int kLeftLabelMargin = 10; | 68 const int kLabelLeftMargin = 10; |
| 69 const int kLabelTopMargin = 6; |
67 | 70 |
68 // Size of the drop shadow. The shadow is provided by BubbleBorder, | 71 // Size of the drop shadow. The shadow is provided by BubbleBorder, |
69 // not this class. | 72 // not this class. |
70 const int kLeftShadowWidth = 0; | 73 const int kLeftShadowWidth = 0; |
71 const int kRightShadowWidth = 0; | 74 const int kRightShadowWidth = 0; |
72 const int kTopShadowWidth = 0; | 75 const int kTopShadowWidth = 0; |
73 const int kBottomShadowWidth = 6; | 76 const int kBottomShadowWidth = 6; |
74 | 77 |
75 // Optional animation. | 78 // Optional animation. |
76 const bool kAnimateEnabled = true; | 79 const bool kAnimateEnabled = true; |
77 | 80 |
78 // The shelf height for the system default font size. It is scaled | 81 // The shelf height for the system default font size. It is scaled |
79 // with changes in the default font size. | 82 // with changes in the default font size. |
80 const int kDefaultShelfHeight = 22; | 83 const int kDefaultShelfHeight = 22; |
81 const int kShelfTopMargin = 6; | |
82 | 84 |
83 // Menu commands | 85 // Menu commands |
84 const int kRevokePermissionCommand = 0; | 86 const int kRevokePermissionCommand = 0; |
85 | 87 |
86 // Colors | 88 // Colors |
87 const SkColor kControlBarBackgroundColor = SkColorSetRGB(245, 245, 245); | 89 const SkColor kControlBarBackgroundColor = SkColorSetRGB(245, 245, 245); |
88 const SkColor kControlBarTextColor = SkColorSetRGB(125, 125, 125); | 90 const SkColor kControlBarTextColor = SkColorSetRGB(125, 125, 125); |
89 const SkColor kControlBarSeparatorLineColor = SkColorSetRGB(180, 180, 180); | 91 const SkColor kControlBarSeparatorLineColor = SkColorSetRGB(180, 180, 180); |
90 | 92 |
91 } // namespace | 93 } // namespace |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 html_contents_->SetPreferredSize(contents_rect.size()); | 242 html_contents_->SetPreferredSize(contents_rect.size()); |
241 RenderWidgetHostView* view = html_contents_->render_view_host()->view(); | 243 RenderWidgetHostView* view = html_contents_->render_view_host()->view(); |
242 if (view) | 244 if (view) |
243 view->SetSize(contents_rect.size()); | 245 view->SetSize(contents_rect.size()); |
244 } | 246 } |
245 | 247 |
246 gfx::Rect BalloonViewImpl::GetCloseButtonBounds() const { | 248 gfx::Rect BalloonViewImpl::GetCloseButtonBounds() const { |
247 return gfx::Rect( | 249 return gfx::Rect( |
248 width() - kDismissButtonWidth - | 250 width() - kDismissButtonWidth - |
249 kDismissButtonRightMargin - kRightShadowWidth, | 251 kDismissButtonRightMargin - kRightShadowWidth, |
250 kShelfTopMargin, | 252 kDismissButtonTopMargin, |
251 kDismissButtonWidth, | 253 kDismissButtonWidth, |
252 kDismissButtonHeight); | 254 kDismissButtonHeight); |
253 } | 255 } |
254 | 256 |
255 gfx::Rect BalloonViewImpl::GetOptionsButtonBounds() const { | 257 gfx::Rect BalloonViewImpl::GetOptionsButtonBounds() const { |
256 gfx::Rect close_rect = GetCloseButtonBounds(); | 258 gfx::Rect close_rect = GetCloseButtonBounds(); |
257 | 259 |
258 return gfx::Rect( | 260 return gfx::Rect( |
259 close_rect.x() - kOptionsButtonWidth - kOptionsButtonRightMargin, | 261 close_rect.x() - kOptionsButtonWidth - kOptionsButtonRightMargin, |
260 kShelfTopMargin, | 262 kOptionsButtonTopMargin, |
261 kOptionsButtonWidth, | 263 kOptionsButtonWidth, |
262 kOptionsButtonHeight); | 264 kOptionsButtonHeight); |
263 } | 265 } |
264 | 266 |
265 gfx::Rect BalloonViewImpl::GetLabelBounds() const { | 267 gfx::Rect BalloonViewImpl::GetLabelBounds() const { |
266 return gfx::Rect( | 268 return gfx::Rect( |
267 kLeftShadowWidth + kLeftLabelMargin, | 269 kLeftShadowWidth + kLabelLeftMargin, |
268 kShelfTopMargin, | 270 kLabelTopMargin, |
269 std::max(0, width() - kOptionsButtonWidth - | 271 std::max(0, width() - kOptionsButtonWidth - |
270 kRightMargin), | 272 kRightMargin), |
271 kOptionsButtonHeight); | 273 kOptionsButtonHeight); |
272 } | 274 } |
273 | 275 |
274 void BalloonViewImpl::Show(Balloon* balloon) { | 276 void BalloonViewImpl::Show(Balloon* balloon) { |
275 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 277 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
276 | 278 |
277 balloon_ = balloon; | 279 balloon_ = balloon; |
278 | 280 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 Widget::AcceptEvents, | 325 Widget::AcceptEvents, |
324 Widget::DeleteOnDestroy, | 326 Widget::DeleteOnDestroy, |
325 Widget::DontMirrorOriginInRTL); | 327 Widget::DontMirrorOriginInRTL); |
326 frame_container_->SetWidgetDelegate(this); | 328 frame_container_->SetWidgetDelegate(this); |
327 frame_container_->SetAlwaysOnTop(true); | 329 frame_container_->SetAlwaysOnTop(true); |
328 frame_container_->Init(NULL, balloon_rect); | 330 frame_container_->Init(NULL, balloon_rect); |
329 frame_container_->SetContentsView(this); | 331 frame_container_->SetContentsView(this); |
330 frame_container_->MoveAbove(html_container_); | 332 frame_container_->MoveAbove(html_container_); |
331 | 333 |
332 close_button_->SetImage(views::CustomButton::BS_NORMAL, | 334 close_button_->SetImage(views::CustomButton::BS_NORMAL, |
333 rb.GetBitmapNamed(IDR_BALLOON_CLOSE)); | 335 rb.GetBitmapNamed(IDR_TAB_CLOSE)); |
334 close_button_->SetImage(views::CustomButton::BS_HOT, | 336 close_button_->SetImage(views::CustomButton::BS_HOT, |
335 rb.GetBitmapNamed(IDR_BALLOON_CLOSE_HOVER)); | 337 rb.GetBitmapNamed(IDR_TAB_CLOSE_H)); |
336 close_button_->SetImage(views::CustomButton::BS_PUSHED, | 338 close_button_->SetImage(views::CustomButton::BS_PUSHED, |
337 rb.GetBitmapNamed(IDR_BALLOON_CLOSE_HOVER)); | 339 rb.GetBitmapNamed(IDR_TAB_CLOSE_P)); |
338 close_button_->SetBounds(GetCloseButtonBounds()); | 340 close_button_->SetBounds(GetCloseButtonBounds()); |
| 341 close_button_->SetBackground(SK_ColorBLACK, |
| 342 rb.GetBitmapNamed(IDR_TAB_CLOSE), |
| 343 rb.GetBitmapNamed(IDR_TAB_CLOSE_MASK)); |
339 | 344 |
340 options_menu_button_->SetIcon(*rb.GetBitmapNamed(IDR_BALLOON_WRENCH)); | 345 options_menu_button_->SetIcon(*rb.GetBitmapNamed(IDR_BALLOON_WRENCH)); |
341 options_menu_button_->SetHoverIcon(*rb.GetBitmapNamed(IDR_BALLOON_WRENCH_H)); | 346 options_menu_button_->SetHoverIcon(*rb.GetBitmapNamed(IDR_BALLOON_WRENCH_H)); |
342 options_menu_button_->SetPushedIcon(*rb.GetBitmapNamed(IDR_BALLOON_WRENCH_P)); | 347 options_menu_button_->SetPushedIcon(*rb.GetBitmapNamed(IDR_BALLOON_WRENCH_P)); |
343 options_menu_button_->set_alignment(views::TextButton::ALIGN_CENTER); | 348 options_menu_button_->set_alignment(views::TextButton::ALIGN_CENTER); |
344 options_menu_button_->SetBounds(GetOptionsButtonBounds()); | 349 options_menu_button_->SetBounds(GetOptionsButtonBounds()); |
345 | 350 |
346 source_label_->SetFont(rb.GetFont(ResourceBundle::SmallFont)); | 351 source_label_->SetFont(rb.GetFont(ResourceBundle::SmallFont)); |
347 source_label_->SetColor(kControlBarTextColor); | 352 source_label_->SetColor(kControlBarTextColor); |
348 source_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 353 source_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 NOTREACHED(); | 492 NOTREACHED(); |
488 return; | 493 return; |
489 } | 494 } |
490 | 495 |
491 // If the renderer process attached to this balloon is disconnected | 496 // If the renderer process attached to this balloon is disconnected |
492 // (e.g., because of a crash), we want to close the balloon. | 497 // (e.g., because of a crash), we want to close the balloon. |
493 notification_registrar_.Remove(this, | 498 notification_registrar_.Remove(this, |
494 NotificationType::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon_)); | 499 NotificationType::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon_)); |
495 Close(false); | 500 Close(false); |
496 } | 501 } |
OLD | NEW |