summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/app_launcher.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/views/app_launcher.cc')
-rw-r--r--chrome/browser/views/app_launcher.cc76
1 files changed, 30 insertions, 46 deletions
diff --git a/chrome/browser/views/app_launcher.cc b/chrome/browser/views/app_launcher.cc
index a074f84..d1e87aa 100644
--- a/chrome/browser/views/app_launcher.cc
+++ b/chrome/browser/views/app_launcher.cc
@@ -16,13 +16,12 @@
#include "chrome/browser/autocomplete/autocomplete_edit_view.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_window.h"
+#include "chrome/browser/bubble_positioner.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/browser/view_ids.h"
#include "chrome/browser/views/dom_view.h"
#include "chrome/browser/views/info_bubble.h"
#include "chrome/browser/views/frame/browser_view.h"
-#include "chrome/browser/views/toolbar_view.h"
#include "chrome/common/url_constants.h"
#include "views/widget/root_view.h"
#include "views/widget/widget.h"
@@ -46,11 +45,10 @@ const int kNavigationEntryYMargin = 1;
// Padding between the navigation bar and the render view contents.
const int kNavigationBarBottomPadding = 3;
-// NavigationBar constants.
-const int kNavigationBarHeight = 23;
-const int kNavigationBarBorderThickness = 1;
+// NavigationBar size.
+const int kNavigationBarHeight = 25;
-// The delta applied to the default font size for the Omnibox.
+// The delta applied to the default font size for the omnibox.
const int kAutocompleteEditFontDelta = 3;
// Command line switch for specifying url of the page.
@@ -74,7 +72,8 @@ static GURL GetMenuURL() {
// mode.
class NavigationBar : public views::View,
- public AutocompleteEditController {
+ public AutocompleteEditController,
+ public BubblePositioner {
public:
explicit NavigationBar(AppLauncher* app_launcher)
: app_launcher_(app_launcher),
@@ -82,12 +81,7 @@ class NavigationBar : public views::View,
SetFocusable(true);
location_entry_view_ = new views::NativeViewHost;
AddChildView(location_entry_view_);
- set_border(views::Border::CreateSolidBorder(kNavigationBarBorderThickness,
- SK_ColorGRAY));
-
- AddChildView(&popup_positioning_view_);
- popup_positioning_view_.SetVisible(false);
- popup_positioning_view_.set_parent_owned(false);
+ set_border(views::Border::CreateSolidBorder(1, SK_ColorGRAY));
}
virtual ~NavigationBar() {
@@ -117,8 +111,7 @@ class NavigationBar : public views::View,
new AutocompleteEditViewWin(font, this, browser->toolbar_model(),
this, GetWidget()->GetNativeView(),
browser->profile(),
- browser->command_updater(), false,
- &popup_positioning_view_);
+ browser->command_updater(), false, this);
location_entry_.reset(autocomplete_view);
autocomplete_view->Update(NULL);
// The Update call above sets the autocomplete text to the current one in
@@ -128,11 +121,10 @@ class NavigationBar : public views::View,
AutocompleteEditViewGtk* autocomplete_view =
new AutocompleteEditViewGtk(this, browser->toolbar_model(),
browser->profile(),
- browser->command_updater(), false,
- &popup_positioning_view_);
+ browser->command_updater(), false, this);
autocomplete_view->Init();
- gtk_widget_show_all(autocomplete_view->GetNativeView());
- gtk_widget_hide(autocomplete_view->GetNativeView());
+ gtk_widget_show_all(autocomplete_view->widget());
+ gtk_widget_hide(autocomplete_view->widget());
location_entry_.reset(autocomplete_view);
#else
NOTIMPLEMENTED();
@@ -149,10 +141,21 @@ class NavigationBar : public views::View,
bounds.width() - 2 * (kNavigationEntryPadding +
kNavigationEntryXMargin),
bounds.height() - kNavigationEntryYMargin * 2);
+ }
- gfx::Rect popup_positioning_bounds(bounds);
- popup_positioning_bounds.Inset(0, -(kNavigationBarBorderThickness + 1));
- popup_positioning_view_.SetBounds(popup_positioning_bounds);
+ // BubblePositioner implementation.
+ virtual gfx::Rect GetLocationStackBounds() const {
+ gfx::Rect bounds = location_entry_view_->GetBounds(
+ views::View::APPLY_MIRRORING_TRANSFORMATION);
+ gfx::Point origin(bounds.x(), bounds.bottom() + kNavigationEntryPadding);
+ views::View::ConvertPointToScreen(this, &origin);
+ gfx::Rect rect = gfx::Rect(origin, gfx::Size(500, 0));
+ if (UILayoutIsRightToLeft()) {
+ // Align the window to the right side of the entry view when
+ // UI is RTL mode.
+ rect.set_x(rect.x() - (rect.width() - location_entry_view_->width()));
+ }
+ return rect;
}
// AutocompleteController implementation.
@@ -192,11 +195,6 @@ class NavigationBar : public views::View,
NOTIMPLEMENTED();
#endif
- // This invisible view is provided to the popup in place of |this|, so the
- // popup can size itself against it using the same offsets it does with the
- // LocationBarView.
- views::View popup_positioning_view_;
-
DISALLOW_COPY_AND_ASSIGN(NavigationBar);
};
@@ -239,7 +237,6 @@ InfoBubbleContentsView::InfoBubbleContentsView(AppLauncher* app_launcher)
: app_launcher_(app_launcher),
navigation_bar_(NULL),
dom_view_(NULL) {
- DCHECK(app_launcher);
}
InfoBubbleContentsView::~InfoBubbleContentsView() {
@@ -302,7 +299,6 @@ void InfoBubbleContentsView::Layout() {
AppLauncher::AppLauncher(Browser* browser)
: browser_(browser),
info_bubble_(NULL) {
- DCHECK(browser);
info_bubble_content_ = new InfoBubbleContentsView(this);
}
@@ -310,15 +306,12 @@ AppLauncher::~AppLauncher() {
}
// static
-AppLauncher* AppLauncher::Show(Browser* browser,
- const gfx::Rect& bounds,
- const gfx::Point& bubble_anchor) {
+AppLauncher* AppLauncher::Show(Browser* browser, const gfx::Rect& bounds) {
AppLauncher* app_launcher = new AppLauncher(browser);
BrowserView* browser_view = static_cast<BrowserView*>(browser->window());
app_launcher->info_bubble_ =
- PinnedContentsInfoBubble::Show(browser_view->frame()->GetWindow(),
- bounds, bubble_anchor, app_launcher->info_bubble_content_,
- app_launcher);
+ InfoBubble::Show(browser_view->frame()->GetWindow(), bounds,
+ app_launcher->info_bubble_content_, app_launcher);
app_launcher->info_bubble_content_->BubbleShown();
return app_launcher;
}
@@ -333,17 +326,7 @@ AppLauncher* AppLauncher::ShowForNewTab(Browser* browser) {
gfx::Point origin = bounds.origin();
views::RootView::ConvertPointToScreen(tabstrip, &origin);
bounds.set_origin(origin);
-
- // Figure out where the location bar is, so we can pin the bubble to
- // make our url bar appear exactly over it.
- views::RootView* root_view = views::Widget::GetWidgetFromNativeWindow(
- browser_view->GetNativeHandle())->GetRootView();
- views::View* location_bar = root_view->GetViewByID(VIEW_ID_LOCATION_BAR);
- gfx::Point location_bar_origin = location_bar->bounds().origin();
- views::RootView::ConvertPointToScreen(location_bar->GetParent(),
- &location_bar_origin);
-
- return Show(browser, bounds, location_bar_origin);
+ return Show(browser, bounds);
}
void AppLauncher::Hide() {
@@ -369,6 +352,7 @@ void AppLauncher::InfoBubbleClosing(InfoBubble* info_bubble,
new DeleteTask<AppLauncher>(this));
}
+
void AppLauncher::AddTabWithURL(const GURL& url,
PageTransition::Type transition) {
#if defined(OS_CHROMEOS)