diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-19 23:09:07 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-19 23:09:07 +0000 |
commit | f98903ef56ce35144860be0d69df5207ae9ace32 (patch) | |
tree | 7d874ef4188dcabf4138f976dfc1bd99ba1e6985 /chrome/browser/views/pinned_contents_info_bubble.h | |
parent | 1b882f5c0f0c50d9eefc9cb421a1157e6e1e45d4 (diff) | |
download | chromium_src-f98903ef56ce35144860be0d69df5207ae9ace32.zip chromium_src-f98903ef56ce35144860be0d69df5207ae9ace32.tar.gz chromium_src-f98903ef56ce35144860be0d69df5207ae9ace32.tar.bz2 |
Subclassing the InfoBubble to handle anchoring bubbles basedon their content, not what they point to, like the one we wantto show for the extension apps.
BUG=41270
TEST=Run Chrome with --enable-extension-apps --app-launcher-new-tab and press the NewTab button. A panel should open that has a mini omnibox which should be situated right on top of the underlying omnibox.
Review URL: http://codereview.chromium.org/1572045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44979 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/pinned_contents_info_bubble.h')
-rw-r--r-- | chrome/browser/views/pinned_contents_info_bubble.h | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/chrome/browser/views/pinned_contents_info_bubble.h b/chrome/browser/views/pinned_contents_info_bubble.h new file mode 100644 index 0000000..92477c0 --- /dev/null +++ b/chrome/browser/views/pinned_contents_info_bubble.h @@ -0,0 +1,89 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_VIEWS_PINNED_CONTENTS_INFO_BUBBLE_H_ +#define CHROME_BROWSER_VIEWS_PINNED_CONTENTS_INFO_BUBBLE_H_ + +#include "chrome/browser/views/info_bubble.h" + +// This is a specialization of BorderContents, used to draw a border around +// an InfoBubble that has its contents pinned to a specific location. See +// base class for details. +class PinnedContentsBorderContents : public BorderContents { + public: + explicit PinnedContentsBorderContents(const gfx::Point& bubble_anchor) + : bubble_anchor_(bubble_anchor) {} + + // BorderContents overrides: + virtual void InitAndGetBounds( + const gfx::Rect& position_relative_to, // In screen coordinates + const gfx::Size& contents_size, + bool prefer_arrow_on_right, + gfx::Rect* contents_bounds, // Returned in window coordinates + gfx::Rect* window_bounds); // Returned in screen coordinates + + private: + // The location of the pinned contents (in screen coordinates). + const gfx::Point bubble_anchor_; + + DISALLOW_COPY_AND_ASSIGN(PinnedContentsBorderContents); +}; + +#if defined(OS_WIN) +// The window that surrounds the info bubble. See base class for details. +class PinnedContentsBorderWidget : public BorderWidget { + public: + explicit PinnedContentsBorderWidget(const gfx::Point& bubble_anchor) + : bubble_anchor_(bubble_anchor) {} + virtual ~PinnedContentsBorderWidget() {} + + // BorderWidget overrides: + virtual gfx::Rect InitAndGetBounds(HWND owner, + const gfx::Rect& position_relative_to, + const gfx::Size& contents_size, + bool is_rtl); + + private: + // The location of the pinned contents (in screen coordinates). + const gfx::Point bubble_anchor_; + + DISALLOW_COPY_AND_ASSIGN(PinnedContentsBorderWidget); +}; +#endif + +// A specialization of the InfoBubble. Used to draw an InfoBubble which, in +// addition to having an arrow pointing to where the user clicked, also shifts +// the bubble horizontally to fix it to a specific location. See base class +// for details. +class PinnedContentsInfoBubble : public InfoBubble { + public: + // Shows the InfoBubble (see base class function for details). + // |bubble_anchor| specifies how far horizontally to shift the bubble in + // order to anchor its contents. Once the InfoBubble has been anchored its + // arrow may be pointing to a slightly different |y| location than specified + // in |position_relative_to|. + static PinnedContentsInfoBubble* Show(views::Window* parent, + const gfx::Rect& position_relative_to, + const gfx::Point& bubble_anchor_, + views::View* contents, + InfoBubbleDelegate* delegate); + + private: + explicit PinnedContentsInfoBubble(const gfx::Point& bubble_anchor) + : bubble_anchor_(bubble_anchor) {} + virtual ~PinnedContentsInfoBubble() {} + + // InfoBubble overrides: + virtual void Init(views::Window* parent, + const gfx::Rect& position_relative_to, + views::View* contents, + InfoBubbleDelegate* delegate); + + // The location of the pinned contents (in screen coordinates). + const gfx::Point bubble_anchor_; + + DISALLOW_COPY_AND_ASSIGN(PinnedContentsInfoBubble); +}; + +#endif // CHROME_BROWSER_VIEWS_PINNED_CONTENTS_INFO_BUBBLE_H_ |