summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-11 17:41:37 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-11 17:41:37 +0000
commitdcf6c130ddd91d3349ec503203ea89d1600f2462 (patch)
treeffc52f5383a4bf6a70948a789d9f4ff5807ce1e2
parent82a5648222234f6a02f2d7332ca5b478760cd0b2 (diff)
downloadchromium_src-dcf6c130ddd91d3349ec503203ea89d1600f2462.zip
chromium_src-dcf6c130ddd91d3349ec503203ea89d1600f2462.tar.gz
chromium_src-dcf6c130ddd91d3349ec503203ea89d1600f2462.tar.bz2
Revert 65813 - Removes the close button from instant on windows.
BUG=59068 TEST=none Review URL: http://codereview.chromium.org/4667008 TBR=sky@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65815 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/theme/match_preview_tear.pngbin0 -> 2303 bytes
-rw-r--r--chrome/app/theme/theme_resources.grd1
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc2
-rw-r--r--chrome/browser/ui/views/frame/contents_container.cc144
-rw-r--r--chrome/browser/ui/views/frame/contents_container.h33
5 files changed, 173 insertions, 7 deletions
diff --git a/chrome/app/theme/match_preview_tear.png b/chrome/app/theme/match_preview_tear.png
new file mode 100644
index 0000000..17ee2b4
--- /dev/null
+++ b/chrome/app/theme/match_preview_tear.png
Binary files differ
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd
index ca7a595..dd8672e 100644
--- a/chrome/app/theme/theme_resources.grd
+++ b/chrome/app/theme/theme_resources.grd
@@ -210,6 +210,7 @@
<include name="IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_C" file="keyword_search_bubble_c.png" type="BINDATA" />
<include name="IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_L" file="keyword_search_bubble_l.png" type="BINDATA" />
<include name="IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R" file="keyword_search_bubble_r.png" type="BINDATA" />
+ <include name="IDR_MATCH_PREVIEW_TEAR" file="match_preview_tear.png" type="BINDATA" />
<include name="IDR_MAXIMIZE_BUTTON_MASK" file="maximize_button_mask.png" type="BINDATA" />
<include name="IDR_MINIMIZE_BUTTON_MASK" file="minimize_button_mask.png" type="BINDATA" />
<include name="IDR_NEWTAB_BUTTON" file="newtab.png" type="BINDATA" />
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 25d8467..949b73b 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -1871,7 +1871,7 @@ void BrowserView::Init() {
AddChildView(infobar_container_);
contents_container_ = new TabContentsContainer;
- contents_ = new ContentsContainer(contents_container_);
+ contents_ = new ContentsContainer(this, contents_container_);
SkColor bg_color = GetWidget()->GetThemeProvider()->
GetColor(BrowserThemeProvider::COLOR_TOOLBAR);
diff --git a/chrome/browser/ui/views/frame/contents_container.cc b/chrome/browser/ui/views/frame/contents_container.cc
index c3056f7..fd80e3b 100644
--- a/chrome/browser/ui/views/frame/contents_container.cc
+++ b/chrome/browser/ui/views/frame/contents_container.cc
@@ -4,20 +4,77 @@
#include "chrome/browser/views/frame/contents_container.h"
-ContentsContainer::ContentsContainer(views::View* active)
- : active_(active),
+#include "app/resource_bundle.h"
+#include "chrome/browser/location_bar.h"
+#include "chrome/browser/views/frame/browser_view.h"
+#include "grit/theme_resources.h"
+#include "views/controls/image_view.h"
+#include "views/widget/root_view.h"
+
+#if defined(OS_WIN)
+#include "views/widget/widget_win.h"
+#elif defined(OS_LINUX)
+#include "chrome/browser/gtk/gtk_util.h"
+#include "views/window/window_gtk.h"
+#endif
+
+#if defined(OS_WIN)
+
+class ContentsContainer::TearWindow : public views::WidgetWin {
+ public:
+ explicit TearWindow(ContentsContainer* contents_container)
+ : contents_container_(contents_container) {
+ set_window_style(WS_POPUP | WS_CLIPCHILDREN);
+ set_window_ex_style(WS_EX_TOOLWINDOW | WS_EX_LAYERED);
+ }
+
+ virtual ~TearWindow() {
+ // On windows it's possible for us to be deleted before the
+ // ContentsContainer. If this happens make sure contents_container_ doesn't
+ // attempt to delete us too.
+ if (contents_container_)
+ contents_container_->TearWindowDestroyed();
+ }
+
+ void set_contents_container(ContentsContainer* contents_container) {
+ contents_container_ = contents_container;
+ }
+
+ virtual LRESULT OnMouseActivate(HWND window,
+ UINT hit_test,
+ UINT mouse_message) {
+ // Don't activate the window when the user clicks it.
+ contents_container_->browser_view_->GetLocationBar()->Revert();
+ return MA_NOACTIVATE;
+ }
+
+ private:
+ ContentsContainer* contents_container_;
+
+ DISALLOW_COPY_AND_ASSIGN(TearWindow);
+};
+
+#endif
+
+ContentsContainer::ContentsContainer(BrowserView* browser_view,
+ views::View* active)
+ : browser_view_(browser_view),
+ active_(active),
preview_(NULL),
preview_tab_contents_(NULL),
+ tear_window_(NULL),
active_top_margin_(0) {
AddChildView(active_);
}
ContentsContainer::~ContentsContainer() {
+ DeleteTearWindow();
}
void ContentsContainer::MakePreviewContentsActiveContents() {
active_ = preview_;
preview_ = NULL;
+ DeleteTearWindow();
Layout();
}
@@ -26,14 +83,21 @@ void ContentsContainer::SetPreview(views::View* preview,
if (preview == preview_)
return;
- if (preview_)
+ if (preview_) {
RemoveChildView(preview_);
+ DeleteTearWindow();
+ }
preview_ = preview;
preview_tab_contents_ = preview_tab_contents;
- if (preview_)
+ if (preview_) {
AddChildView(preview_);
+ CreateTearWindow();
+ }
Layout();
+
+ if (preview_)
+ tear_window_->Show(); // Show after we'ved positioned it in Layout.
}
void ContentsContainer::SetActiveTopMargin(int margin) {
@@ -57,10 +121,80 @@ void ContentsContainer::Layout() {
active_->SetBounds(0, active_top_margin_, width(),
std::max(0, height() - active_top_margin_));
- if (preview_)
+ if (preview_) {
preview_->SetBounds(0, 0, width(), height());
+ PositionTearWindow();
+ }
// Need to invoke views::View in case any views whose bounds didn't change
// still need a layout.
views::View::Layout();
}
+
+void ContentsContainer::CreateTearWindow() {
+ DCHECK(preview_);
+ tear_window_ = CreateTearWindowImpl();
+
+ views::ImageView* image_view = new views::ImageView();
+ image_view->SetImage(ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_MATCH_PREVIEW_TEAR));
+ tear_window_->SetContentsView(image_view);
+}
+
+#if defined(OS_WIN)
+
+ContentsContainer::TearWindow* ContentsContainer::CreateTearWindowImpl() {
+ TearWindow* widget = new TearWindow(this);
+ widget->Init(browser_view_->GetNativeHandle(), gfx::Rect());
+ return widget;
+}
+
+#elif defined(OS_LINUX)
+
+ContentsContainer::TearWindow* ContentsContainer::CreateTearWindowImpl() {
+ views::WidgetGtk* widget = new views::WidgetGtk(views::WidgetGtk::TYPE_POPUP);
+ widget->MakeTransparent();
+ widget->Init(NULL, gfx::Rect());
+ gtk_util::StackPopupWindow(widget->GetNativeView(),
+ GTK_WIDGET(browser_view_->GetNativeHandle()));
+ return widget;
+}
+
+#endif
+
+void ContentsContainer::PositionTearWindow() {
+ if (!tear_window_)
+ return;
+
+ gfx::Rect vis_bounds = GetVisibleBounds();
+
+ gfx::Size pref = tear_window_->GetRootView()->GetPreferredSize();
+ // Constrain to the the visible bounds as we may be given a different size
+ // than is actually visible.
+ pref.SetSize(std::min(pref.width(), vis_bounds.width()),
+ std::min(pref.height(), vis_bounds.height()));
+
+ gfx::Rect bounds(0, 0, pref.width(), pref.height());
+ bounds.set_x(MirroredLeftPointForRect(bounds));
+
+ gfx::Point origin(bounds.origin());
+ views::View::ConvertPointToScreen(this, &origin);
+
+ tear_window_->SetBounds(gfx::Rect(origin, pref));
+}
+
+void ContentsContainer::DeleteTearWindow() {
+ if (!tear_window_)
+ return;
+
+ tear_window_->Close();
+#if defined(OS_WIN)
+ tear_window_->set_contents_container(NULL);
+#endif
+ // Close deletes the tear window.
+ tear_window_ = NULL;
+}
+
+void ContentsContainer::TearWindowDestroyed() {
+ tear_window_ = NULL;
+}
diff --git a/chrome/browser/ui/views/frame/contents_container.h b/chrome/browser/ui/views/frame/contents_container.h
index 8943f0a..2e00fa7 100644
--- a/chrome/browser/ui/views/frame/contents_container.h
+++ b/chrome/browser/ui/views/frame/contents_container.h
@@ -8,14 +8,19 @@
#include "views/view.h"
+class BrowserView;
class TabContents;
+namespace views {
+class Widget;
+}
+
// ContentsContainer is responsible for managing the TabContents views.
// ContentsContainer has up to two children: one for the currently active
// TabContents and one for instant's TabContents.
class ContentsContainer : public views::View {
public:
- explicit ContentsContainer(views::View* active);
+ ContentsContainer(BrowserView* browser_view, views::View* active);
virtual ~ContentsContainer();
// Makes the preview view the active view and nulls out the old active view.
@@ -39,12 +44,38 @@ class ContentsContainer : public views::View {
virtual void Layout();
private:
+#if defined(OS_WIN)
+ class TearWindow;
+#else
+ typedef views::Widget TearWindow;
+#endif
+
+ // Creates and configures the tear window.
+ void CreateTearWindow();
+
+ // Creates and returns a new TearWindow.
+ TearWindow* CreateTearWindowImpl();
+
+ // Resets the bounds of the tear window.
+ void PositionTearWindow();
+
+ // Closes and deletes the tear window.
+ void DeleteTearWindow();
+
+ // Invoked when the tear window is destroyed.
+ void TearWindowDestroyed();
+
+ BrowserView* browser_view_;
+
views::View* active_;
views::View* preview_;
TabContents* preview_tab_contents_;
+ // Window used to show the page tear.
+ TearWindow* tear_window_;
+
// The margin between the top and the active view. This is used to make the
// preview overlap the bookmark bar on the new tab page.
int active_top_margin_;