| 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/pinned_contents_info_bubble.h" | 5 #include "chrome/browser/views/pinned_contents_info_bubble.h" |
| 6 | 6 |
| 7 #include "chrome/browser/views/bubble_border.h" | 7 #include "chrome/browser/views/bubble_border.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | |
| 10 // BorderWidget --------------------------------------------------------------- | |
| 11 | |
| 12 void PinnedContentsBorderContents::SizeAndGetBounds( | 9 void PinnedContentsBorderContents::SizeAndGetBounds( |
| 13 const gfx::Rect& position_relative_to, | 10 const gfx::Rect& position_relative_to, |
| 14 BubbleBorder::ArrowLocation arrow_location, | 11 BubbleBorder::ArrowLocation arrow_location, |
| 15 bool allow_bubble_offscreen, | 12 bool allow_bubble_offscreen, |
| 16 const gfx::Size& contents_size, | 13 const gfx::Size& contents_size, |
| 17 gfx::Rect* contents_bounds, | 14 gfx::Rect* contents_bounds, |
| 18 gfx::Rect* window_bounds) { | 15 gfx::Rect* window_bounds) { |
| 19 // Arrow offset is calculated from the middle of the |position_relative_to|. | 16 // Arrow offset is calculated from the middle of the |position_relative_to|. |
| 20 int offset = position_relative_to.x() + (position_relative_to.width() / 2); | 17 int offset = position_relative_to.x() + (position_relative_to.width() / 2); |
| 21 offset -= bubble_anchor_.x(); | 18 offset -= bubble_anchor_.x(); |
| 22 | 19 |
| 23 gfx::Insets insets; | 20 gfx::Insets insets; |
| 24 bubble_border_->GetInsets(&insets); | 21 bubble_border_->GetInsets(&insets); |
| 25 offset += kLeftMargin + insets.left() + 1; | 22 offset += kLeftMargin + insets.left() + 1; |
| 26 bubble_border_->SetArrowOffset(offset, contents_size); | 23 bubble_border_->SetArrowOffset(offset, contents_size); |
| 27 | 24 |
| 28 BorderContents::SizeAndGetBounds( | 25 BorderContents::SizeAndGetBounds( |
| 29 position_relative_to, arrow_location, | 26 position_relative_to, arrow_location, |
| 30 true, // Don't move the bubble around if it does not fit on the screen. | 27 true, // Don't move the bubble around if it does not fit on the screen. |
| 31 contents_size, contents_bounds, window_bounds); | 28 contents_size, contents_bounds, window_bounds); |
| 32 | 29 |
| 33 // Now move the y position to make sure the bubble contents overlap the view. | 30 // Now move the y position to make sure the bubble contents overlap the view. |
| 34 window_bounds->Offset(0, -(kTopMargin + 1)); | 31 window_bounds->Offset(0, -(kTopMargin + 1)); |
| 35 } | 32 } |
| 36 | 33 |
| 37 BorderContents* PinnedContentsBorderWidget::CreateBorderContents() { | |
| 38 return new PinnedContentsBorderContents(bubble_anchor_); | |
| 39 } | |
| 40 #endif | |
| 41 | |
| 42 // InfoBubble ----------------------------------------------------------------- | 34 // InfoBubble ----------------------------------------------------------------- |
| 43 | 35 |
| 44 // static | 36 // static |
| 45 PinnedContentsInfoBubble* PinnedContentsInfoBubble::Show( | 37 PinnedContentsInfoBubble* PinnedContentsInfoBubble::Show( |
| 46 views::Widget* parent, | 38 views::Widget* parent, |
| 47 const gfx::Rect& position_relative_to, | 39 const gfx::Rect& position_relative_to, |
| 48 BubbleBorder::ArrowLocation arrow_location, | 40 BubbleBorder::ArrowLocation arrow_location, |
| 49 const gfx::Point& bubble_anchor, | 41 const gfx::Point& bubble_anchor, |
| 50 views::View* contents, | 42 views::View* contents, |
| 51 InfoBubbleDelegate* delegate) { | 43 InfoBubbleDelegate* delegate) { |
| 52 PinnedContentsInfoBubble* window = | 44 PinnedContentsInfoBubble* window = |
| 53 new PinnedContentsInfoBubble(bubble_anchor); | 45 new PinnedContentsInfoBubble(bubble_anchor); |
| 54 window->Init(parent, position_relative_to, arrow_location, | 46 window->Init(parent, position_relative_to, arrow_location, |
| 55 contents, delegate); | 47 contents, delegate); |
| 56 return window; | 48 return window; |
| 57 } | 49 } |
| 58 | 50 |
| 59 // TODO(finnur): This needs to be implemented for other platforms once we decide | 51 BorderContents* PinnedContentsInfoBubble::CreateBorderContents() { |
| 60 // this is the way to go. | 52 return new PinnedContentsBorderContents(bubble_anchor_); |
| 61 #if defined(OS_WIN) | |
| 62 BorderWidget* PinnedContentsInfoBubble::CreateBorderWidget() { | |
| 63 return new PinnedContentsBorderWidget(bubble_anchor_); | |
| 64 } | 53 } |
| 65 #endif | |
| OLD | NEW |