| 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/ui/views/notifications/balloon_view.h" | 5 #include "chrome/browser/ui/views/notifications/balloon_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 gfx::Size BalloonViewImpl::GetPreferredSize() { | 183 gfx::Size BalloonViewImpl::GetPreferredSize() { |
| 184 return gfx::Size(1000, 1000); | 184 return gfx::Size(1000, 1000); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void BalloonViewImpl::SizeContentsWindow() { | 187 void BalloonViewImpl::SizeContentsWindow() { |
| 188 if (!html_container_ || !frame_container_) | 188 if (!html_container_ || !frame_container_) |
| 189 return; | 189 return; |
| 190 | 190 |
| 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_container_->MoveAboveWidget(frame_container_); | 193 html_container_->StackAboveWidget(frame_container_); |
| 194 | 194 |
| 195 gfx::Path path; | 195 gfx::Path path; |
| 196 GetContentsMask(contents_rect, &path); | 196 GetContentsMask(contents_rect, &path); |
| 197 html_container_->SetShape(path.CreateNativeRegion()); | 197 html_container_->SetShape(path.CreateNativeRegion()); |
| 198 | 198 |
| 199 close_button_->SetBoundsRect(GetCloseButtonBounds()); | 199 close_button_->SetBoundsRect(GetCloseButtonBounds()); |
| 200 options_menu_button_->SetBoundsRect(GetOptionsButtonBounds()); | 200 options_menu_button_->SetBoundsRect(GetOptionsButtonBounds()); |
| 201 source_label_->SetBoundsRect(GetLabelBounds()); | 201 source_label_->SetBoundsRect(GetLabelBounds()); |
| 202 } | 202 } |
| 203 | 203 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 html_container_->Init(params); | 341 html_container_->Init(params); |
| 342 html_container_->SetContentsView(html_contents_->view()); | 342 html_container_->SetContentsView(html_contents_->view()); |
| 343 | 343 |
| 344 gfx::Rect balloon_rect(x(), y(), GetTotalWidth(), GetTotalHeight()); | 344 gfx::Rect balloon_rect(x(), y(), GetTotalWidth(), GetTotalHeight()); |
| 345 frame_container_ = new Widget; | 345 frame_container_ = new Widget; |
| 346 params.delegate = this; | 346 params.delegate = this; |
| 347 params.transparent = true; | 347 params.transparent = true; |
| 348 params.bounds = balloon_rect; | 348 params.bounds = balloon_rect; |
| 349 frame_container_->Init(params); | 349 frame_container_->Init(params); |
| 350 frame_container_->SetContentsView(this); | 350 frame_container_->SetContentsView(this); |
| 351 frame_container_->MoveAboveWidget(html_container_); | 351 frame_container_->StackAboveWidget(html_container_); |
| 352 | 352 |
| 353 // SetAlwaysOnTop should be called after MoveAboveWidget because otherwise | 353 // SetAlwaysOnTop should be called after StackAboveWidget because otherwise |
| 354 // the top-most flag will be removed. | 354 // the top-most flag will be removed. |
| 355 html_container_->SetAlwaysOnTop(true); | 355 html_container_->SetAlwaysOnTop(true); |
| 356 frame_container_->SetAlwaysOnTop(true); | 356 frame_container_->SetAlwaysOnTop(true); |
| 357 | 357 |
| 358 close_button_->SetImage(views::CustomButton::BS_NORMAL, | 358 close_button_->SetImage(views::CustomButton::BS_NORMAL, |
| 359 rb.GetBitmapNamed(IDR_TAB_CLOSE)); | 359 rb.GetBitmapNamed(IDR_TAB_CLOSE)); |
| 360 close_button_->SetImage(views::CustomButton::BS_HOT, | 360 close_button_->SetImage(views::CustomButton::BS_HOT, |
| 361 rb.GetBitmapNamed(IDR_TAB_CLOSE_H)); | 361 rb.GetBitmapNamed(IDR_TAB_CLOSE_H)); |
| 362 close_button_->SetImage(views::CustomButton::BS_PUSHED, | 362 close_button_->SetImage(views::CustomButton::BS_PUSHED, |
| 363 rb.GetBitmapNamed(IDR_TAB_CLOSE_P)); | 363 rb.GetBitmapNamed(IDR_TAB_CLOSE_P)); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 return; | 516 return; |
| 517 } | 517 } |
| 518 | 518 |
| 519 // If the renderer process attached to this balloon is disconnected | 519 // If the renderer process attached to this balloon is disconnected |
| 520 // (e.g., because of a crash), we want to close the balloon. | 520 // (e.g., because of a crash), we want to close the balloon. |
| 521 notification_registrar_.Remove( | 521 notification_registrar_.Remove( |
| 522 this, chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED, | 522 this, chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED, |
| 523 content::Source<Balloon>(balloon_)); | 523 content::Source<Balloon>(balloon_)); |
| 524 Close(false); | 524 Close(false); |
| 525 } | 525 } |
| OLD | NEW |