Index: chrome/browser/ui/views/location_bar/location_bar_view.cc |
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
index 9431a0d7b908239da0419154ae75402a39f80c39..1f27d6ad60adad6f877f0003fc8a93812c8403b5 100644 |
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc |
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
@@ -77,6 +77,7 @@ |
#include "ui/views/widget/widget.h" |
#if defined(OS_WIN) && !defined(USE_AURA) |
+#include "base/win/metro.h" |
#include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" |
#endif |
@@ -245,8 +246,13 @@ void LocationBarView::Init(views::View* popup_parent_view) { |
// URL edit field. |
// View container for URL edit field. |
+ OmniboxWindowMode omnibox_window_mode = |
+ (mode_ == POPUP) ? OMNIBOX_WINDOW_MODE_POPUP : |
+ (mode_ == METRO_SNAP) ? OMNIBOX_WINDOW_MODE_DISABLED : |
+ OMNIBOX_WINDOW_MODE_NORMAL; |
+ |
location_entry_.reset(CreateOmniboxView(this, model_, profile_, |
- command_updater_, mode_ == POPUP, this, popup_parent_view)); |
+ command_updater_, omnibox_window_mode, this, popup_parent_view)); |
SetLocationEntryFocusable(true); |
location_entry_view_ = location_entry_->AddToView(this); |
@@ -587,8 +593,12 @@ gfx::Size LocationBarView::GetPreferredSize() { |
location_entry_->GetFont())); |
int delta = chrome::search::IsInstantExtendedAPIEnabled(profile_) ? |
kSearchEditHeightPadding : 0; |
- return gfx::Size(0, GetThemeProvider()->GetImageSkiaNamed(mode_ == POPUP ? |
- IDR_LOCATIONBG_POPUPMODE_CENTER : IDR_LOCATIONBG_C)->height() + delta); |
+ |
+ int image_id = (mode_ == POPUP || mode_ == METRO_SNAP) ? |
+ IDR_LOCATIONBG_POPUPMODE_CENTER : IDR_LOCATIONBG_C; |
+ return gfx::Size( |
+ 0, |
+ GetThemeProvider()->GetImageSkiaNamed(image_id)->height() + delta); |
} |
void LocationBarView::Layout() { |
@@ -618,7 +628,7 @@ void LocationBarView::Layout() { |
// The edge stroke is 1 px thick. In popup mode, the edges are drawn by the |
// omnibox' parent, so there isn't any edge to account for at all. |
- const int kEdgeThickness = (mode_ == NORMAL) ? |
+ const int kEdgeThickness = (mode_ == NORMAL || mode_ == METRO_SNAP) ? |
kNormalHorizontalEdgeThickness : 0; |
// The edit has 1 px of horizontal whitespace inside it before the text. |
const int kEditInternalSpace = 1; |
@@ -877,7 +887,7 @@ void LocationBarView::OnPaint(gfx::Canvas* canvas) { |
if (painter_.get()) { |
painter_->Paint(canvas, size()); |
- } else if (mode_ == POPUP) { |
+ } else if (mode_ == POPUP || mode_ == METRO_SNAP) { |
canvas->TileImageInt(*GetThemeProvider()->GetImageSkiaNamed( |
IDR_LOCATIONBG_POPUPMODE_CENTER), 0, 0, 0, 0, width(), height()); |
} |
@@ -1171,6 +1181,20 @@ void LocationBarView::RefreshPageActionViews() { |
#if defined(OS_WIN) && !defined(USE_AURA) |
void LocationBarView::OnMouseEvent(const views::MouseEvent& event, UINT msg) { |
+ // Attempt to unsnap if we're in metro snap mode. |
+ if (mode_ == METRO_SNAP) { |
+ HMODULE metro = base::win::GetMetroModule(); |
+ if (metro) { |
+ base::win::MetroUnsnapFn metro_unsnap_fn = |
+ reinterpret_cast<base::win::MetroUnsnapFn>( |
+ ::GetProcAddress(metro, "MetroUnsnap")); |
+ if (metro_unsnap_fn) { |
+ metro_unsnap_fn(); |
+ return; |
+ } |
+ } |
+ } |
+ |
OmniboxViewWin* omnibox_win = GetOmniboxViewWin(location_entry_.get()); |
if (omnibox_win) { |
UINT flags = event.native_event().wParam; |