diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-22 16:59:24 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-22 16:59:24 +0000 |
commit | ea87eee46258f8a3a75a2d244342b50721e4fb9d (patch) | |
tree | 239760d7015a95cad5e8ed2eeb25a55d3fa85bc7 /chrome | |
parent | b1d963d60e08720fab32ea5d582e636895feb0d7 (diff) | |
download | chromium_src-ea87eee46258f8a3a75a2d244342b50721e4fb9d.zip chromium_src-ea87eee46258f8a3a75a2d244342b50721e4fb9d.tar.gz chromium_src-ea87eee46258f8a3a75a2d244342b50721e4fb9d.tar.bz2 |
Removes tab overview related classes and renames TabOverviewTypes to
WmIpc.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/646079
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39604 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
31 files changed, 184 insertions, 2485 deletions
diff --git a/chrome/app/theme/new_browser_window.png b/chrome/app/theme/new_browser_window.png Binary files differdeleted file mode 100644 index 6ed666b..0000000 --- a/chrome/app/theme/new_browser_window.png +++ /dev/null diff --git a/chrome/app/theme/tab_overview.png b/chrome/app/theme/tab_overview.png Binary files differdeleted file mode 100644 index a6afc03..0000000 --- a/chrome/app/theme/tab_overview.png +++ /dev/null diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd index 3a5cb853..8e23064 100644 --- a/chrome/app/theme/theme_resources.grd +++ b/chrome/app/theme/theme_resources.grd @@ -353,9 +353,6 @@ </if> <if expr="pp_ifdef('chromeos') or pp_ifdef('toolkit_views')"> - <include name="IDR_NEW_BROWSER_WINDOW_ICON" file="new_browser_window.png" type="BINDATA" /> - <include name="IDR_TAB_OVERVIEW_BUTTON_ICON" file="tab_overview.png" type="BINDATA" /> - <include name="IDR_THEME_FRAME" file="theme_frame_default2.png" type="BINDATA" /> <include name="IDR_THEME_TAB_BACKGROUND" file="theme_tab_background2.png" type="BINDATA" /> <include name="IDR_THEME_FRAME_INCOGNITO_INACTIVE" file="theme_frame_default_incognito_inactive2.png" type="BINDATA" /> diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc index a7589c7..6e9f1e1 100644 --- a/chrome/browser/browser_init.cc +++ b/chrome/browser/browser_init.cc @@ -62,7 +62,7 @@ #include "chrome/browser/chromeos/cros/mount_library.h" #include "chrome/browser/chromeos/gview_request_interceptor.h" #include "chrome/browser/chromeos/usb_mount_observer.h" -#include "chrome/browser/views/tabs/tab_overview_message_listener.h" +#include "chrome/browser/chromeos/wm_message_listener.h" #endif namespace { @@ -365,9 +365,9 @@ bool BrowserInit::LaunchBrowser( } #if defined(OS_CHROMEOS) - // Create the TabOverviewMessageListener so that it can listen for messages - // regardless of what window has focus. - TabOverviewMessageListener::instance(); + // Create the WmMessageListener so that it can listen for messages regardless + // of what window has focus. + chromeos::WmMessageListener::instance(); // Install the GView request interceptor that will redirect requests // of compatible documents (PDF, etc) to the GView document viewer. diff --git a/chrome/browser/chromeos/frame/browser_view.cc b/chrome/browser/chromeos/frame/browser_view.cc index e7a1c9c..d5cbddc 100644 --- a/chrome/browser/chromeos/frame/browser_view.cc +++ b/chrome/browser/chromeos/frame/browser_view.cc @@ -18,13 +18,13 @@ #include "chrome/browser/chromeos/main_menu.h" #include "chrome/browser/chromeos/status/browser_status_area_view.h" #include "chrome/browser/chromeos/status/status_area_button.h" +#include "chrome/browser/chromeos/wm_ipc.h" #include "chrome/browser/view_ids.h" #include "chrome/browser/views/frame/browser_extender.h" #include "chrome/browser/views/frame/browser_frame_gtk.h" #include "chrome/browser/views/frame/browser_view.h" #include "chrome/browser/views/frame/browser_view_layout.h" #include "chrome/browser/views/tabs/tab.h" -#include "chrome/browser/views/tabs/tab_overview_types.h" #include "chrome/browser/views/tabs/tab_strip.h" #include "chrome/browser/views/toolbar_view.h" #include "chrome/browser/views/toolbar_star_toggle.h" @@ -390,9 +390,9 @@ void BrowserView::Show() { bool was_visible = frame()->GetWindow()->IsVisible(); ::BrowserView::Show(); if (!was_visible) { - TabOverviewTypes::instance()->SetWindowType( + WmIpc::instance()->SetWindowType( GTK_WIDGET(frame()->GetWindow()->GetNativeWindow()), - TabOverviewTypes::WINDOW_TYPE_CHROME_TOPLEVEL, + WmIpc::WINDOW_TYPE_CHROME_TOPLEVEL, NULL); } } diff --git a/chrome/browser/chromeos/frame/panel_controller.cc b/chrome/browser/chromeos/frame/panel_controller.cc index 2e53cd63..8f2d1b7 100644 --- a/chrome/browser/chromeos/frame/panel_controller.cc +++ b/chrome/browser/chromeos/frame/panel_controller.cc @@ -12,7 +12,7 @@ #include "base/scoped_ptr.h" #include "base/string_util.h" #include "chrome/browser/browser.h" -#include "chrome/browser/views/tabs/tab_overview_types.h" +#include "chrome/browser/chromeos/wm_ipc.h" #include "chrome/common/x11_util.h" #include "grit/app_resources.h" #include "grit/generated_resources.h" @@ -97,17 +97,16 @@ void PanelController::Init(const gfx::Rect window_bounds) { title_ = title_window_->GetNativeView(); title_xid_ = x11_util::GetX11WindowFromGtkWidget(title_); - TabOverviewTypes* tab_overview = TabOverviewTypes::instance(); - tab_overview->SetWindowType( + WmIpc::instance()->SetWindowType( title_, - TabOverviewTypes::WINDOW_TYPE_CHROME_PANEL_TITLEBAR, + WmIpc::WINDOW_TYPE_CHROME_PANEL_TITLEBAR, NULL); std::vector<int> type_params; type_params.push_back(title_xid_); type_params.push_back(expanded_ ? 1 : 0); - tab_overview->SetWindowType( + WmIpc::instance()->SetWindowType( GTK_WIDGET(panel_), - TabOverviewTypes::WINDOW_TYPE_CHROME_PANEL_CONTENT, + WmIpc::WINDOW_TYPE_CHROME_PANEL_CONTENT, &type_params); g_signal_connect(panel_, "client-event", @@ -167,16 +166,14 @@ void PanelController::TitleMouseReleased( mouse_down_ = false; if (!dragging_) { - TabOverviewTypes::Message msg( - TabOverviewTypes::Message::WM_SET_PANEL_STATE); + WmIpc::Message msg(WmIpc::Message::WM_SET_PANEL_STATE); msg.set_param(0, panel_xid_); msg.set_param(1, expanded_ ? 0 : 1); - TabOverviewTypes::instance()->SendMessage(msg); + WmIpc::instance()->SendMessage(msg); } else { - TabOverviewTypes::Message msg( - TabOverviewTypes::Message::WM_NOTIFY_PANEL_DRAG_COMPLETE); + WmIpc::Message msg(WmIpc::Message::WM_NOTIFY_PANEL_DRAG_COMPLETE); msg.set_param(0, panel_xid_); - TabOverviewTypes::instance()->SendMessage(msg); + WmIpc::instance()->SendMessage(msg); dragging_ = false; } } @@ -201,12 +198,11 @@ bool PanelController::TitleMouseDragged(const views::MouseEvent& event) { } } if (dragging_) { - TabOverviewTypes::Message msg( - TabOverviewTypes::Message::WM_NOTIFY_PANEL_DRAGGED); + WmIpc::Message msg(WmIpc::Message::WM_NOTIFY_PANEL_DRAGGED); msg.set_param(0, panel_xid_); msg.set_param(1, last_motion_event.x_root - mouse_down_offset_x_); msg.set_param(2, last_motion_event.y_root - mouse_down_offset_y_); - TabOverviewTypes::instance()->SendMessage(msg); + WmIpc::instance()->SendMessage(msg); } gdk_event_free(gdk_event); return true; @@ -231,9 +227,9 @@ void PanelController::OnFocusOut() { } bool PanelController::PanelClientEvent(GdkEventClient* event) { - TabOverviewTypes::Message msg; - TabOverviewTypes::instance()->DecodeMessage(*event, &msg); - if (msg.type() == TabOverviewTypes::Message::CHROME_NOTIFY_PANEL_STATE) { + WmIpc::Message msg; + WmIpc::instance()->DecodeMessage(*event, &msg); + if (msg.type() == WmIpc::Message::CHROME_NOTIFY_PANEL_STATE) { expanded_ = msg.param(0); } return true; diff --git a/chrome/browser/chromeos/main_menu.cc b/chrome/browser/chromeos/main_menu.cc index efe724e..69cef64 100644 --- a/chrome/browser/chromeos/main_menu.cc +++ b/chrome/browser/chromeos/main_menu.cc @@ -21,6 +21,7 @@ #include "chrome/browser/bubble_positioner.h" #include "chrome/browser/chromeos/frame/browser_view.h" #include "chrome/browser/chromeos/status/status_area_view.h" +#include "chrome/browser/chromeos/wm_ipc.h" #include "chrome/browser/in_process_webkit/dom_storage_context.h" #include "chrome/browser/in_process_webkit/webkit_context.h" #include "chrome/browser/profile.h" @@ -32,7 +33,6 @@ #include "chrome/browser/renderer_preferences_util.h" #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" #include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/browser/views/tabs/tab_overview_types.h" #include "grit/app_resources.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -296,9 +296,9 @@ MainMenu::MainMenu() // The background image has transparency, so we make the window transparent. menu_popup->MakeTransparent(); popup_->Init(NULL, gfx::Rect()); - TabOverviewTypes::instance()->SetWindowType( + WmIpc::instance()->SetWindowType( popup_->GetNativeView(), - TabOverviewTypes::WINDOW_TYPE_CHROME_INFO_BUBBLE, + WmIpc::WINDOW_TYPE_CHROME_INFO_BUBBLE, NULL); views::Painter* painter = views::Painter::CreateImagePainter( diff --git a/chrome/browser/views/tabs/tab_overview_types.cc b/chrome/browser/chromeos/wm_ipc.cc index 6ce76a3..d2c4260 100644 --- a/chrome/browser/views/tabs/tab_overview_types.cc +++ b/chrome/browser/chromeos/wm_ipc.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// 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. -#include "chrome/browser/views/tabs/tab_overview_types.h" +#include "chrome/browser/chromeos/wm_ipc.h" #include <gdk/gdkx.h> extern "C" { @@ -14,43 +14,32 @@ extern "C" { #include "base/scoped_ptr.h" #include "chrome/common/x11_util.h" +namespace chromeos { + namespace { // A value from the Atom enum and the actual name that should be used to // look up its ID on the X server. struct AtomInfo { - TabOverviewTypes::AtomType atom; + WmIpc::AtomType atom; const char* name; }; // Each value from the Atom enum must be present here. static const AtomInfo kAtomInfos[] = { - { TabOverviewTypes::ATOM_CHROME_WINDOW_TYPE, - "_CHROME_WINDOW_TYPE" }, - { TabOverviewTypes::ATOM_CHROME_WM_MESSAGE, - "_CHROME_WM_MESSAGE" }, - { TabOverviewTypes::ATOM_MANAGER, - "MANAGER" }, - { TabOverviewTypes::ATOM_NET_SUPPORTING_WM_CHECK, - "_NET_SUPPORTING_WM_CHECK" }, - { TabOverviewTypes::ATOM_NET_WM_NAME, - "_NET_WM_NAME" }, - { TabOverviewTypes::ATOM_PRIMARY, - "PRIMARY" }, - { TabOverviewTypes::ATOM_STRING, - "STRING" }, - { TabOverviewTypes::ATOM_UTF8_STRING, - "UTF8_STRING" }, - { TabOverviewTypes::ATOM_WM_NORMAL_HINTS, - "WM_NORMAL_HINTS" }, - { TabOverviewTypes::ATOM_WM_S0, - "WM_S0" }, - { TabOverviewTypes::ATOM_WM_STATE, - "WM_STATE" }, - { TabOverviewTypes::ATOM_WM_TRANSIENT_FOR, - "WM_TRANSIENT_FOR" }, - { TabOverviewTypes::ATOM_WM_SYSTEM_METRICS, - "WM_SYSTEM_METRICS" }, + { WmIpc::ATOM_CHROME_WINDOW_TYPE, "_CHROME_WINDOW_TYPE" }, + { WmIpc::ATOM_CHROME_WM_MESSAGE, "_CHROME_WM_MESSAGE" }, + { WmIpc::ATOM_MANAGER, "MANAGER" }, + { WmIpc::ATOM_NET_SUPPORTING_WM_CHECK, "_NET_SUPPORTING_WM_CHECK" }, + { WmIpc::ATOM_NET_WM_NAME, "_NET_WM_NAME" }, + { WmIpc::ATOM_PRIMARY, "PRIMARY" }, + { WmIpc::ATOM_STRING, "STRING" }, + { WmIpc::ATOM_UTF8_STRING, "UTF8_STRING" }, + { WmIpc::ATOM_WM_NORMAL_HINTS, "WM_NORMAL_HINTS" }, + { WmIpc::ATOM_WM_S0, "WM_S0" }, + { WmIpc::ATOM_WM_STATE, "WM_STATE" }, + { WmIpc::ATOM_WM_TRANSIENT_FOR, "WM_TRANSIENT_FOR" }, + { WmIpc::ATOM_WM_SYSTEM_METRICS, "WM_SYSTEM_METRICS" }, }; bool SetIntProperty(XID xid, Atom xatom, const std::vector<int>& values) { @@ -72,17 +61,16 @@ bool SetIntProperty(XID xid, Atom xatom, const std::vector<int>& values) { } // namespace // static -TabOverviewTypes* TabOverviewTypes::instance() { - static TabOverviewTypes* instance = NULL; +WmIpc* WmIpc::instance() { + static WmIpc* instance = NULL; if (!instance) - instance = Singleton<TabOverviewTypes>::get(); + instance = Singleton<WmIpc>::get(); return instance; } -bool TabOverviewTypes::SetWindowType( - GtkWidget* widget, - WindowType type, - const std::vector<int>* params) { +bool WmIpc::SetWindowType(GtkWidget* widget, + WindowType type, + const std::vector<int>* params) { std::vector<int> values; values.push_back(type); if (params) @@ -91,7 +79,7 @@ bool TabOverviewTypes::SetWindowType( type_to_atom_[ATOM_CHROME_WINDOW_TYPE], values); } -void TabOverviewTypes::SendMessage(const Message& msg) { +void WmIpc::SendMessage(const Message& msg) { XEvent e; e.xclient.type = ClientMessage; e.xclient.window = wm_; @@ -112,8 +100,8 @@ void TabOverviewTypes::SendMessage(const Message& msg) { &e); } -bool TabOverviewTypes::DecodeMessage(const GdkEventClient& event, - Message* msg) { +bool WmIpc::DecodeMessage(const GdkEventClient& event, + Message* msg) { if (wm_message_atom_ != gdk_x11_atom_to_xatom(event.message_type)) return false; @@ -140,8 +128,8 @@ bool TabOverviewTypes::DecodeMessage(const GdkEventClient& event, return true; } -bool TabOverviewTypes::DecodeStringMessage(const GdkEventProperty& event, - std::string* msg) { +bool WmIpc::DecodeStringMessage(const GdkEventProperty& event, + std::string* msg) { DCHECK(NULL != msg); if (type_to_atom_[ATOM_WM_SYSTEM_METRICS] != gdk_x11_atom_to_xatom(event.atom)) @@ -193,8 +181,7 @@ bool TabOverviewTypes::DecodeStringMessage(const GdkEventProperty& event, return true; } -void TabOverviewTypes::HandleNonChromeClientMessageEvent( - const GdkEventClient& event) { +void WmIpc::HandleNonChromeClientMessageEvent(const GdkEventClient& event) { // Only do these lookups once; they should never change. static GdkAtom manager_gdk_atom = gdk_x11_xatom_to_atom(type_to_atom_[ATOM_MANAGER]); @@ -206,7 +193,7 @@ void TabOverviewTypes::HandleNonChromeClientMessageEvent( } } -TabOverviewTypes::TabOverviewTypes() { +WmIpc::WmIpc() { scoped_array<char*> names(new char*[kNumAtoms]); scoped_array<Atom> atoms(new Atom[kNumAtoms]); @@ -237,14 +224,16 @@ TabOverviewTypes::TabOverviewTypes() { InitWmInfo(); } -void TabOverviewTypes::InitWmInfo() { +void WmIpc::InitWmInfo() { wm_ = XGetSelectionOwner(x11_util::GetXDisplay(), type_to_atom_[ATOM_WM_S0]); // Let the window manager know which version of the IPC messages we support. Message msg(Message::WM_NOTIFY_IPC_VERSION); - // TODO: The version number is the latest listed in tab_overview_types.h -- + // TODO: The version number is the latest listed in wm_ipc.h -- // ideally, once this header is shared between Chrome and the Chrome OS window // manager, we'll just define the version statically in the header. msg.set_param(0, 1); SendMessage(msg); } + +} // namespace chromeos diff --git a/chrome/browser/views/tabs/tab_overview_types.h b/chrome/browser/chromeos/wm_ipc.h index e19fdff..0cf997f 100644 --- a/chrome/browser/views/tabs/tab_overview_types.h +++ b/chrome/browser/chromeos/wm_ipc.h @@ -1,9 +1,9 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// 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_TABS_TAB_OVERVIEW_TYPES_H_ -#define CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_TYPES_H_ +#ifndef CHROME_BROWSER_CHROMEOS_WM_IPC_H_ +#define CHROME_BROWSER_CHROMEOS_WM_IPC_H_ #include <gtk/gtk.h> #include <map> @@ -16,8 +16,9 @@ typedef unsigned long Atom; typedef unsigned long XID; -// TODO(sky): move and rename. -class TabOverviewTypes { +namespace chromeos { + +class WmIpc { public: enum AtomType { ATOM_CHROME_WINDOW_TYPE = 0, @@ -228,8 +229,8 @@ class TabOverviewTypes { long params_[4]; }; - // Returns the single instance of TabOverviewTypes. - static TabOverviewTypes* instance(); + // Returns the single instance of WmIpc. + static WmIpc* instance(); // Get or set a property describing a window's type. Type-specific // parameters may also be supplied ('params' is mandatory for @@ -258,9 +259,9 @@ class TabOverviewTypes { void HandleNonChromeClientMessageEvent(const GdkEventClient& event); private: - friend struct DefaultSingletonTraits<TabOverviewTypes>; + friend struct DefaultSingletonTraits<WmIpc>; - TabOverviewTypes(); + WmIpc(); // Initialize 'wm_' and send the window manager a message telling it the // version of the IPC protocol that we support. This is called in our @@ -280,7 +281,9 @@ class TabOverviewTypes { // Handle to the wm. Used for sending messages. XID wm_; - DISALLOW_COPY_AND_ASSIGN(TabOverviewTypes); + DISALLOW_COPY_AND_ASSIGN(WmIpc); }; -#endif // CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_TYPES_H_ +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_WM_IPC_H_ diff --git a/chrome/browser/chromeos/wm_message_listener.cc b/chrome/browser/chromeos/wm_message_listener.cc new file mode 100644 index 0000000..564ec4e --- /dev/null +++ b/chrome/browser/chromeos/wm_message_listener.cc @@ -0,0 +1,44 @@ +// 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. + +#include "chrome/browser/chromeos/wm_message_listener.h" + +namespace chromeos { + +// static +WmMessageListener* WmMessageListener::instance() { + static WmMessageListener* instance = NULL; + if (!instance) { + instance = Singleton<WmMessageListener>::get(); + MessageLoopForUI::current()->AddObserver(instance); + } + return instance; +} + +void WmMessageListener::WillProcessEvent(GdkEvent* event) { +} + +void WmMessageListener::DidProcessEvent(GdkEvent* event) { + if (event->type == GDK_CLIENT_EVENT) { + WmIpc::Message message; + GdkEventClient* client_event = reinterpret_cast<GdkEventClient*>(event); + WmIpc* wm_ipc = WmIpc::instance(); + if (wm_ipc->DecodeMessage(*client_event, &message)) + ProcessMessage(message, client_event->window); + else + wm_ipc->HandleNonChromeClientMessageEvent(*client_event); + } +} + +WmMessageListener::WmMessageListener() { +} + +WmMessageListener::~WmMessageListener() { +} + +void WmMessageListener::ProcessMessage(const WmIpc::Message& message, + GdkWindow* window) { +} + +} // namespace chromeos diff --git a/chrome/browser/chromeos/wm_message_listener.h b/chrome/browser/chromeos/wm_message_listener.h new file mode 100644 index 0000000..f909073 --- /dev/null +++ b/chrome/browser/chromeos/wm_message_listener.h @@ -0,0 +1,43 @@ +// 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_CHROMEOS_WM_MESSAGE_LISTENER_H_ +#define CHROME_BROWSER_CHROMEOS_WM_MESSAGE_LISTENER_H_ + +#include <gtk/gtk.h> + +#include "base/message_loop.h" +#include "base/singleton.h" +#include "chrome/browser/chromeos/wm_ipc.h" + +class Browser; +class BrowserView; + +namespace chromeos { + +// WmMessageListener listens for messages from the window manager that need to +// be dealt with by Chrome. +class WmMessageListener : public MessageLoopForUI::Observer { + public: + static WmMessageListener* instance(); + + // MessageLoopForUI::Observer overrides. + virtual void WillProcessEvent(GdkEvent* event); + virtual void DidProcessEvent(GdkEvent* event); + + private: + friend struct DefaultSingletonTraits<WmMessageListener>; + + WmMessageListener(); + ~WmMessageListener(); + + // Invoked when a valid WmIpc::Message is received. + void ProcessMessage(const WmIpc::Message& message, GdkWindow* window); + + DISALLOW_COPY_AND_ASSIGN(WmMessageListener); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_WM_MESSAGE_LISTENER_H_ diff --git a/chrome/browser/views/browser_bubble_gtk.cc b/chrome/browser/views/browser_bubble_gtk.cc index 66b07c1..cf2ff0c 100644 --- a/chrome/browser/views/browser_bubble_gtk.cc +++ b/chrome/browser/views/browser_bubble_gtk.cc @@ -8,7 +8,9 @@ #include "views/widget/widget_gtk.h" #include "views/window/window.h" -#include "chrome/browser/views/tabs/tab_overview_types.h" +#if defined(OS_CHROMEOS) +#include "chrome/browser/chromeos/wm_ipc.h" +#endif namespace { @@ -84,10 +86,12 @@ void BrowserBubble::InitPopup() { pop->SetOpacity(0xFF); pop->make_transient_to_parent(); pop->Init(frame_->GetNativeView(), bounds_); - TabOverviewTypes::instance()->SetWindowType( +#if defined(OS_CHROMEOS) + chromeos::WmIpc::instance()->SetWindowType( pop->GetNativeView(), - TabOverviewTypes::WINDOW_TYPE_CHROME_INFO_BUBBLE, + chromeos::WmIpc::WINDOW_TYPE_CHROME_INFO_BUBBLE, NULL); +#endif pop->SetContentsView(view_); popup_ = pop; Reposition(); diff --git a/chrome/browser/views/extensions/extension_popup.cc b/chrome/browser/views/extensions/extension_popup.cc index 70c9222..c417e8e2 100644 --- a/chrome/browser/views/extensions/extension_popup.cc +++ b/chrome/browser/views/extensions/extension_popup.cc @@ -19,10 +19,13 @@ #include "views/window/window.h" #if defined(OS_LINUX) -#include "chrome/browser/views/tabs/tab_overview_types.h" #include "views/widget/widget_gtk.h" #endif +#if defined(OS_CHROMEOS) +#include "chrome/browser/chromeos/wm_ipc.h" +#endif + using views::Widget; // The minimum/maximum dimensions of the popup. @@ -80,10 +83,10 @@ ExtensionPopup::ExtensionPopup(ExtensionHost* host, Widget::DeleteOnDestroy); #endif border_widget_->Init(native_window, bounds()); -#if defined(OS_LINUX) - TabOverviewTypes::instance()->SetWindowType( +#if defined(OS_CHROMEOS) + chromeos::WmIpc::instance()->SetWindowType( border_widget_->GetNativeView(), - TabOverviewTypes::WINDOW_TYPE_CHROME_INFO_BUBBLE, + chromeos::WmIpc::WINDOW_TYPE_CHROME_INFO_BUBBLE, NULL); #endif diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc index 9f88fc8..165bc46 100644 --- a/chrome/browser/views/info_bubble.cc +++ b/chrome/browser/views/info_bubble.cc @@ -15,8 +15,8 @@ #include "views/widget/root_view.h" #include "views/window/window.h" -#if defined(OS_LINUX) -#include "chrome/browser/views/tabs/tab_overview_types.h" +#if defined(OS_CHROMEOS) +#include "chrome/browser/chromeos/wm_ipc.h" #endif // Background color of the bubble. @@ -240,11 +240,13 @@ void InfoBubble::Init(views::Window* parent, MakeTransparent(); make_transient_to_parent(); WidgetGtk::Init(GTK_WIDGET(parent->GetNativeWindow()), gfx::Rect()); - TabOverviewTypes::instance()->SetWindowType( +#if defined(OS_CHROMEOS) + chromeos::WmIpc::instance()->SetWindowType( GetNativeView(), - TabOverviewTypes::WINDOW_TYPE_CHROME_INFO_BUBBLE, + chromeos::WmIpc::WINDOW_TYPE_CHROME_INFO_BUBBLE, NULL); #endif +#endif // Create a View to hold the contents of the main window. views::View* contents_view = new views::View; diff --git a/chrome/browser/views/new_browser_window_widget.cc b/chrome/browser/views/new_browser_window_widget.cc deleted file mode 100644 index 7cc3950..0000000 --- a/chrome/browser/views/new_browser_window_widget.cc +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2009 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. - -#include "chrome/browser/views/new_browser_window_widget.h" - -#include "app/resource_bundle.h" -#include "chrome/browser/browser.h" -#include "chrome/browser/browser_window.h" -#include "chrome/browser/metrics/user_metrics.h" -#include "chrome/browser/profile.h" -#include "chrome/browser/views/tabs/tab_overview_types.h" -#include "chrome/common/page_transition_types.h" -#include "googleurl/src/gurl.h" -#include "grit/theme_resources.h" -#include "views/controls/button/image_button.h" -#include "views/fill_layout.h" -#include "views/widget/root_view.h" -#include "views/widget/widget_gtk.h" - -NewBrowserWindowWidget::NewBrowserWindowWidget(Profile* profile) - : profile_(profile), - widget_(NULL) { - views::ImageButton* button = new views::ImageButton(this); - button->SetImage(views::CustomButton::BS_NORMAL, - ResourceBundle::GetSharedInstance().GetBitmapNamed( - IDR_NEW_BROWSER_WINDOW_ICON)); - gfx::Size pref = button->GetPreferredSize(); - views::WidgetGtk* widget = - new views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW); - widget->MakeTransparent(); - widget->Init(NULL, gfx::Rect(0, 0, pref.width(), pref.height())); - TabOverviewTypes::instance()->SetWindowType( - widget->GetNativeView(), - TabOverviewTypes::WINDOW_TYPE_CREATE_BROWSER_WINDOW, - NULL); - widget->GetRootView()->SetLayoutManager(new views::FillLayout()); - widget->GetRootView()->AddChildView(button); - widget_ = widget; - widget->Show(); -} - -NewBrowserWindowWidget::~NewBrowserWindowWidget() { - widget_->Close(); - widget_ = NULL; -} - -void NewBrowserWindowWidget::ButtonPressed( - views::Button* sender, const views::Event& event) { - UserMetrics::RecordAction("TabOverview_PressedCreateNewBrowserButton", - profile_); - - Browser* browser = Browser::Create(profile_); - browser->AddTabWithURL(GURL(), GURL(), PageTransition::START_PAGE, - true, -1, false, NULL); - browser->window()->Show(); -} diff --git a/chrome/browser/views/new_browser_window_widget.h b/chrome/browser/views/new_browser_window_widget.h deleted file mode 100644 index 5540009..0000000 --- a/chrome/browser/views/new_browser_window_widget.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2009 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_NEW_BROWSER_WINDOW_WIDGET_H_ -#define CHROME_BROWSER_VIEWS_NEW_BROWSER_WINDOW_WIDGET_H_ - -#include "views/controls/button/button.h" - -class Profile; - -namespace views { -class Widget; -} - -// NewBrowserWindowWidget creates a window containing a single button that -// when clicked creates a new Browser. NewBrowserWindowWidget shows the window -// from its constructor, and closes it from the destructor. -class NewBrowserWindowWidget : public views::ButtonListener { - public: - explicit NewBrowserWindowWidget(Profile* profile); - ~NewBrowserWindowWidget(); - - // ButtonListener implementation. - virtual void ButtonPressed(views::Button* sender, const views::Event& event); - - private: - // The profile the browser is created with. - Profile* profile_; - - // The widget containing the button. - views::Widget* widget_; - - DISALLOW_COPY_AND_ASSIGN(NewBrowserWindowWidget); -}; - -#endif // CHROME_BROWSER_VIEWS_NEW_BROWSER_WINDOW_WIDGET_H_ diff --git a/chrome/browser/views/tabs/grid.cc b/chrome/browser/views/tabs/grid.cc deleted file mode 100644 index e6db1e7..0000000 --- a/chrome/browser/views/tabs/grid.cc +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (c) 2009 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. - -#include "chrome/browser/views/tabs/grid.h" - -#include "base/compiler_specific.h" - -using views::View; - -// static -const int Grid::kCellXPadding = 15; -// static -const int Grid::kCellYPadding = 15; - -Grid::Grid() - : ALLOW_THIS_IN_INITIALIZER_LIST(animation_(this)), - modifying_children_(false), - needs_layout_(false), - pref_width_(0), - pref_height_(0), - cell_width_(0), - cell_height_(0), - columns_(0), - rows_(0), - floating_index_(-1) { - animation_.SetTweenType(SlideAnimation::EASE_OUT); -} - -void Grid::MoveCell(int old_index, int new_index) { - View* cell = GetChildViewAt(old_index); - modifying_children_ = true; - RemoveChildView(cell); - AddChildView(new_index, cell); - modifying_children_ = false; - - CalculateTargetBoundsAndStartAnimation(); -} - -void Grid::InsertCell(int index, View* cell) { - modifying_children_ = true; - AddChildView(index, cell); - modifying_children_ = false; - - CalculateTargetBoundsAndStartAnimation(); - - // Set the bounds of the cell to it's target bounds. This way it won't appear - // to animate. - if (index != floating_index_) { - start_bounds_[index] = target_bounds_[index]; - cell->SetBounds(target_bounds_[index]); - } -} - -void Grid::RemoveCell(int index) { - modifying_children_ = true; - RemoveChildView(GetChildViewAt(index)); - modifying_children_ = false; - - CalculateTargetBoundsAndStartAnimation(); -} - -void Grid::AnimateToTargetBounds() { - CalculateTargetBoundsAndStartAnimation(); -} - -void Grid::ViewHierarchyChanged(bool is_add, View* parent, View* child) { - if (modifying_children_ || parent != this) - return; - - // Our child views changed without us knowing it. Stop the animation and mark - // us as dirty (needs_layout_ = true). - animation_.Stop(); - needs_layout_ = true; -} - -gfx::Rect Grid::CellBounds(int index) { - int row = index / columns_; - int col = index % columns_; - return gfx::Rect(col * cell_width_ + std::max(0, col * kCellXPadding), - row * cell_height_ + std::max(0, row * kCellYPadding), - cell_width_, cell_height_); -} - -gfx::Size Grid::GetPreferredSize() { - if (needs_layout_) - Layout(); - - return gfx::Size(pref_width_, pref_height_); -} - -void Grid::Layout() { - if (!needs_layout_) - return; - - needs_layout_ = false; - animation_.Stop(); - target_bounds_.clear(); - CalculateCellBounds(&target_bounds_); - for (size_t i = 0; i < target_bounds_.size(); ++i) { - if (static_cast<int>(i) != floating_index_) - GetChildViewAt(i)->SetBounds(target_bounds_[i]); - } -} - -void Grid::PaintChildren(gfx::Canvas* canvas) { - int i, c; - for (i = 0, c = GetChildViewCount(); i < c; ++i) { - if (i != floating_index_) { - View* child = GetChildViewAt(i); - if (!child) { - NOTREACHED(); - continue; - } - child->ProcessPaint(canvas); - } - } - - // Paint the floating view last. This way it floats on top of all other - // views. - if (floating_index_ != -1 && floating_index_ < GetChildViewCount()) - GetChildViewAt(floating_index_)->ProcessPaint(canvas); -} - -void Grid::AnimationEnded(const Animation* animation) { - SetViewBoundsToTarget(); -} - -void Grid::AnimationProgressed(const Animation* animation) { - DCHECK(GetChildViewCount() == static_cast<int>(target_bounds_.size())); - for (size_t i = 0; i < target_bounds_.size(); ++i) { - View* view = GetChildViewAt(i); - gfx::Rect start_bounds = start_bounds_[i]; - gfx::Rect target_bounds = target_bounds_[i]; - if (static_cast<int>(i) != floating_index_) { - view->SetBounds( - animation_.CurrentValueBetween(start_bounds, target_bounds)); - } - } - SchedulePaint(); -} - -void Grid::AnimationCanceled(const Animation* animation) { - // Don't do anything when the animation is canceled. Presumably Layout will - // be invoked, and all children will get set to their appropriate position. -} - -void Grid::CalculateCellBounds(std::vector<gfx::Rect>* bounds) { - DCHECK(max_size_.width() > 0 && max_size_.height() > 0); - int cell_count = GetChildViewCount(); - if (cell_count == 0) { - pref_width_ = pref_height_ = 0; - return; - } - - gfx::Size cell_pref = GetChildViewAt(0)->GetPreferredSize(); - int col_count, row_count; - // Assume we get the ideal cell size. - int cell_width = cell_pref.width(); - int cell_height = cell_pref.height(); - int max_columns = std::max(1, (max_size_.width() + kCellXPadding) / - (cell_width + kCellXPadding)); - if (cell_count <= max_columns) { - // All the cells fit in a single row. - row_count = 1; - col_count = cell_count; - } else { - // Need more than one row to display all. - int max_rows = std::max(1, (max_size_.height() + kCellYPadding) / - (cell_height + kCellYPadding)); - col_count = max_columns; - row_count = cell_count / max_columns; - if (cell_count % col_count != 0) - row_count++; - if (cell_count > max_columns * max_rows) { - // We don't have enough space for the cells at their ideal size. Keep - // adding columns (and shrinking down cell sizes) until we fit - // everything. - float ratio = static_cast<float>(cell_width) / - static_cast<float>(cell_height); - do { - col_count++; - cell_width = - static_cast<float>(max_size_.width() - - ((col_count - 1) * kCellXPadding)) / - static_cast<float>(col_count); - cell_height = static_cast<float>(cell_width) / ratio; - row_count = std::max(1, (max_size_.height() + kCellYPadding) / - (cell_height + kCellYPadding)); - } while (row_count * col_count < cell_count); - row_count = cell_count / col_count; - if (cell_count % col_count != 0) - row_count++; - } - } - - cell_width_ = cell_width; - cell_height_ = cell_height; - columns_ = col_count; - rows_ = row_count; - - pref_width_ = - std::max(0, col_count * (cell_width + kCellXPadding) - kCellXPadding); - pref_height_ = - std::max(0, row_count * (cell_height + kCellYPadding) - kCellYPadding); - - for (int i = 0; i < cell_count; ++i) - bounds->push_back(CellBounds(i)); -} - -void Grid::CalculateTargetBoundsAndStartAnimation() { - if (needs_layout_) - Layout(); - - // Determine the current bounds. - start_bounds_.clear(); - start_bounds_.resize(GetChildViewCount()); - for (int i = 0; i < GetChildViewCount(); ++i) - start_bounds_[i] = GetChildViewAt(i)->bounds(); - - // Then the target bounds. - target_bounds_.clear(); - CalculateCellBounds(&target_bounds_); - - // And restart the animation. - animation_.Reset(); - animation_.Show(); -} - -void Grid::SetViewBoundsToTarget() { - DCHECK(GetChildViewCount() == static_cast<int>(target_bounds_.size())); - for (size_t i = 0; i < target_bounds_.size(); ++i) { - if (static_cast<int>(i) != floating_index_) - GetChildViewAt(i)->SetBounds(target_bounds_[i]); - } -} diff --git a/chrome/browser/views/tabs/grid.h b/chrome/browser/views/tabs/grid.h deleted file mode 100644 index c046737..0000000 --- a/chrome/browser/views/tabs/grid.h +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) 2009 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_TABS_GRID_H_ -#define CHROME_BROWSER_VIEWS_TABS_GRID_H_ - -#include <vector> - -#include "app/slide_animation.h" -#include "base/gfx/rect.h" -#include "views/view.h" - -// Grid is a view that positions its children (cells) in a grid. Grid -// attempts to layout the children at their preferred size (assuming -// all cells have the same preferred size) in a single row. If the sum -// of the widths is greater than the max width, then a new row is -// added. Once the max number of rows and columns are reached, the -// cells are shrunk to fit. -// -// Grid offers methods to move, insert and remove cells. These end up changing -// the child views, and animating the transition. -class Grid : public views::View, public AnimationDelegate { - public: - Grid(); - - // Sets the max size for the Grid. See description above class for details. - void set_max_size(const gfx::Size& size) { max_size_ = size; } - const gfx::Size& max_size() const { return max_size_; } - - // Moves the child view to the specified index, animating the move. - void MoveCell(int old_index, int new_index); - - // Inserts a cell at the specified index, animating the insertion. - void InsertCell(int index, views::View* cell); - - // Removes the cell at the specified index, animating the removal. - // WARNING: this does NOT delete the view, it's up to the caller to do that. - void RemoveCell(int index); - - // Calculates the target bounds of each cell and starts the animation timer - // (assuming it isn't already running). This is invoked for you, but may - // be invoked to retrigger animation, perhaps after changing the floating - // index. - void AnimateToTargetBounds(); - - // Sets the index of the floating cell. The floating cells bounds are NOT - // updated along with the rest of the cells, and the floating cell is painted - // after all other cells. This is typically used during drag and drop when - // the user is dragging a cell around. - void set_floating_index(int index) { floating_index_ = index; } - - // Returns the number of columns. - int columns() const { return columns_; } - - // Returns the number of rows. - int rows() const { return rows_; } - - // Returns the width of a cell. - int cell_width() const { return cell_width_; } - - // Returns the height of a cell. - int cell_height() const { return cell_height_; } - - // Returns the bounds of the specified cell. - gfx::Rect CellBounds(int index); - - // Returns the animation. - const SlideAnimation& animation() { return animation_; } - - // View overrides. - virtual void ViewHierarchyChanged(bool is_add, - views::View* parent, - views::View* child); - virtual gfx::Size GetPreferredSize(); - virtual void Layout(); - void PaintChildren(gfx::Canvas* canvas); - - // AnimationDelegate overrides. - virtual void AnimationEnded(const Animation* animation); - virtual void AnimationProgressed(const Animation* animation); - virtual void AnimationCanceled(const Animation* animation); - - // Padding between cells. - static const int kCellXPadding; - static const int kCellYPadding; - - private: - // Calculates the bounds of each of the cells, adding the result to |bounds|. - void CalculateCellBounds(std::vector<gfx::Rect>* bounds); - - // Resets start_bounds_ to the bounds of the current cells, and invokes - // CalculateCellBounds to determine the target bounds. Then starts the - // animation if it isn't already running. - void CalculateTargetBoundsAndStartAnimation(); - - // Resets the bounds of each cell to that of target_bounds_. - void SetViewBoundsToTarget(); - - // The animation. - SlideAnimation animation_; - - // If true, we're adding/removing a child and can ignore the change in - // ViewHierarchyChanged. - bool modifying_children_; - - // Do we need a layout? This is set to true any time a child is added/removed. - bool needs_layout_; - - // Max size we layout to. - gfx::Size max_size_; - - // Preferred size. - int pref_width_; - int pref_height_; - - // Current cell size. - int cell_width_; - int cell_height_; - - // Number of rows/columns. - int columns_; - int rows_; - - // See description above setter. - int floating_index_; - - // Used during animation, gives the initial bounds of the views. - std::vector<gfx::Rect> start_bounds_; - - // Used during animation, gives the target bounds of the views. - std::vector<gfx::Rect> target_bounds_; - - DISALLOW_COPY_AND_ASSIGN(Grid); -}; - -#endif // CHROME_BROWSER_VIEWS_TABS_GRID_H_ diff --git a/chrome/browser/views/tabs/tab_overview_cell.cc b/chrome/browser/views/tabs/tab_overview_cell.cc deleted file mode 100644 index 4bebd42..0000000 --- a/chrome/browser/views/tabs/tab_overview_cell.cc +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) 2009 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. - -#include "chrome/browser/views/tabs/tab_overview_cell.h" - -#include "app/gfx/favicon_size.h" -#include "app/gfx/skbitmap_operations.h" -#include "base/string_util.h" -#include "views/border.h" -#include "views/controls/image_view.h" -#include "views/controls/label.h" -#include "views/grid_layout.h" - -using views::ColumnSet; -using views::GridLayout; - -// Padding between the favicon and label. -static const int kFavIconPadding = 4; - -// Height of the thumbnail. -static const int kThumbnailHeight = 140; -static const int kThumbnailWidth = 220; - -// Padding between favicon/title and thumbnail. -static const int kVerticalPadding = 10; - -TabOverviewCell::TabOverviewCell() : configured_thumbnail_(false) { - title_label_ = new views::Label(); - title_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); - - thumbnail_view_ = new views::ImageView(); - thumbnail_view_->SetImageSize(gfx::Size(kThumbnailWidth, kThumbnailHeight)); - - fav_icon_view_ = new views::ImageView(); - fav_icon_view_->SetImageSize(gfx::Size(kFavIconSize, kFavIconSize)); - - int title_cs_id = 0; - int thumbnail_cs_id = 1; - GridLayout* layout = new GridLayout(this); - SetLayoutManager(layout); - ColumnSet* columns = layout->AddColumnSet(title_cs_id); - columns->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, - GridLayout::USE_PREF, 0, 0); - columns->AddPaddingColumn(0, kFavIconPadding); - columns->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, - GridLayout::USE_PREF, 0, 0); - - columns = layout->AddColumnSet(thumbnail_cs_id); - columns->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, - GridLayout::USE_PREF, 0, 0); - - layout->StartRow(0, title_cs_id); - layout->AddView(fav_icon_view_); - layout->AddView(title_label_); - - layout->StartRowWithPadding(1, thumbnail_cs_id, 0, kVerticalPadding); - layout->AddView(thumbnail_view_); - - thumbnail_view_->set_background( - views::Background::CreateSolidBackground(SK_ColorWHITE)); - - thumbnail_view_->set_border( - views::Border::CreateSolidBorder(1, SkColorSetRGB(176, 176, 176))); -} - -void TabOverviewCell::SetThumbnail(const SkBitmap& thumbnail) { - // Do mipmapped-based resampling to get closer to the correct size. The - // input bitmap isn't guaranteed to have any specific resolution. - thumbnail_view_->SetImage(SkBitmapOperations::DownsampleByTwoUntilSize( - thumbnail, kThumbnailWidth, kThumbnailHeight)); - configured_thumbnail_ = true; -} - -void TabOverviewCell::SetTitle(const string16& title) { - title_label_->SetText(UTF16ToWide(title)); -} - -void TabOverviewCell::SetFavIcon(const SkBitmap& favicon) { - fav_icon_view_->SetImage(favicon); -} - -bool TabOverviewCell::IsPointInThumbnail(const gfx::Point& point) { - return thumbnail_view_->bounds().Contains(point); -} - -gfx::Size TabOverviewCell::GetPreferredSize() { - if (!preferred_size_.IsEmpty()) - return preferred_size_; - - // Force the preferred width to that of the thumbnail. - gfx::Size thumbnail_pref = thumbnail_view_->GetPreferredSize(); - gfx::Size pref = View::GetPreferredSize(); - pref.set_width(thumbnail_pref.width()); - return pref; -} diff --git a/chrome/browser/views/tabs/tab_overview_cell.h b/chrome/browser/views/tabs/tab_overview_cell.h deleted file mode 100644 index 08c0055..0000000 --- a/chrome/browser/views/tabs/tab_overview_cell.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2009 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_TABS_TAB_OVERVIEW_CELL_H_ -#define CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_CELL_H_ - -#include "base/string16.h" -#include "third_party/skia/include/core/SkBitmap.h" -#include "views/view.h" - -namespace views { -class ImageView; -class Label; -} - -// A single cell displayed by TabOverviewGrid. TabOverviewCell contains a -// label, favicon and thumnbail. -class TabOverviewCell : public views::View { - public: - TabOverviewCell(); - - void SetThumbnail(const SkBitmap& thumbnail); - void SetTitle(const string16& title); - void SetFavIcon(const SkBitmap& favicon); - - // Sets the preferred size. Normally the preferred size is calculate from - // the content, but this can be used to fix it at a particular value. Use an - // empty size to get the default preferred size. - void set_preferred_size(const gfx::Size& preferred_size) { - preferred_size_ = preferred_size; - } - - // Returns true if the specified point, in the bounds of the cell, is over - // the thumbnail. - bool IsPointInThumbnail(const gfx::Point& point); - - // Has the thumbnail been configured? This is true after SetThumbnail - // is invoked. - bool configured_thumbnail() const { return configured_thumbnail_; } - - // View overrides. - virtual gfx::Size GetPreferredSize(); - - private: - views::Label* title_label_; - views::ImageView* thumbnail_view_; - views::ImageView* fav_icon_view_; - - // Specific preferred size. See set_preferred_size() for details. - gfx::Size preferred_size_; - - bool configured_thumbnail_; - - DISALLOW_COPY_AND_ASSIGN(TabOverviewCell); -}; - -#endif // CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_CELL_H_ diff --git a/chrome/browser/views/tabs/tab_overview_container.cc b/chrome/browser/views/tabs/tab_overview_container.cc deleted file mode 100644 index 6843b1e..0000000 --- a/chrome/browser/views/tabs/tab_overview_container.cc +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) 2009 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. - -#include "chrome/browser/views/tabs/tab_overview_container.h" - -#include "app/gfx/canvas.h" -#include "chrome/browser/views/tabs/tab_overview_grid.h" -#include "third_party/skia/include/core/SkPath.h" -#include "third_party/skia/include/effects/SkGradientShader.h" - -// Padding between the edges of us and the grid. -static const int kVerticalPadding = 43; -static const int kHorizontalPadding = 30; - -// Height of the arrow. -static const int kArrowHeight = 28; - -// Radius of the corners of the rectangle. -static const int kEdgeSize = 8; - -TabOverviewContainer::TabOverviewContainer() : arrow_center_(0) { -} - -TabOverviewContainer::~TabOverviewContainer() { -} - -void TabOverviewContainer::SetMaxSize(const gfx::Size& max_size) { - GetTabOverviewGrid()->set_max_size( - gfx::Size(max_size.width() - kHorizontalPadding * 2, - max_size.height() - kVerticalPadding * 2 - kArrowHeight)); -} - -gfx::Size TabOverviewContainer::GetPreferredSize() { - gfx::Size tab_overview_pref = GetTabOverviewGrid()->GetPreferredSize(); - return gfx::Size(kHorizontalPadding * 2 + tab_overview_pref.width(), - kVerticalPadding * 2 + tab_overview_pref.height() + - kArrowHeight); -} - -void TabOverviewContainer::Layout() { - GetTabOverviewGrid()->SetBounds(kHorizontalPadding, kVerticalPadding, - width() - kHorizontalPadding * 2, - height() - kVerticalPadding * 2 - - kArrowHeight); -} - -void TabOverviewContainer::Paint(gfx::Canvas* canvas) { - // Create a path with a rounded rect and arrow pointing down. - SkPath outline; - int right = width() - 1; - int bottom = height() - 1 - kArrowHeight; - outline.moveTo(SkIntToScalar(kEdgeSize), SkIntToScalar(0)); - outline.arcTo(SkIntToScalar(right), SkIntToScalar(0), - SkIntToScalar(right), SkIntToScalar(bottom), - SkIntToScalar(kEdgeSize)); - outline.arcTo(SkIntToScalar(right), SkIntToScalar(bottom), - SkIntToScalar(0), SkIntToScalar(bottom), - SkIntToScalar(kEdgeSize)); - // Convert arrow_center to our coordinates. - int arrow_center = arrow_center_ - bounds().x(); - if (arrow_center >= kArrowHeight && arrow_center < width() - kArrowHeight) { - // Only draw the arrow if we have enough space. - outline.lineTo(SkIntToScalar(arrow_center + kArrowHeight / 2), - SkIntToScalar(bottom)); - outline.lineTo(SkIntToScalar(arrow_center), - SkIntToScalar(bottom + kArrowHeight)); - outline.lineTo(SkIntToScalar(arrow_center - kArrowHeight / 2), - SkIntToScalar(bottom)); - } - outline.arcTo(SkIntToScalar(0), SkIntToScalar(bottom), - SkIntToScalar(0), SkIntToScalar(0), - SkIntToScalar(kEdgeSize)); - outline.arcTo(SkIntToScalar(0), SkIntToScalar(0), - SkIntToScalar(right), SkIntToScalar(0), - SkIntToScalar(kEdgeSize)); - - canvas->save(); - // Clip out the outline. - canvas->clipPath(outline); - - // Fill the interior with a gradient. - SkPoint points[] = { { SkIntToScalar(0), SkIntToScalar(0) }, - { SkIntToScalar(0), SkIntToScalar(height()) } }; - SkColor colors[] = { SkColorSetARGB(242, 255, 255, 255), - SkColorSetARGB(212, 255, 255, 255), }; - SkShader* shader = SkGradientShader::CreateLinear( - points, colors, NULL, 2, SkShader::kRepeat_TileMode); - SkPaint paint; - paint.setShader(shader); - shader = NULL; - paint.setStyle(SkPaint::kFill_Style); - paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); - canvas->drawPaint(paint); - - // Restore the canvas (resetting the clip). - canvas->restore(); - - SkPaint paint2; - paint2.setStyle(SkPaint::kStroke_Style); - paint2.setAntiAlias(true); - paint2.setColor(SK_ColorWHITE); - paint2.setStrokeWidth(SkIntToScalar(0)); - - // And stroke the rounded rect with arrow pointing down. - canvas->drawPath(outline, paint2); -} - -TabOverviewGrid* TabOverviewContainer::GetTabOverviewGrid() { - return static_cast<TabOverviewGrid*>(GetChildViewAt(0)); -} diff --git a/chrome/browser/views/tabs/tab_overview_container.h b/chrome/browser/views/tabs/tab_overview_container.h deleted file mode 100644 index fdc63e0..0000000 --- a/chrome/browser/views/tabs/tab_overview_container.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2009 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_TABS_TAB_OVERVIEW_CONTAINER_H_ -#define CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_CONTAINER_H_ - -#include "views/view.h" - -class TabOverviewGrid; - -// TabOverviewContainer contains TabOverviewGrid. TabOverviewContainer provides -// padding around the grid. -class TabOverviewContainer : public views::View { - public: - TabOverviewContainer(); - virtual ~TabOverviewContainer(); - - // Sets the max size. This ends up being passed down to the grid after - // adjusting for our borders. - void SetMaxSize(const gfx::Size& max_size); - - // View overrides. - virtual gfx::Size GetPreferredSize(); - virtual void Layout(); - virtual void Paint(gfx::Canvas* canvas); - - // Sets the location of the arrow, along the x-axis. - // - // WARNING: this is the coordinate system of the parent, NOT this view. - void set_arrow_center(int x) { arrow_center_ = x; } - - private: - TabOverviewGrid* GetTabOverviewGrid(); - - // See set_arrow_center for details. - int arrow_center_; - - DISALLOW_COPY_AND_ASSIGN(TabOverviewContainer); -}; - -#endif // CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_CONTAINER_H_ diff --git a/chrome/browser/views/tabs/tab_overview_controller.cc b/chrome/browser/views/tabs/tab_overview_controller.cc deleted file mode 100644 index f9c4d1f2..0000000 --- a/chrome/browser/views/tabs/tab_overview_controller.cc +++ /dev/null @@ -1,365 +0,0 @@ -// Copyright (c) 2009 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. - -#include "chrome/browser/views/tabs/tab_overview_controller.h" - -#include "chrome/browser/browser.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/renderer_host/render_view_host.h" -#include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/browser/tab_contents/thumbnail_generator.h" -#include "chrome/browser/views/frame/browser_extender.h" -#include "chrome/browser/views/frame/browser_view.h" -#include "chrome/browser/views/tabs/tab_overview_cell.h" -#include "chrome/browser/views/tabs/tab_overview_container.h" -#include "chrome/browser/views/tabs/tab_overview_drag_controller.h" -#include "chrome/browser/views/tabs/tab_overview_grid.h" -#include "chrome/browser/views/tabs/tab_overview_types.h" -#include "chrome/browser/window_sizer.h" -#include "chrome/common/x11_util.h" -#include "views/widget/root_view.h" -#include "views/widget/widget_gtk.h" -#include "views/window/window.h" - -// Horizontal padding from the edge of the monitor to the overview. -static int kMonitorPadding = 20; -// Vertical padding between the overview and the windows along on the bottom. -static int kWindowToOverviewPadding = 25; -// Height of the windows along the bottom, as a percentage of the monitors -// height. -static float kWindowHeight = .30; -// Height of the tab overview, as a percentage of monitors height. -static float kOverviewHeight = .55; - -TabOverviewController::TabOverviewController( - const gfx::Point& monitor_origin) - : host_(NULL), - container_(NULL), - grid_(NULL), - browser_(NULL), - drag_browser_(NULL), - moved_offscreen_(false), - shown_(false), - horizontal_center_(0), - change_window_bounds_on_animate_(false), - mutating_grid_(false), - show_thumbnails_(false) { - grid_ = new TabOverviewGrid(this); - - // Determine the max size for the overview. - scoped_ptr<WindowSizer::MonitorInfoProvider> provider( - WindowSizer::CreateDefaultMonitorInfoProvider()); - monitor_bounds_ = provider->GetMonitorWorkAreaMatching( - gfx::Rect(monitor_origin.x(), monitor_origin.y(), 1, 1)); - - // Create the host. - views::WidgetGtk* host = new views::WidgetGtk(views::WidgetGtk::TYPE_POPUP); - host->set_delete_on_destroy(false); - host->MakeTransparent(); - host->Init(NULL, CalculateHostBounds()); - TabOverviewTypes::instance()->SetWindowType( - host->GetNativeView(), - TabOverviewTypes::WINDOW_TYPE_CHROME_TAB_SUMMARY, - NULL); - host_ = host; - - container_ = new TabOverviewContainer(); - container_->AddChildView(grid_); - host->GetRootView()->AddChildView(container_); - - container_->SetMaxSize(CalculateHostBounds().size()); - - horizontal_center_ = monitor_bounds_.x() + monitor_bounds_.width() / 2; -} - -TabOverviewController::~TabOverviewController() { - if (browser_) - model()->RemoveObserver(this); - host_->Close(); - // The drag controller may call back to us from it's destructor. Make sure - // it's destroyed before us. - grid()->CancelDrag(); -} - -void TabOverviewController::SetBrowser(Browser* browser, - int horizontal_center) { - horizontal_center_ = horizontal_center; - if (browser_) - model()->RemoveObserver(this); - browser_ = browser; - if (browser_) - model()->AddObserver(this); - - show_thumbnails_ = false; - StartDelayTimer(); - - gfx::Rect host_bounds = CalculateHostBounds(); - if (moved_offscreen_ && model() && model()->count()) { - // Need to reset the bounds if we were offscreen. - host_->SetBounds(host_bounds); - moved_offscreen_ = false; - } else if (!model() && shown_) { - MoveOffscreen(); - } - if (!moved_offscreen_) - container_->SchedulePaint(); - - RecreateCells(); - - container_->set_arrow_center(horizontal_center_ - host_bounds.x()); - - if (!moved_offscreen_) - container_->SchedulePaint(); -} - -TabStripModel* TabOverviewController::model() const { - return browser_ ? browser_->tabstrip_model() : NULL; -} - -void TabOverviewController::SetMouseOverMiniWindow(bool over_mini_window) { - if (grid_->drag_controller()) - grid_->drag_controller()->set_mouse_over_mini_window(over_mini_window); -} - -void TabOverviewController::Show() { - if (host_->IsVisible()) - return; - - shown_ = true; - DCHECK(model()); // The model needs to be set before showing. - host_->Show(); - - show_thumbnails_ = false; - StartDelayTimer(); -} - -void TabOverviewController::ConfigureCell(TabOverviewCell* cell, - TabContents* contents) { - if (contents) { - cell->SetTitle(contents->GetTitle()); - cell->SetFavIcon(contents->GetFavIcon()); - - if (show_thumbnails_) { - ThumbnailGenerator* generator = - g_browser_process->GetThumbnailGenerator(); - cell->SetThumbnail( - generator->GetThumbnailForRenderer(contents->render_view_host())); - } - cell->SchedulePaint(); - } else { - // Need to figure out under what circumstances this is null and deal. - NOTIMPLEMENTED(); - - // Make sure we set the thumbnail, otherwise configured_thumbnail - // remains false and ConfigureNextUnconfiguredCell would get stuck. - if (show_thumbnails_) - cell->SetThumbnail(SkBitmap()); - } -} - -void TabOverviewController::DragStarted() { - DCHECK(!drag_browser_); - drag_browser_ = browser_; - static_cast<BrowserView*>(drag_browser_->window())-> - browser_extender()->set_can_close(false); -} - -void TabOverviewController::DragEnded() { - static_cast<BrowserView*>(drag_browser_->window())-> - browser_extender()->set_can_close(true); - if (drag_browser_->tabstrip_model()->count() == 0) - drag_browser_->tabstrip_model()->delegate()->CloseFrameAfterDragSession(); - drag_browser_ = NULL; -} - -void TabOverviewController::MoveOffscreen() { - gfx::Rect bounds; - moved_offscreen_ = true; - host_->GetBounds(&bounds, true); - host_->SetBounds(gfx::Rect(-10000, -10000, bounds.width(), bounds.height())); -} - -void TabOverviewController::SelectTab(int index) { - browser_->SelectTabContentsAt(index, true); -} - -void TabOverviewController::FocusBrowser() { - static_cast<BrowserView*>(browser_->window())->GetWindow()->Activate(); -} - -void TabOverviewController::GridAnimationEnded() { - if (moved_offscreen_ || !change_window_bounds_on_animate_ || mutating_grid_) - return; - - container_->SetBounds(target_bounds_); - grid_->UpdateDragController(); - change_window_bounds_on_animate_ = false; -} - -void TabOverviewController::GridAnimationProgressed() { - if (moved_offscreen_ || !change_window_bounds_on_animate_) - return; - - DCHECK(!mutating_grid_); - - // Schedule a paint before and after changing sizes to deal with the case - // of the view shrinking in size. - container_->SchedulePaint(); - container_->SetBounds( - grid_->animation().CurrentValueBetween(start_bounds_, target_bounds_)); - container_->SchedulePaint(); - - // Update the position of the dragged cell. - grid_->UpdateDragController(); -} - -void TabOverviewController::GridAnimationCanceled() { - change_window_bounds_on_animate_ = false; -} - -void TabOverviewController::TabInsertedAt(TabContents* contents, - int index, - bool foreground) { - if (!grid_->modifying_model()) - grid_->CancelDrag(); - - TabOverviewCell* child = new TabOverviewCell(); - ConfigureCell(child, index); - mutating_grid_ = true; - grid_->InsertCell(index, child); - mutating_grid_ = false; - - UpdateStartAndTargetBounds(); -} - -void TabOverviewController::TabClosingAt(TabContents* contents, int index) { - // Nothing to do, we only care when the tab is actually detached. -} - -void TabOverviewController::TabDetachedAt(TabContents* contents, int index) { - if (!grid_->modifying_model()) - grid_->CancelDrag(); - - scoped_ptr<TabOverviewCell> child(grid_->GetTabOverviewCellAt(index)); - mutating_grid_ = true; - grid_->RemoveCell(index); - mutating_grid_ = false; - - UpdateStartAndTargetBounds(); -} - -void TabOverviewController::TabMoved(TabContents* contents, - int from_index, - int to_index) { - if (!grid_->modifying_model()) - grid_->CancelDrag(); - - mutating_grid_ = true; - grid_->MoveCell(from_index, to_index); - mutating_grid_ = false; - - UpdateStartAndTargetBounds(); -} - -void TabOverviewController::TabChangedAt(TabContents* contents, int index, - TabChangeType change_type) { - ConfigureCell(grid_->GetTabOverviewCellAt(index), index); -} - -void TabOverviewController::TabStripEmpty() { - if (!grid_->modifying_model()) { - grid_->CancelDrag(); - // The tab strip is empty, hide the grid. - host_->Hide(); - } -} - -void TabOverviewController::ConfigureCell(TabOverviewCell* cell, int index) { - ConfigureCell(cell, model()->GetTabContentsAt(index)); -} - -void TabOverviewController::RecreateCells() { - grid_->RemoveAllChildViews(true); - - if (model()) { - for (int i = 0; i < model()->count(); ++i) { - TabOverviewCell* child = new TabOverviewCell(); - ConfigureCell(child, i); - grid_->AddChildView(child); - } - } - - if (moved_offscreen_) - return; - - if (grid()->GetChildViewCount() > 0) { - if (shown_) - host_->Show(); - } else { - host_->Hide(); - } - container_->SetBounds(CalculateContainerBounds()); -} - -void TabOverviewController::UpdateStartAndTargetBounds() { - if (moved_offscreen_ || !shown_) - return; - - if (grid()->GetChildViewCount() == 0) { - host_->Hide(); - } else { - start_bounds_ = container_->bounds(); - target_bounds_ = CalculateContainerBounds(); - change_window_bounds_on_animate_ = (start_bounds_ != target_bounds_); - } -} - -gfx::Rect TabOverviewController::CalculateContainerBounds() { - gfx::Rect host_bounds = CalculateHostBounds(); - const gfx::Size& host_size = CalculateHostBounds().size(); - gfx::Size pref = container_->GetPreferredSize(); - int relative_horizontal_center = horizontal_center_ - host_bounds.x(); - int x = relative_horizontal_center - pref.width() / 2; - int y = host_size.height() - pref.height(); - return gfx::Rect(x, y, pref.width(), pref.height()). - AdjustToFit(gfx::Rect(0, 0, host_size.width(), host_size.height())); -} - -gfx::Rect TabOverviewController::CalculateHostBounds() { - int max_width = monitor_bounds_.width() - kMonitorPadding * 2; - int window_height = monitor_bounds_.height() * kWindowHeight; - int max_height = static_cast<int>(monitor_bounds_.height() * - kOverviewHeight); - return gfx::Rect(monitor_bounds_.x() + kMonitorPadding, - monitor_bounds_.bottom() - window_height - - kWindowToOverviewPadding - max_height, max_width, - max_height); -} - -void TabOverviewController::StartConfiguring() { - show_thumbnails_ = true; - configure_timer_.Stop(); - configure_timer_.Start( - base::TimeDelta::FromMilliseconds(10), this, - &TabOverviewController::ConfigureNextUnconfiguredCell); -} - -void TabOverviewController::ConfigureNextUnconfiguredCell() { - for (int i = 0; i < grid_->GetChildViewCount(); ++i) { - TabOverviewCell* cell = grid_->GetTabOverviewCellAt(i); - if (!cell->configured_thumbnail()) { - ConfigureCell(cell, i); - return; - } - } - configure_timer_.Stop(); -} - -void TabOverviewController::StartDelayTimer() { - configure_timer_.Stop(); - delay_timer_.Stop(); - delay_timer_.Start( - base::TimeDelta::FromMilliseconds(350), this, - &TabOverviewController::StartConfiguring); -} diff --git a/chrome/browser/views/tabs/tab_overview_controller.h b/chrome/browser/views/tabs/tab_overview_controller.h deleted file mode 100644 index 3110f7d..0000000 --- a/chrome/browser/views/tabs/tab_overview_controller.h +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright (c) 2009 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_TABS_TAB_OVERVIEW_CONTROLLER_H_ -#define CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_CONTROLLER_H_ - -#include "base/gfx/rect.h" -#include "base/scoped_ptr.h" -#include "base/timer.h" -#include "chrome/browser/tabs/tab_strip_model.h" - -class Animation; -class Browser; -class TabOverviewCell; -class TabOverviewContainer; -class TabOverviewGrid; - -namespace views { -class Widget; -} - -// TabOverviewController is responsible for showing a TabOverviewGrid and -// keeping it in sync with the TabStripModel of a browser. -// -// As tabs are added/removed from the TabStripModel the size and position -// of the container animates. Ideally this would be done by changing the -// bounds of the host window, but that proved janktastic. Instead the -// size of the host window is created at the largest possible size the -// window can be and the bounds of the container are changed during the -// animation. -// -// As obtaining and setting thumbnails is expensive we delay setting the -// thumbnail. The delay is controlled by delay_timer_. Once the timer fires -// another timer is started (configure_timer_). This timer invokes -// ConfigureNextUnconfiguredCell, which obtains and sets the thumbnail of -// the next uncofigured cell. ConfigureNextUnconfiguredCell only configures -// one cell at a time. -class TabOverviewController : public TabStripModelObserver { - public: - // Creates a TabOverviewController that will be shown on the monitor - // containing |monitor_origin|. - explicit TabOverviewController(const gfx::Point& monitor_origin); - ~TabOverviewController(); - - // Sets the browser we're showing the tab strip for. |horizontal_center| - // gives the center of the window. - void SetBrowser(Browser* browser, int horizontal_center); - Browser* browser() const { return browser_; } - TabOverviewGrid* grid() const { return grid_; } - TabStripModel* model() const; - - // Returns true if the grid has been moved off screen. The grid is moved - // offscren if the user detaches the last tab in the tab strip. - bool moved_offscreen() const { return moved_offscreen_; } - - // Sets whether the mouse is over a mini-window. - void SetMouseOverMiniWindow(bool over_mini_window); - - // Shows the grid. - void Show(); - - // Configures a cell from the model. - void ConfigureCell(TabOverviewCell* cell, TabContents* contents); - - // Invoked from TabOverviewDragController. - void DragStarted(); - void DragEnded(); - void MoveOffscreen(); - - // Selects the TabContents at |index|. This is invoked from the - // TabOverviewDragController when the user mouses down on a cell. - void SelectTab(int index); - - // Focuses the current browser. This is invoked from the - // TabOverviewDragController if the user releases the mouse over a cell - // without dragging. - void FocusBrowser(); - - // Forwarded from TabOverviewGrid as the animation of the grid changes. - void GridAnimationEnded(); - void GridAnimationProgressed(); - void GridAnimationCanceled(); - - // TabStripModelObserver overrides. - virtual void TabInsertedAt(TabContents* contents, - int index, - bool foreground); - virtual void TabClosingAt(TabContents* contents, int index); - virtual void TabDetachedAt(TabContents* contents, int index); - virtual void TabMoved(TabContents* contents, - int from_index, - int to_index); - virtual void TabChangedAt(TabContents* contents, int index, - TabChangeType change_type); - virtual void TabStripEmpty(); - // Currently don't care about these as we're not rendering the selection. - virtual void TabDeselectedAt(TabContents* contents, int index) { } - virtual void TabSelectedAt(TabContents* old_contents, - TabContents* new_contents, - int index, - bool user_gesture) { } - - private: - // Configures a cell from the model. - void ConfigureCell(TabOverviewCell* cell, int index); - - // Removes all the cells in the grid and populates it from the model. - void RecreateCells(); - - // Updates the target and start bounds. - void UpdateStartAndTargetBounds(); - - // Returns the bounds for the tab overview container based on the preferred - // size of the container. The returned value is the coordinates of the - // root view (container's parent). - // See comment above class description for more details. - gfx::Rect CalculateContainerBounds(); - - // Returns the bounds needed for the host. - // See comment above class description for more details. - gfx::Rect CalculateHostBounds(); - - // Invoked by delay_timer_. Sets show_thumbnails_ to true and starts - // configure_timer_. - void StartConfiguring(); - - // Finds the first cell with no thumbnail and invokes ConfigureCell for - // it. If all the thumnbails have been set configure_timer_ is stopped. - void ConfigureNextUnconfiguredCell(); - - // Starts the delay timer. - void StartDelayTimer(); - - // The widget showing the view. - views::Widget* host_; - - // Bounds of the monitor we're being displayed on. This is used to position - // the widget. - gfx::Rect monitor_bounds_; - - // View containing the grid, owned by host. - TabOverviewContainer* container_; - - // The view. This is owned by host. - TabOverviewGrid* grid_; - - // The browser, not owned by us. - Browser* browser_; - - // The browser a drag was started on. - Browser* drag_browser_; - - // True if the host has been moved offscreen. - bool moved_offscreen_; - - // Has Show been invoked? - bool shown_; - - // Position of the center of the window along the horizontal axis. This is - // used to position the overview window. - int horizontal_center_; - - // Should we change the window bounds on animate? This is true while the - // animation is running on the grid to move things around. - bool change_window_bounds_on_animate_; - - // When the model changes we animate the bounds of the window. These two - // give the start and target bounds of the window. - gfx::Rect start_bounds_; - gfx::Rect target_bounds_; - - // Are we in the process of mutating the grid? This is used to avoid changing - // bounds when we're responsible for the mutation. - bool mutating_grid_; - - // Should we set the thumbnails? This is initially false, then set to true - // by StartConfiguring. - bool show_thumbnails_; - - // See description above class for details. - base::OneShotTimer<TabOverviewController> delay_timer_; - - // See description above class for details. - base::RepeatingTimer<TabOverviewController> configure_timer_; - - DISALLOW_COPY_AND_ASSIGN(TabOverviewController); -}; - -#endif // CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_CONTROLLER_H_ diff --git a/chrome/browser/views/tabs/tab_overview_drag_controller.cc b/chrome/browser/views/tabs/tab_overview_drag_controller.cc deleted file mode 100644 index b609489..0000000 --- a/chrome/browser/views/tabs/tab_overview_drag_controller.cc +++ /dev/null @@ -1,457 +0,0 @@ -// Copyright (c) 2009 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. - -#include "chrome/browser/views/tabs/tab_overview_drag_controller.h" - -#include "chrome/browser/browser.h" -#include "chrome/browser/browser_window.h" -#include "chrome/browser/dock_info.h" -#include "chrome/browser/gtk/browser_window_gtk.h" -#include "chrome/browser/metrics/user_metrics.h" -#include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/browser/tabs/tab_strip_model.h" -#include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/browser/views/tabs/tab_overview_cell.h" -#include "chrome/browser/views/tabs/tab_overview_controller.h" -#include "chrome/browser/views/tabs/tab_overview_grid.h" -#include "chrome/browser/views/tabs/tab_overview_types.h" -#include "chrome/common/notification_service.h" -#include "views/fill_layout.h" -#include "views/view.h" -#include "views/widget/root_view.h" -#include "views/widget/widget_gtk.h" - -TabOverviewDragController::TabOverviewDragController( - TabOverviewController* controller) - : controller_(controller), - original_model_(controller->model()), - current_index_(-1), - original_index_(-1), - detached_tab_(NULL), - original_delegate_(NULL), - x_offset_(0), - y_offset_(0), - dragging_(false), - modifying_model_(false), - detached_window_(NULL), - hidden_browser_(NULL), - mouse_over_mini_window_(false) { -} - -TabOverviewDragController::~TabOverviewDragController() { - if (dragging_) - controller_->DragEnded(); - if (original_index_ != -1) - RevertDrag(false); -} - -bool TabOverviewDragController::Configure(const gfx::Point& location) { - // Find the cell the user clicked on. - TabOverviewCell* cell = NULL; - int index = -1; - for (int i = 0; i < grid()->GetChildViewCount(); ++i) { - views::View* child = grid()->GetChildViewAt(i); - if (child->bounds().Contains(location)) { - index = i; - cell = static_cast<TabOverviewCell*>(child); - break; - } - } - if (!cell) - return false; // User didn't click on a cell. - - // Only start a drag if the user clicks on the thumbnail. - gfx::Point cell_point(location); - grid()->ConvertPointToView(grid(), cell, &cell_point); - if (!cell->IsPointInThumbnail(cell_point)) - return false; - - current_index_ = original_index_ = index; - origin_ = location; - x_offset_ = location.x() - cell->bounds().x(); - y_offset_ = location.y() - cell->bounds().y(); - - // Ask the controller to select the cell. - controller_->SelectTab(index); - - if (controller_->browser()) { - browser_window_size_ = - controller_->browser()->window()->GetRestoredBounds().size(); - } - - return true; -} - -void TabOverviewDragController::Drag(const gfx::Point& location) { - if (original_index_ == -1) - return; - - if (!dragging_ && - views::View::ExceededDragThreshold(location.x() - origin_.x(), - location.y() - origin_.y())) { - // Start dragging. - dragging_ = true; - controller_->DragStarted(); - grid()->set_floating_index(current_index_); - UserMetrics::RecordAction("TabOverview_DragCell", - original_model_->profile()); - } - if (dragging_) - DragCell(location); -} - -void TabOverviewDragController::CommitDrag(const gfx::Point& location) { - if (original_index_ == -1) - return; - - Drag(location); - if (detached_tab_) { - if (mouse_over_mini_window_) { - // Dragged over a mini window, add as the last tab to the browser. - Attach(model()->count()); - UserMetrics::RecordAction("TabOverview_DropOnMiniWindow", - original_model_->profile()); - } else { - DropTab(location); - } - } else if (!dragging_) { - // We haven't started dragging. Tell the controller to focus the browser. - controller_->FocusBrowser(); - } else { - // The tab is already in position, nothing to do but animate the change. - grid()->set_floating_index(-1); - grid()->AnimateToTargetBounds(); - } - - // Set the index to -1 so we know not to do any cleanup. - original_index_ = -1; -} - -void TabOverviewDragController::RevertDrag(bool tab_destroyed) { - if (original_index_ == -1) - return; - - modifying_model_ = true; - if (detached_tab_) { - // Tab is currently detached, add it back to the original tab strip. - if (!tab_destroyed) { - original_model_->InsertTabContentsAt(original_index_, - detached_tab_, true, false); - } - SetDetachedContents(NULL); - detached_window_->Close(); - detached_window_ = NULL; - - if (hidden_browser_) { - gtk_widget_show(GTK_WIDGET(static_cast<BrowserWindowGtk*>( - hidden_browser_->window())->GetNativeHandle())); - } - } else if (original_model_ != model() && !tab_destroyed) { - // The tab was added to a different tab strip. Move it back to the - // original. - TabContents* contents = model()->DetachTabContentsAt(current_index_); - original_model_->InsertTabContentsAt(original_index_, contents, true, - false); - } else if (current_index_ != original_index_ && !tab_destroyed) { - original_model_->MoveTabContentsAt(current_index_, original_index_, true); - } - modifying_model_ = false; - - // Set the index to -1 so we know not to do any cleanup. - original_index_ = -1; -} - -TabOverviewGrid* TabOverviewDragController::grid() const { - return controller_->grid(); -} - -TabStripModel* TabOverviewDragController::model() const { - return controller_->model(); -} - -void TabOverviewDragController::Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { - DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED); - DCHECK(Source<TabContents>(source).ptr() == detached_tab_); - RevertDrag(true); -} - -void TabOverviewDragController::OpenURLFromTab( - TabContents* source, - const GURL& url, - const GURL& referrer, - WindowOpenDisposition disposition, - PageTransition::Type transition) { - if (original_delegate_) { - if (disposition == CURRENT_TAB) - disposition = NEW_WINDOW; - - original_delegate_->OpenURLFromTab(source, url, referrer, - disposition, transition); - } -} - -void TabOverviewDragController::NavigationStateChanged( - const TabContents* source, - unsigned changed_flags) { -} - -void TabOverviewDragController::AddNewContents( - TabContents* source, - TabContents* new_contents, - WindowOpenDisposition disposition, - const gfx::Rect& initial_pos, - bool user_gesture) { - DCHECK(disposition != CURRENT_TAB); - - // Theoretically could be called while dragging if the page tries to - // spawn a window. Route this message back to the browser in most cases. - if (original_delegate_) { - original_delegate_->AddNewContents(source, new_contents, disposition, - initial_pos, user_gesture); - } -} - -void TabOverviewDragController::ActivateContents(TabContents* contents) { - // Ignored. -} - -void TabOverviewDragController::LoadingStateChanged(TabContents* source) { -} - -void TabOverviewDragController::CloseContents(TabContents* source) { - // Theoretically could be called by a window. Should be ignored - // because window.close() is ignored (usually, even though this - // method gets called.) -} - -void TabOverviewDragController::MoveContents(TabContents* source, - const gfx::Rect& pos) { - // Theoretically could be called by a web page trying to move its - // own window. Should be ignored since we're moving the window... -} - -bool TabOverviewDragController::IsPopup(TabContents* source) { - return false; -} - -void TabOverviewDragController::ToolbarSizeChanged(TabContents* source, - bool finished) { - // Dragged tabs don't care about this. -} - -void TabOverviewDragController::URLStarredChanged(TabContents* source, - bool starred) { - // Ignored. -} - -void TabOverviewDragController::UpdateTargetURL(TabContents* source, - const GURL& url) { - // Ignored. -} - -void TabOverviewDragController::DragCell(const gfx::Point& location) { - if (controller_->moved_offscreen()) { - MoveDetachedWindow(location); - return; - } - - int col = (location.x() - x_offset_ + grid()->cell_width() / 2) / - (grid()->cell_width() + TabOverviewGrid::kCellXPadding); - int row = (location.y() - y_offset_ + grid()->cell_height() / 2) / - (grid()->cell_height() + TabOverviewGrid::kCellYPadding); - gfx::Rect local_bounds = grid()->GetLocalBounds(true); - if (!local_bounds.Contains(location)) { - // Local bounds doesn't contain the point, allow dragging to the left/right - // of us. - views::View* root = grid()->GetParent(); - gfx::Rect allowed_bounds = local_bounds; - gfx::Point root_offset; - views::View::ConvertPointToView(grid(), root, &root_offset); - allowed_bounds.Offset(-root_offset.x(), 0); - allowed_bounds.set_width(root->width()); - if (!allowed_bounds.Contains(location)) { - // The user dragged outside the grid. - if (detached_tab_) { - // We've already created the detached window, move it. - MoveDetachedWindow(location); - } else { - // Detach the cell. - Detach(location); - } - return; - } - if (location.x() < 0) { - col = 0; - } else if (location.x() >= grid()->width()) { - col = grid()->columns(); - } else { - col = (location.x() + grid()->cell_width() / 2) / - (grid()->cell_width() + TabOverviewGrid::kCellXPadding); - } - } - int new_index = std::min(model()->count() - 1, - row * grid()->columns() + col); - if (detached_tab_) { - // The user dragged a detached tab back over the grid, reattach it. - Attach(new_index); - } else if (new_index != current_index_) { - grid()->set_floating_index(new_index); - modifying_model_ = true; - model()->MoveTabContentsAt(current_index_, new_index, false); - modifying_model_ = false; - current_index_ = new_index; - } - gfx::Rect target_bounds = grid()->CellBounds(current_index_); - target_bounds.Offset(location.x() - target_bounds.x() - x_offset_, - location.y() - target_bounds.y() - y_offset_); - target_bounds.set_y(row * (grid()->cell_height() + - TabOverviewGrid::kCellYPadding)); - target_bounds = target_bounds.AdjustToFit(grid()->GetLocalBounds(true)); - views::View* cell = grid()->GetChildViewAt(new_index); - gfx::Rect cell_bounds = cell->bounds(); - if (target_bounds.origin() != cell_bounds.origin()) { - grid()->SchedulePaint(cell_bounds, false); - grid()->SchedulePaint(target_bounds, false); - cell->SetBounds(target_bounds); - } -} - -void TabOverviewDragController::Attach(int index) { - DCHECK(detached_tab_); - DCHECK(model()); - current_index_ = index; - modifying_model_ = true; - model()->InsertTabContentsAt(index, detached_tab_, true, false); - modifying_model_ = false; - grid()->set_floating_index(index); - SetDetachedContents(NULL); - - detached_window_->Close(); - detached_window_ = NULL; -} - -void TabOverviewDragController::Detach(const gfx::Point& location) { - if (detached_tab_) { - // Already detached. - return; - } - - UserMetrics::RecordAction("TabOverview_DetachCell", - original_model_->profile()); - - detached_window_ = CreateDetachedWindow( - location, model()->GetTabContentsAt(current_index_)); - detached_window_->Show(); - - grid()->set_floating_index(-1); - SetDetachedContents(model()->GetTabContentsAt(current_index_)); - if (model()->count() == 1) { - // The model is going to be empty. Tell the host to move us offscreen. - // NOTE: it would be nice to hide and destroy the window here but this - // causes two problems: we'll stop getting events, and we don't want - // to empty out the tabstrip as otherwise they may trigger Chrome to - // exit. - controller_->MoveOffscreen(); - hidden_browser_ = controller_->browser(); - gtk_widget_hide(GTK_WIDGET(static_cast<BrowserWindowGtk*>( - hidden_browser_->window())->GetNativeHandle())); - } - modifying_model_ = true; - model()->DetachTabContentsAt(current_index_); - modifying_model_ = false; -} - -void TabOverviewDragController::DropTab(const gfx::Point& location) { - TabContents* contents = detached_tab_; - SetDetachedContents(NULL); - - gfx::Point screen_loc(location); - grid()->ConvertPointToScreen(grid(), &screen_loc); - gfx::Rect window_bounds(screen_loc, browser_window_size_); - Browser* new_browser = - original_model_->delegate()->CreateNewStripWithContents( - contents, window_bounds, DockInfo()); - new_browser->window()->Show(); - - detached_window_->Close(); - detached_window_ = NULL; -} - -void TabOverviewDragController::MoveDetachedWindow( - const gfx::Point& location) { - gfx::Point screen_loc = location; - screen_loc.Offset(-x_offset_, -y_offset_); - grid()->ConvertPointToScreen(grid(), &screen_loc); - detached_window_->SetBounds( - gfx::Rect(screen_loc, - detached_window_->GetRootView()->GetPreferredSize())); - - // Notify the wm of the move. - TabOverviewTypes::Message message; - message.set_type(TabOverviewTypes::Message::WM_MOVE_FLOATING_TAB); - message.set_param(0, x11_util::GetX11WindowFromGtkWidget( - detached_window_->GetNativeView())); - message.set_param(1, screen_loc.x() + x_offset_); - message.set_param(2, screen_loc.y() + y_offset_); - TabOverviewTypes::instance()->SendMessage(message); -} - -views::Widget* TabOverviewDragController::CreateDetachedWindow( - const gfx::Point& location, - TabContents* tab_contents) { - // TODO: wrap the cell in another view that provides a background. - views::WidgetGtk* widget = - new views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW); - widget->MakeTransparent(); - gfx::Point screen_loc = location; - screen_loc.Offset(-x_offset_, -y_offset_); - grid()->ConvertPointToScreen(grid(), &screen_loc); - TabOverviewCell* cell = new TabOverviewCell(); - cell->set_preferred_size( - gfx::Size(grid()->cell_width(), grid()->cell_height())); - controller_->ConfigureCell(cell, tab_contents); - widget->Init(NULL, gfx::Rect(screen_loc, cell->GetPreferredSize())); - widget->GetRootView()->SetLayoutManager(new views::FillLayout()); - widget->GetRootView()->AddChildView(cell); - - std::vector<int> params(4); - params[0] = screen_loc.x() + x_offset_; - params[1] = screen_loc.y() + y_offset_; - params[2] = x_offset_; - params[3] = y_offset_; - TabOverviewTypes::instance()->SetWindowType( - widget->GetNativeView(), - TabOverviewTypes::WINDOW_TYPE_CHROME_FLOATING_TAB, - ¶ms); - - return widget; -} - -void TabOverviewDragController::SetDetachedContents(TabContents* tab) { - if (detached_tab_) { - registrar_.Remove(this, - NotificationType::TAB_CONTENTS_DESTROYED, - Source<TabContents>(detached_tab_)); - if (detached_tab_->delegate() == this) - detached_tab_->set_delegate(original_delegate_); - else - DLOG(WARNING) << " delegate changed"; - } - original_delegate_ = NULL; - detached_tab_ = tab; - if (tab) { - registrar_.Add(this, - NotificationType::TAB_CONTENTS_DESTROYED, - Source<TabContents>(tab)); - - // We need to be the delegate so we receive messages about stuff, - // otherwise our dragged contents may be replaced and subsequently - // collected/destroyed while the drag is in process, leading to - // nasty crashes. - original_delegate_ = tab->delegate(); - tab->set_delegate(this); - } -} diff --git a/chrome/browser/views/tabs/tab_overview_drag_controller.h b/chrome/browser/views/tabs/tab_overview_drag_controller.h deleted file mode 100644 index 4a8a2a0..0000000 --- a/chrome/browser/views/tabs/tab_overview_drag_controller.h +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright (c) 2009 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_TABS_TAB_OVERVIEW_DRAG_CONTROLLER_H_ -#define CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_DRAG_CONTROLLER_H_ - -#include "base/gfx/point.h" -#include "base/scoped_ptr.h" -#include "chrome/browser/tab_contents/tab_contents_delegate.h" -#include "chrome/common/notification_registrar.h" - -class Browser; -class TabOverviewController; -class TabOverviewGrid; -class TabStripModel; - -namespace views { -class Widget; -} - -// TabOverviewDragController handles dragging cells in a TabOverviewGrid. -// There are a couple of interesting states TabOverviewDragController may -// be in: -// . original_index_ == -1: indicates the drag wasn't valid (not over a cell), -// or the drag is done (either committed or reverted). -// . detached_tab_ != NULL: the user has dragged a tab outside the grid such -// that a windows was created with the contents of -// the tab. -// . detached_tab_ == NULL: the user is dragging a cell around within the grid. -// -// TabOverviewGrid invokes Configure to prepare the controller. If this returns -// true, then Drag is repeatedly invoked as the user drags the mouse around. -// Finally CommitDrag is invoked if the user releases the mouse, or RevertDrag -// if the drag is canceled some how. -// -// NOTE: all coordinates passed in are relative to the TabOverviewGrid. -class TabOverviewDragController : public TabContentsDelegate, - public NotificationObserver { - public: - explicit TabOverviewDragController(TabOverviewController* controller); - ~TabOverviewDragController(); - - // Sets whether the mouse is over a mini-window. - void set_mouse_over_mini_window(bool over_mini_window) { - mouse_over_mini_window_ = over_mini_window; - } - - // Prepares the TabOverviewDragController for a drag. Returns true if over a - // cell, false if the mouse isn't over a valid location. - bool Configure(const gfx::Point& location); - - // Invoked as the user drags the mouse. - void Drag(const gfx::Point& location); - - // Commits the drag, typically when the user releases the mouse. - void CommitDrag(const gfx::Point& location); - - // Reverts the drag. Use true if the revert is the result of the tab being - // destroyed. - void RevertDrag(bool tab_destroyed); - - bool modifying_model() const { return modifying_model_; } - TabOverviewGrid* grid() const; - TabStripModel* model() const; - - // Overridden from NotificationObserver: - virtual void Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details); - - // Overridden from TabContentsDelegate: - virtual void OpenURLFromTab(TabContents* source, - const GURL& url, - const GURL& referrer, - WindowOpenDisposition disposition, - PageTransition::Type transition); - virtual void NavigationStateChanged(const TabContents* source, - unsigned changed_flags); - virtual void AddNewContents(TabContents* source, - TabContents* new_contents, - WindowOpenDisposition disposition, - const gfx::Rect& initial_pos, - bool user_gesture); - virtual void ActivateContents(TabContents* contents); - virtual void LoadingStateChanged(TabContents* source); - virtual void CloseContents(TabContents* source); - virtual void MoveContents(TabContents* source, const gfx::Rect& pos); - virtual bool IsPopup(TabContents* source); - virtual void ToolbarSizeChanged(TabContents* source, bool is_animating); - virtual void URLStarredChanged(TabContents* source, bool starred); - virtual void UpdateTargetURL(TabContents* source, const GURL& url); - - private: - // Invoked from Drag if the mouse has moved enough to trigger dragging. - void DragCell(const gfx::Point& location); - - // Reattaches the detatched tab. |index| is the index into |model()| as to - // where the tab should be attached. - void Attach(int index); - - // Detaches the tab at |current_index_|. - void Detach(const gfx::Point& location); - - // Drops the detached tab. This is invoked from |CommitDrag|. - void DropTab(const gfx::Point& location); - - // Moves the detached window. - void MoveDetachedWindow(const gfx::Point& location); - - // Creates and returns the detached window. - views::Widget* CreateDetachedWindow(const gfx::Point& location, - TabContents* contents); - - // Sets the detaches contents, installed/uninstalling listeners. - void SetDetachedContents(TabContents* tab); - - TabOverviewController* controller_; - - // The model the drag started from. This needs to be cached as the grid may - // end up showing a different model if the user drags over another window. - TabStripModel* original_model_; - - // The index the tab has been dragged to. This is initially the index the - // user pressed the mouse at, but changes as the user drags the tab around. - int current_index_; - - // The original index the tab was at. If -1 it means the drag is invalid or - // done. See description above class for more details. - int original_index_; - - // The tab being dragged. This is only non-NULL if the tab has been detached. - TabContents* detached_tab_; - - // If detached_tab_ is non-null, this is it's delegate before we set - // ourselves as the delegate. - TabContentsDelegate* original_delegate_; - - // The origin of the click. - gfx::Point origin_; - - // Offset of the initial mouse location relative to the cell at - // original_index_. - int x_offset_; - int y_offset_; - - // Has the user started dragging? - bool dragging_; - - // If true, we're modifying the model. This is used to avoid cancelling the - // drag when the model changes. - bool modifying_model_; - - // Handles registering for notifications. - NotificationRegistrar registrar_; - - // Once a tab is detached a window is created containing a cell and moved - // around; this is that window. - views::Widget* detached_window_; - - // When a tab is detached from a browser with a single tab we hide the - // browser. If this is non-null it means a single tab has been detached - // and this is the browser it was detached from. - Browser* hidden_browser_; - - // Whether the mouse is over a mini window. - bool mouse_over_mini_window_; - - // Size of the browser window. Cached in case browser() becomes NULL (as - // happens when the user drags over a region that shouldn't show the tab - // overview). - gfx::Size browser_window_size_; - - DISALLOW_COPY_AND_ASSIGN(TabOverviewDragController); -}; - -#endif // CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_DRAG_CONTROLLER_H_ diff --git a/chrome/browser/views/tabs/tab_overview_grid.cc b/chrome/browser/views/tabs/tab_overview_grid.cc deleted file mode 100644 index 35bd116..0000000 --- a/chrome/browser/views/tabs/tab_overview_grid.cc +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) 2009 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. - -#include "chrome/browser/views/tabs/tab_overview_grid.h" - -#include "chrome/browser/views/tabs/tab_overview_cell.h" -#include "chrome/browser/views/tabs/tab_overview_controller.h" -#include "chrome/browser/views/tabs/tab_overview_drag_controller.h" -#include "views/screen.h" - -TabOverviewGrid::TabOverviewGrid(TabOverviewController* controller) - : controller_(controller) { -} - -TabOverviewGrid::~TabOverviewGrid() { -} - -bool TabOverviewGrid::modifying_model() const { - return drag_controller_.get() && drag_controller_->modifying_model(); -} - -TabOverviewCell* TabOverviewGrid::GetTabOverviewCellAt(int index) { - return static_cast<TabOverviewCell*>(GetChildViewAt(index)); -} - -TabOverviewDragController* TabOverviewGrid::drag_controller() const { - return drag_controller_.get(); -} - -void TabOverviewGrid::CancelDrag() { - drag_controller_.reset(NULL); -} - -void TabOverviewGrid::UpdateDragController() { - if (drag_controller_.get()) { - gfx::Point mouse_loc = views::Screen::GetCursorScreenPoint(); - ConvertPointToView(NULL, this, &mouse_loc); - drag_controller_->Drag(mouse_loc); - } -} - -bool TabOverviewGrid::OnMousePressed(const views::MouseEvent& event) { - if (drag_controller_.get()) - return true; - - if (!event.IsLeftMouseButton()) - return false; - - drag_controller_.reset(new TabOverviewDragController(controller_)); - if (!drag_controller_->Configure(event.location())) { - drag_controller_.reset(NULL); - return false; - } - return true; -} - -bool TabOverviewGrid::OnMouseDragged(const views::MouseEvent& event) { - if (!drag_controller_.get()) - return false; - - drag_controller_->Drag(event.location()); - return true; -} - -void TabOverviewGrid::OnMouseReleased(const views::MouseEvent& event, - bool canceled) { - if (!drag_controller_.get()) - return; - - if (canceled) - drag_controller_->RevertDrag(false); - else - drag_controller_->CommitDrag(event.location()); - drag_controller_.reset(NULL); -} - -void TabOverviewGrid::AnimationEnded(const Animation* animation) { - Grid::AnimationEnded(animation); - controller_->GridAnimationEnded(); -} - -void TabOverviewGrid::AnimationProgressed(const Animation* animation) { - Grid::AnimationProgressed(animation); - controller_->GridAnimationProgressed(); -} - -void TabOverviewGrid::AnimationCanceled(const Animation* animation) { - Grid::AnimationCanceled(animation); - controller_->GridAnimationCanceled(); -} diff --git a/chrome/browser/views/tabs/tab_overview_grid.h b/chrome/browser/views/tabs/tab_overview_grid.h deleted file mode 100644 index 52cf27f..0000000 --- a/chrome/browser/views/tabs/tab_overview_grid.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2009 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_TABS_TAB_OVERVIEW_GRID_H_ -#define CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_GRID_H_ - -#include "base/scoped_ptr.h" -#include "chrome/browser/views/tabs/grid.h" - -class TabOverviewCell; -class TabOverviewController; -class TabOverviewDragController; - -// TabOverviewGrid is used to provide a grid view of the contents of a tab -// strip model. Each cell of the grid is a TabOverviewCell. TabOverviewGrids -// primary responsibility is to forward events to TabOverviewDragController. -class TabOverviewGrid : public Grid { - public: - explicit TabOverviewGrid(TabOverviewController* controller); - virtual ~TabOverviewGrid(); - - // Returns true if a drag is underway and the drag is in the process of - // modifying the tab strip model. - bool modifying_model() const; - - // Returns the TabOverviewCell at the specified index. - TabOverviewCell* GetTabOverviewCellAt(int index); - - // Returns the TabOverviewDragController. This is NULL if a drag is not - // underway. - TabOverviewDragController* drag_controller() const; - - // Cancels the drag. Does nothing if a drag is not underway. - void CancelDrag(); - - // If a drag is under way, this invokes Drag on the DragController with the - // current position of the mouse. - void UpdateDragController(); - - // View overrides. - virtual bool OnMousePressed(const views::MouseEvent& event); - virtual bool OnMouseDragged(const views::MouseEvent& event); - virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled); - - // AnimationDelegate overrides. - virtual void AnimationEnded(const Animation* animation); - virtual void AnimationProgressed(const Animation* animation); - virtual void AnimationCanceled(const Animation* animation); - - private: - TabOverviewController* controller_; - - scoped_ptr<TabOverviewDragController> drag_controller_; - - DISALLOW_COPY_AND_ASSIGN(TabOverviewGrid); -}; - -#endif // CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_GRID_H_ diff --git a/chrome/browser/views/tabs/tab_overview_message_listener.cc b/chrome/browser/views/tabs/tab_overview_message_listener.cc deleted file mode 100644 index 3222d21..0000000 --- a/chrome/browser/views/tabs/tab_overview_message_listener.cc +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (c) 2009 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. - -#include "chrome/browser/views/tabs/tab_overview_message_listener.h" - -#include "chrome/browser/browser.h" -#include "chrome/browser/browser_list.h" -#if defined(TOOLKIT_VIEWS) -#include "chrome/browser/views/frame/browser_view.h" -#else -#include "chrome/browser/gtk/browser_window_gtk.h" -#endif -#include "chrome/browser/metrics/user_metrics.h" -#include "chrome/browser/views/new_browser_window_widget.h" -#include "chrome/browser/views/tabs/tab_overview_controller.h" -#include "chrome/common/x11_util.h" - -// static -TabOverviewMessageListener* TabOverviewMessageListener::instance() { - static TabOverviewMessageListener* instance = NULL; - if (!instance) { - instance = Singleton<TabOverviewMessageListener>::get(); - MessageLoopForUI::current()->AddObserver(instance); - } - return instance; -} - -#if defined(TOOLKIT_VIEWS) -// static -BrowserView* TabOverviewMessageListener::GetBrowserViewForGdkWindow( - GdkWindow* gdk_window) { - gpointer data = NULL; - gdk_window_get_user_data(gdk_window, &data); - GtkWidget* widget = reinterpret_cast<GtkWidget*>(data); - if (widget) { - GtkWindow* gtk_window = GTK_WINDOW(widget); - return BrowserView::GetBrowserViewForNativeWindow(gtk_window); - } else { - return NULL; - } -} -#endif - -void TabOverviewMessageListener::WillProcessEvent(GdkEvent* event) { -} - -void TabOverviewMessageListener::DidProcessEvent(GdkEvent* event) { - if (event->type == GDK_CLIENT_EVENT) { - TabOverviewTypes::Message message; - GdkEventClient* client_event = reinterpret_cast<GdkEventClient*>(event); - TabOverviewTypes* types = TabOverviewTypes::instance(); - if (types->DecodeMessage(*client_event, &message)) - ProcessMessage(message, client_event->window); - else - types->HandleNonChromeClientMessageEvent(*client_event); - } -} - -TabOverviewMessageListener::TabOverviewMessageListener() { -} - -TabOverviewMessageListener::~TabOverviewMessageListener() { -} - -void TabOverviewMessageListener::ProcessMessage( - const TabOverviewTypes::Message& message, - GdkWindow* window) { - switch (message.type()) { - case TabOverviewTypes::Message::CHROME_SET_TAB_SUMMARY_VISIBILITY: { - if (message.param(0) == 0) { - HideOverview(); - } else { -#if defined(TOOLKIT_VIEWS) - BrowserView* browser_window = GetBrowserViewForGdkWindow(window); -#else - BrowserWindowGtk* browser_window = - BrowserWindowGtk::GetBrowserWindowForNativeWindow( - BrowserWindowGtk::GetBrowserWindowForXID( - x11_util::GetX11WindowFromGdkWindow(window))); -#endif - if (browser_window) - ShowOverview(browser_window->browser(), message.param(1)); - else - HideOverview(); - } - break; - } - - case TabOverviewTypes::Message::CHROME_NOTIFY_LAYOUT_MODE: { - if (message.param(0) == 0) { - new_browser_window_.reset(NULL); - controller_.reset(NULL); - } else if (BrowserList::size() > 0) { - Browser* browser = *BrowserList::begin(); - controller_.reset(new TabOverviewController( - browser->window()->GetRestoredBounds().origin())); - new_browser_window_.reset( - new NewBrowserWindowWidget(browser->profile())); - } - break; - } - - case TabOverviewTypes::Message::CHROME_NOTIFY_FLOATING_TAB_OVER_TOPLEVEL: { - if (!controller_.get()) - return; - - bool over_mini_window = message.param(1) == 1; - controller_->SetMouseOverMiniWindow(over_mini_window); - if (!over_mini_window) - return; - - // Over a mini-window, make sure the controller is showing the contents - // of the browser the mouse is over. -#if defined(TOOLKIT_VIEWS) - BrowserView* browser_window = GetBrowserViewForGdkWindow( - gdk_window_lookup(message.param(0))); -#else - BrowserWindowGtk* browser_window = - BrowserWindowGtk::GetBrowserWindowForNativeWindow( - BrowserWindowGtk::GetBrowserWindowForXID(message.param(0))); -#endif - if (!browser_window) - return; - - if (controller_->browser()->window() == browser_window) - return; - - TabOverviewTypes::Message select_message; - select_message.set_type(TabOverviewTypes::Message::WM_MOVE_FLOATING_TAB); - select_message.set_param(0, message.param(1)); - TabOverviewTypes::instance()->SendMessage(select_message); - - UserMetrics::RecordAction("TabOverview_DragOverMiniWindow", - browser_window->browser()->profile()); - } - - default: - break; - } -} - -void TabOverviewMessageListener::ShowOverview(Browser* browser, - int horizontal_center) { - if (!controller_.get()) { - controller_.reset(new TabOverviewController( - browser->window()->GetRestoredBounds().origin())); - } - controller_->SetBrowser(browser, horizontal_center); - controller_->Show(); -} - -void TabOverviewMessageListener::HideOverview() { - controller_->SetBrowser(NULL, -1); -} diff --git a/chrome/browser/views/tabs/tab_overview_message_listener.h b/chrome/browser/views/tabs/tab_overview_message_listener.h deleted file mode 100644 index 4075222..0000000 --- a/chrome/browser/views/tabs/tab_overview_message_listener.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2009 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_TABS_TAB_OVERVIEW_MESSAGE_LISTENER_H_ -#define CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_MESSAGE_LISTENER_H_ - -#include <gtk/gtk.h> - -#include "base/message_loop.h" -#include "base/scoped_ptr.h" -#include "base/singleton.h" -#include "chrome/browser/views/tabs/tab_overview_types.h" - -class Browser; -#if defined(TOOLKIT_VIEWS) -class BrowserView; -#endif -class NewBrowserWindowWidget; -class TabOverviewController; - -// TabOverviewMessageListener listens for messages, showing/hiding the tab -// overview as necessary. TabOverviewMessageListener is created early on by -// browser init and only one instance ever exists. -class TabOverviewMessageListener : public MessageLoopForUI::Observer { - public: - static TabOverviewMessageListener* instance(); - - // MessageLoopForUI::Observer overrides. - virtual void WillProcessEvent(GdkEvent* event); - virtual void DidProcessEvent(GdkEvent* event); - - private: - friend struct DefaultSingletonTraits<TabOverviewMessageListener>; - -#if defined(TOOLKIT_VIEWS) - // Returns a BrowserView that corresponds to given gdk_window. - static BrowserView* GetBrowserViewForGdkWindow(GdkWindow* gdk_window); -#endif - - TabOverviewMessageListener(); - ~TabOverviewMessageListener(); - - // Invoked when a valid TabOverviewTypes::Message is found on the message - // loop.. - void ProcessMessage(const TabOverviewTypes::Message& message, - GdkWindow* window); - - // Shows the tab overview for |browser|. - void ShowOverview(Browser* browser, int horizontal_center); - - // Hids the tab overview. - void HideOverview(); - - // If non-null tab overview is showing. - scoped_ptr<TabOverviewController> controller_; - - // Non-null while in tab-overview mode. - scoped_ptr<NewBrowserWindowWidget> new_browser_window_; - - DISALLOW_COPY_AND_ASSIGN(TabOverviewMessageListener); -}; - -#endif // CHROME_BROWSER_VIEWS_TABS_TAB_OVERVIEW_MESSAGE_LISTENER_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 2bad76e..3df5a9f 100755 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -378,6 +378,10 @@ 'browser/chromeos/usb_mount_observer.h', 'browser/chromeos/version_loader.cc', 'browser/chromeos/version_loader.h', + 'browser/chromeos/wm_ipc.cc', + 'browser/chromeos/wm_ipc.h', + 'browser/chromeos/wm_message_listener.cc', + 'browser/chromeos/wm_message_listener.h', 'browser/cocoa/about_ipc_bridge.h', 'browser/cocoa/about_ipc_bridge.mm', 'browser/cocoa/about_ipc_controller.h', @@ -2017,8 +2021,6 @@ 'browser/views/modal_dialog_delegate.h', 'browser/views/new_profile_dialog.cc', 'browser/views/new_profile_dialog.h', - 'browser/views/new_browser_window_widget.cc', - 'browser/views/new_browser_window_widget.h', 'browser/views/notifications/balloon_view_host.cc', 'browser/views/notifications/balloon_view_host.h', 'browser/views/notifications/balloon_view.cc', @@ -2098,8 +2100,6 @@ 'browser/views/tabs/dragged_tab_controller.h', 'browser/views/tabs/dragged_tab_view.cc', 'browser/views/tabs/dragged_tab_view.h', - 'browser/views/tabs/grid.cc', - 'browser/views/tabs/grid.h', 'browser/views/tabs/native_view_photobooth.h', 'browser/views/tabs/native_view_photobooth_gtk.cc', 'browser/views/tabs/native_view_photobooth_gtk.h', @@ -2114,20 +2114,6 @@ 'browser/views/tabs/side_tab_strip.h', 'browser/views/tabs/tab.cc', 'browser/views/tabs/tab.h', - 'browser/views/tabs/tab_overview_cell.cc', - 'browser/views/tabs/tab_overview_cell.h', - 'browser/views/tabs/tab_overview_container.cc', - 'browser/views/tabs/tab_overview_container.h', - 'browser/views/tabs/tab_overview_controller.cc', - 'browser/views/tabs/tab_overview_controller.h', - 'browser/views/tabs/tab_overview_drag_controller.cc', - 'browser/views/tabs/tab_overview_drag_controller.h', - 'browser/views/tabs/tab_overview_grid.cc', - 'browser/views/tabs/tab_overview_grid.h', - 'browser/views/tabs/tab_overview_message_listener.cc', - 'browser/views/tabs/tab_overview_message_listener.h', - 'browser/views/tabs/tab_overview_types.cc', - 'browser/views/tabs/tab_overview_types.h', 'browser/views/tabs/tab_renderer.cc', 'browser/views/tabs/tab_renderer.h', 'browser/views/tabs/tab_strip.cc', @@ -2428,25 +2414,7 @@ 'browser/password_manager/password_store_kwallet.h', 'browser/password_manager/password_store_kwallet.cc', 'browser/power_save_blocker_stub.cc', - 'browser/views/new_browser_window_widget.cc', - 'browser/views/new_browser_window_widget.h', 'browser/views/select_file_dialog.cc', - 'browser/views/tabs/grid.cc', - 'browser/views/tabs/grid.h', - 'browser/views/tabs/tab_overview_cell.cc', - 'browser/views/tabs/tab_overview_cell.h', - 'browser/views/tabs/tab_overview_container.cc', - 'browser/views/tabs/tab_overview_container.h', - 'browser/views/tabs/tab_overview_controller.cc', - 'browser/views/tabs/tab_overview_controller.h', - 'browser/views/tabs/tab_overview_drag_controller.cc', - 'browser/views/tabs/tab_overview_drag_controller.h', - 'browser/views/tabs/tab_overview_grid.cc', - 'browser/views/tabs/tab_overview_grid.h', - 'browser/views/tabs/tab_overview_message_listener.cc', - 'browser/views/tabs/tab_overview_message_listener.h', - 'browser/views/tabs/tab_overview_types.cc', - 'browser/views/tabs/tab_overview_types.h', ], }, { # 'OS!="win" 'sources/': [ @@ -2751,8 +2719,6 @@ ['include', 'browser/views/bug_report_view.h'], ['include', 'browser/views/event_utils.cc'], ['include', 'browser/views/event_utils.h'], - ['include', 'browser/views/new_browser_window_widget.cc'], - ['include', 'browser/views/new_browser_window_widget.h'], ['include', 'browser/views/options/options_page_view.cc'], ['include', 'browser/views/options/options_page_view.h'], ['include', 'browser/views/panel_controller.cc'], @@ -2763,22 +2729,6 @@ ['include', 'browser/views/panels/panel_scroller.h'], ['include', 'browser/views/panels/panel_scroller_header.cc'], ['include', 'browser/views/panels/panel_scroller_header.h'], - ['include', 'browser/views/tabs/grid.cc'], - ['include', 'browser/views/tabs/grid.h'], - ['include', 'browser/views/tabs/tab_overview_cell.cc'], - ['include', 'browser/views/tabs/tab_overview_cell.h'], - ['include', 'browser/views/tabs/tab_overview_container.cc'], - ['include', 'browser/views/tabs/tab_overview_container.h'], - ['include', 'browser/views/tabs/tab_overview_controller.cc'], - ['include', 'browser/views/tabs/tab_overview_controller.h'], - ['include', 'browser/views/tabs/tab_overview_drag_controller.cc'], - ['include', 'browser/views/tabs/tab_overview_drag_controller.h'], - ['include', 'browser/views/tabs/tab_overview_grid.cc'], - ['include', 'browser/views/tabs/tab_overview_grid.h'], - ['include', 'browser/views/tabs/tab_overview_message_listener.cc'], - ['include', 'browser/views/tabs/tab_overview_message_listener.h'], - ['include', 'browser/views/tabs/tab_overview_types.cc'], - ['include', 'browser/views/tabs/tab_overview_types.h'], ], }], ['OS=="linux" and chromeos==1',{ |