summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/info_bubble.cc
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-06 23:27:01 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-06 23:27:01 +0000
commit11a4b1bd05f3d419a2164ecbe0e2ec12726f523b (patch)
tree3f3ba4dc644dc42ccaa4c959b1276f30c404ceb7 /chrome/browser/views/info_bubble.cc
parent81a7e67a0dbb0133f5c016d3eb04ed1116ba6717 (diff)
downloadchromium_src-11a4b1bd05f3d419a2164ecbe0e2ec12726f523b.zip
chromium_src-11a4b1bd05f3d419a2164ecbe0e2ec12726f523b.tar.gz
chromium_src-11a4b1bd05f3d419a2164ecbe0e2ec12726f523b.tar.bz2
Extension Installed InfoBubble
This creates UI feedback upon successful installation of an extension. An InfoBubble is shown containing the install icon and some information about how to manage extensions. TEST=Install a packaged extension. Verify the InfoBubble is shown, with the install icon and some description. The InfoBubble should disappear when the bubble looses focus (click elsewhere). For a browserAction, the bubble should point to the browserAction icon. For a pageAction **that has a "default_icon" set in it's manifest (see the samples/subscribe_page_action in this CL)**, it should point to a temporarily shown pageAction icon that will be hidden when the bubble closes. Otherwise it should point to the wrench menu. BUG=21412 Review URL: http://codereview.chromium.org/362022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31322 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/info_bubble.cc')
-rw-r--r--chrome/browser/views/info_bubble.cc37
1 files changed, 21 insertions, 16 deletions
diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc
index 1218f46..4f39ba9 100644
--- a/chrome/browser/views/info_bubble.cc
+++ b/chrome/browser/views/info_bubble.cc
@@ -35,17 +35,16 @@ class BorderContents : public views::View {
// Given the size of the contents and the rect to point at, initializes the
// bubble and returns the bounds of both the border
// and the contents inside the bubble.
- // |is_rtl| is true if the UI is RTL and thus the arrow should default to the
- // right side of the bubble; otherwise it defaults to the left top corner, and
- // then is moved as necessary to try and fit the whole bubble on the same
- // monitor as the rect being pointed to.
+ // |prefer_arrow_on_right| specifies the preferred location for the arrow
+ // anchor. If the bubble does not fit on the monitor, the arrow location may
+ // changed so it can.
//
// TODO(pkasting): Maybe this should use mirroring transformations instead,
// which would hopefully simplify this code.
void InitAndGetBounds(
const gfx::Rect& position_relative_to, // In screen coordinates
const gfx::Size& contents_size,
- bool is_rtl,
+ bool prefer_arrow_on_right,
gfx::Rect* contents_bounds, // Returned in window coordinates
gfx::Rect* window_bounds); // Returned in screen coordinates
@@ -61,7 +60,7 @@ class BorderContents : public views::View {
void BorderContents::InitAndGetBounds(
const gfx::Rect& position_relative_to,
const gfx::Size& contents_size,
- bool is_rtl,
+ bool prefer_arrow_on_right,
gfx::Rect* contents_bounds,
gfx::Rect* window_bounds) {
// Margins between the contents and the inside of the border, in pixels.
@@ -80,8 +79,9 @@ void BorderContents::InitAndGetBounds(
local_contents_size.Enlarge(kLeftMargin + kRightMargin,
kTopMargin + kBottomMargin);
- // Try putting the arrow in its default location, and calculating the bounds.
- BubbleBorder::ArrowLocation arrow_location(is_rtl ?
+ // Try putting the arrow in its initial location, and calculating the
+ // bounds.
+ BubbleBorder::ArrowLocation arrow_location(prefer_arrow_on_right ?
BubbleBorder::TOP_RIGHT : BubbleBorder::TOP_LEFT);
bubble_border->set_arrow_location(arrow_location);
*window_bounds =
@@ -94,9 +94,9 @@ void BorderContents::InitAndGetBounds(
monitor_provider->GetMonitorWorkAreaMatching(position_relative_to));
if (!monitor_bounds.IsEmpty() && !monitor_bounds.Contains(*window_bounds)) {
// The bounds don't fit. Move the arrow to try and improve things.
- bool arrow_on_left =
- (is_rtl ? (window_bounds->x() < monitor_bounds.x()) :
- (window_bounds->right() <= monitor_bounds.right()));
+ bool arrow_on_left = prefer_arrow_on_right ?
+ (window_bounds->x() < monitor_bounds.x()) :
+ (window_bounds->right() <= monitor_bounds.right());
if (window_bounds->bottom() > monitor_bounds.bottom()) {
arrow_location = arrow_on_left ?
BubbleBorder::BOTTOM_LEFT : BubbleBorder::BOTTOM_RIGHT;
@@ -155,13 +155,14 @@ gfx::Rect BorderWidget::InitAndGetBounds(
HWND owner,
const gfx::Rect& position_relative_to,
const gfx::Size& contents_size,
- bool is_rtl) {
+ bool prefer_arrow_on_right) {
// Set up the border view and ask it to calculate our bounds (and our
// contents').
BorderContents* border_contents = new BorderContents;
gfx::Rect contents_bounds, window_bounds;
- border_contents->InitAndGetBounds(position_relative_to, contents_size, is_rtl,
- &contents_bounds, &window_bounds);
+ border_contents->InitAndGetBounds(position_relative_to, contents_size,
+ prefer_arrow_on_right, &contents_bounds,
+ &window_bounds);
// Initialize ourselves.
WidgetWin::Init(GetAncestor(owner, GA_ROOT), window_bounds);
@@ -247,12 +248,16 @@ void InfoBubble::Init(views::Window* parent,
// Calculate and set the bounds for all windows and views.
gfx::Rect window_bounds;
+
+ bool prefer_arrow_on_right =
+ (contents->UILayoutIsRightToLeft() == delegate->PreferOriginSideAnchor());
+
#if defined(OS_WIN)
border_.reset(new BorderWidget);
// Initialize and position the border window.
window_bounds = border_->InitAndGetBounds(GetNativeView(),
position_relative_to, contents->GetPreferredSize(),
- contents->UILayoutIsRightToLeft());
+ prefer_arrow_on_right);
// Make |contents| take up the entire contents view.
contents_view->SetLayoutManager(new views::FillLayout);
@@ -265,7 +270,7 @@ void InfoBubble::Init(views::Window* parent,
BorderContents* border_contents = new BorderContents;
gfx::Rect contents_bounds;
border_contents->InitAndGetBounds(position_relative_to,
- contents->GetPreferredSize(), contents->UILayoutIsRightToLeft(),
+ contents->GetPreferredSize(), prefer_arrow_on_right,
&contents_bounds, &window_bounds);
// This new view must be added before |contents| so it will paint under it.
contents_view->AddChildView(0, border_contents);