| 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/info_bubble.h" | 5 #include "chrome/browser/ui/views/info_bubble.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "chrome/browser/ui/window_sizer.h" | 9 #include "chrome/browser/ui/window_sizer.h" |
| 10 #include "chrome/common/notification_service.h" | 10 #include "chrome/common/notification_service.h" |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 views::Background::CreateSolidBackground(kBackgroundColor)); | 431 views::Background::CreateSolidBackground(kBackgroundColor)); |
| 432 #else | 432 #else |
| 433 // Create a view to paint the border and background. | 433 // Create a view to paint the border and background. |
| 434 border_contents_ = CreateBorderContents(); | 434 border_contents_ = CreateBorderContents(); |
| 435 border_contents_->Init(); | 435 border_contents_->Init(); |
| 436 gfx::Rect contents_bounds; | 436 gfx::Rect contents_bounds; |
| 437 border_contents_->SizeAndGetBounds(position_relative_to, | 437 border_contents_->SizeAndGetBounds(position_relative_to, |
| 438 arrow_location, false, contents->GetPreferredSize(), | 438 arrow_location, false, contents->GetPreferredSize(), |
| 439 &contents_bounds, &window_bounds); | 439 &contents_bounds, &window_bounds); |
| 440 // This new view must be added before |contents| so it will paint under it. | 440 // This new view must be added before |contents| so it will paint under it. |
| 441 contents_view->AddChildView(0, border_contents_); | 441 contents_view->AddChildViewAt(border_contents_, 0); |
| 442 | 442 |
| 443 // |contents_view| has no layout manager, so we have to explicitly position | 443 // |contents_view| has no layout manager, so we have to explicitly position |
| 444 // its children. | 444 // its children. |
| 445 border_contents_->SetBoundsRect( | 445 border_contents_->SetBoundsRect( |
| 446 gfx::Rect(gfx::Point(), window_bounds.size())); | 446 gfx::Rect(gfx::Point(), window_bounds.size())); |
| 447 contents->SetBoundsRect(contents_bounds); | 447 contents->SetBoundsRect(contents_bounds); |
| 448 #endif | 448 #endif |
| 449 SetBounds(window_bounds); | 449 SetBounds(window_bounds); |
| 450 | 450 |
| 451 // Register the Escape accelerator for closing. | 451 // Register the Escape accelerator for closing. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 #endif | 493 #endif |
| 494 SetBounds(window_bounds); | 494 SetBounds(window_bounds); |
| 495 } | 495 } |
| 496 | 496 |
| 497 #if defined(OS_WIN) | 497 #if defined(OS_WIN) |
| 498 void InfoBubble::OnActivate(UINT action, BOOL minimized, HWND window) { | 498 void InfoBubble::OnActivate(UINT action, BOOL minimized, HWND window) { |
| 499 // The popup should close when it is deactivated. | 499 // The popup should close when it is deactivated. |
| 500 if (action == WA_INACTIVE) { | 500 if (action == WA_INACTIVE) { |
| 501 Close(); | 501 Close(); |
| 502 } else if (action == WA_ACTIVE) { | 502 } else if (action == WA_ACTIVE) { |
| 503 DCHECK_GT(GetRootView()->GetChildViewCount(), 0); | 503 DCHECK(GetRootView()->has_children()); |
| 504 GetRootView()->GetChildViewAt(0)->RequestFocus(); | 504 GetRootView()->GetChildViewAt(0)->RequestFocus(); |
| 505 } | 505 } |
| 506 } | 506 } |
| 507 #elif defined(OS_LINUX) | 507 #elif defined(OS_LINUX) |
| 508 void InfoBubble::IsActiveChanged() { | 508 void InfoBubble::IsActiveChanged() { |
| 509 if (!IsActive()) | 509 if (!IsActive()) |
| 510 Close(); | 510 Close(); |
| 511 } | 511 } |
| 512 #endif | 512 #endif |
| 513 | 513 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 animation_->Hide(); | 558 animation_->Hide(); |
| 559 } | 559 } |
| 560 | 560 |
| 561 bool InfoBubble::AcceleratorPressed(const views::Accelerator& accelerator) { | 561 bool InfoBubble::AcceleratorPressed(const views::Accelerator& accelerator) { |
| 562 if (!delegate_ || delegate_->CloseOnEscape()) { | 562 if (!delegate_ || delegate_->CloseOnEscape()) { |
| 563 DoClose(true); | 563 DoClose(true); |
| 564 return true; | 564 return true; |
| 565 } | 565 } |
| 566 return false; | 566 return false; |
| 567 } | 567 } |
| OLD | NEW |