diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-28 20:45:42 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-28 20:45:42 +0000 |
commit | 45da6c72f2d0d50f2acbf7dc306108c861b71aa4 (patch) | |
tree | 4d5b3c889638b3789033503c11e420f325b51984 /chrome | |
parent | 799c8ef9901a90908432f2d82daafa79a7fecc1f (diff) | |
download | chromium_src-45da6c72f2d0d50f2acbf7dc306108c861b71aa4.zip chromium_src-45da6c72f2d0d50f2acbf7dc306108c861b71aa4.tar.gz chromium_src-45da6c72f2d0d50f2acbf7dc306108c861b71aa4.tar.bz2 |
CompactLocationBar 1st step:
* Added OnMouseXXXTab methods to BrowserExtender to handle on tabs.
* Changed tab to call above methods.
* Added GetSelectedTab to TabStrip
Minor changes along with the major changes above
* Removed unnecessary file entries in chrome.gyp
* Fixed a few method's const.
* Removed unnecessary class declarations and includes.
Know issue: keyboard focus is not working.
In 2nd step, I'm going to eliminate popup and use whatever that FindBar is using to show compact location bar. I'll fix the issue above after this migration. (if it still persists)
BUG=None
Test=None
Review URL: http://codereview.chromium.org/341008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30386 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/chromeos/chromeos_browser_extenders.cc | 42 | ||||
-rw-r--r-- | chrome/browser/chromeos/compact_location_bar.cc | 273 | ||||
-rw-r--r-- | chrome/browser/chromeos/compact_location_bar.h | 111 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_extender.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_extender.h | 10 | ||||
-rw-r--r-- | chrome/browser/views/frame/standard_extender.cc | 5 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab.cc | 34 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab.h | 9 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_strip.cc | 5 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_strip.h | 6 | ||||
-rwxr-xr-x | chrome/chrome.gyp | 4 |
11 files changed, 491 insertions, 10 deletions
diff --git a/chrome/browser/chromeos/chromeos_browser_extenders.cc b/chrome/browser/chromeos/chromeos_browser_extenders.cc index e7c8fcd..9e3645e 100644 --- a/chrome/browser/chromeos/chromeos_browser_extenders.cc +++ b/chrome/browser/chromeos/chromeos_browser_extenders.cc @@ -6,6 +6,7 @@ #include "app/theme_provider.h" #include "chrome/app/chrome_dll_resource.h" +#include "chrome/browser/chromeos/compact_location_bar.h" #include "chrome/browser/chromeos/compact_navigation_bar.h" #include "chrome/browser/chromeos/main_menu.h" #include "chrome/browser/chromeos/status_area_view.h" @@ -14,6 +15,8 @@ #include "chrome/browser/views/frame/browser_frame_gtk.h" #include "chrome/browser/views/frame/browser_view.h" #include "chrome/browser/views/tabs/tab_overview_types.h" +#include "chrome/browser/views/tabs/tab_strip.h" +#include "chrome/browser/views/tabs/tab_strip_wrapper.h" #include "chrome/browser/views/toolbar_view.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -60,6 +63,7 @@ class NormalExtender : public BrowserExtender, main_menu_->SetImage(views::CustomButton::BS_PUSHED, image); browser_view()->AddChildView(main_menu_); + compact_location_bar_.reset(new CompactLocationBar(browser_view())); compact_navigation_bar_ = new CompactNavigationBar(browser_view()->browser()); browser_view()->AddChildView(compact_navigation_bar_); @@ -96,6 +100,12 @@ class NormalExtender : public BrowserExtender, status_area_->SetVisible(true); } + if (compact_navigation_bar_->IsVisible()) { + // Update the size and location of the compact location bar. + compact_location_bar_->UpdateBounds( + browser_view()->tabstrip()->AsTabStrip()->GetSelectedTab()); + } + // Layout main menu before tab strip. gfx::Size main_menu_size = main_menu_->GetPreferredSize(); main_menu_->SetBounds(bounds.x(), bounds.y(), @@ -164,7 +174,28 @@ class NormalExtender : public BrowserExtender, compact_navigation_bar_enabled_ = !compact_navigation_bar_enabled_; } + virtual void OnMouseEnteredToTab(Tab* tab) { + ShowCompactLocationBarUnderSelectedTab(); + } + + virtual void OnMouseMovedOnTab(Tab* tab) { + ShowCompactLocationBarUnderSelectedTab(); + } + + virtual void OnMouseExitedFromTab(Tab* tab) { + compact_location_bar_->StartPopupTimer(); + } + private: + // Shows the compact location bar under the selected tab. + void ShowCompactLocationBarUnderSelectedTab() { + if (!compact_navigation_bar_enabled_) + return; + compact_location_bar_->Update( + browser_view()->tabstrip()->AsTabStrip()->GetSelectedTab(), + browser_view()->browser()->GetSelectedTabContents()); + } + // Creates system menu. void InitSystemMenu() { system_menu_contents_.reset(new views::SimpleMenuModel(browser_view())); @@ -196,7 +227,7 @@ class NormalExtender : public BrowserExtender, // Status Area view. StatusAreaView* status_area_; - // System menus + // System menus. scoped_ptr<views::SimpleMenuModel> system_menu_contents_; scoped_ptr<views::Menu2> system_menu_menu_; @@ -206,6 +237,9 @@ class NormalExtender : public BrowserExtender, // A toggle flag to show/hide the compact navigation bar. bool compact_navigation_bar_enabled_; + // CompactLocationBar view. + scoped_ptr<CompactLocationBar> compact_location_bar_; + DISALLOW_COPY_AND_ASSIGN(NormalExtender); }; @@ -275,6 +309,12 @@ class PopupExtender : public BrowserExtender { virtual void ToggleCompactNavigationBar() {} + virtual void OnMouseEnteredToTab(Tab* tab) {} + + virtual void OnMouseMovedOnTab(Tab* tab) {} + + virtual void OnMouseExitedFromTab(Tab* tab) {} + // Controls interactions with the window manager for popup panels. scoped_ptr<PanelController> panel_controller_; diff --git a/chrome/browser/chromeos/compact_location_bar.cc b/chrome/browser/chromeos/compact_location_bar.cc new file mode 100644 index 0000000..3405d1e --- /dev/null +++ b/chrome/browser/chromeos/compact_location_bar.cc @@ -0,0 +1,273 @@ +// 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/chromeos/compact_location_bar.h" + +#include <gtk/gtk.h> +#include <algorithm> + +#include "app/l10n_util.h" +#include "base/gfx/point.h" +#include "chrome/app/chrome_dll_resource.h" +#include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" +#include "chrome/browser/browser_list.h" +#include "chrome/browser/browser_theme_provider.h" +#include "chrome/browser/profile.h" +#include "chrome/browser/view_ids.h" +#include "chrome/browser/views/event_utils.h" +#include "chrome/browser/views/frame/browser_view.h" +#include "chrome/browser/views/tabs/tab.h" +#include "chrome/browser/views/tabs/tab_strip.h" +#include "grit/chromium_strings.h" +#include "grit/generated_resources.h" +#include "grit/theme_resources.h" +#include "views/background.h" +#include "views/controls/button/image_button.h" +#include "views/controls/native/native_view_host.h" +#include "views/widget/widget.h" + +const int kDefaultLocationBarWidth = 300; +const int kHideTimeoutInSeconds = 2; + +CompactLocationBar::CompactLocationBar(BrowserView* browser_view) + : browser_view_(browser_view), + current_contents_(NULL), + reload_(NULL) { + popup_timer_.reset(new base::OneShotTimer<CompactLocationBar>()); + set_background(views::Background::CreateStandardPanelBackground()); +} + +CompactLocationBar::~CompactLocationBar() { + if (popup_) { + // This is a hack to avoid deleting this twice. + // This problem will be gone once we eliminate a popup. + GetParent()->RemoveAllChildViews(false); + popup_->Close(); + popup_ = NULL; + } +} + +//////////////////////////////////////////////////////////////////////////////// +// CompactLocationBar public: + +void CompactLocationBar::StartPopupTimer() { + if (popup_ == NULL || !popup_->IsVisible()) + return; + if (popup_timer_->IsRunning()) { + // Restart the timer. + popup_timer_->Reset(); + } else { + popup_timer_->Start(base::TimeDelta::FromSeconds(kHideTimeoutInSeconds), + this, &CompactLocationBar::HidePopup); + } +} + +gfx::Rect CompactLocationBar::GetBoundsUnderTab(const Tab* tab) const { + // Get the position of the left-bottom corner of the tab on the screen + gfx::Point tab_left_bottom(0, tab->height()); + views::View::ConvertPointToScreen(tab, &tab_left_bottom); + // Get the position of the left edge of the window. + gfx::Point browser_left_top(0, 0); + views::View::ConvertPointToScreen(browser_view_, + &browser_left_top); + + // The compact location bar must be smaller than browser_width. + int width = std::min(browser_view_->width(), kDefaultLocationBarWidth); + + // Try to center around the tab, or align to the left of the window. + // TODO(oshima): handle RTL + int x = std::max(tab_left_bottom.x() - ((width - tab->width()) / 2), + browser_left_top.x()); + return gfx::Rect(x, tab_left_bottom.y(), width, 28); +} + +void CompactLocationBar::UpdateBounds(const Tab* tab) { + if (popup_ != NULL) + popup_->SetBounds(GetBoundsUnderTab(tab)); +} + +void CompactLocationBar::Update(const Tab* tab, const TabContents* contents) { + DCHECK(tab != NULL && contents != NULL); + if (current_contents_ == contents) { + StartPopupTimer(); + return; + } + CancelPopupTimer(); + HidePopup(); + + if (!popup_) { + popup_ = views::Widget::CreatePopupWidget( + views::Widget::Transparent, + views::Widget::AcceptEvents, + views::Widget::DeleteOnDestroy); + popup_->Init(NULL, GetBoundsUnderTab(tab)); + popup_->SetContentsView(this); + } else { + UpdateBounds(tab); + } + current_contents_ = contents; + location_entry_->Update(contents); + popup_->Show(); + // Set focus to the location entry. + location_entry_->SetFocus(); + + // Start popup timer. + StartPopupTimer(); +} + +//////////////////////////////////////////////////////////////////////////////// +// CompactLocationBar private: + +Browser* CompactLocationBar::browser() const { + return browser_view_->browser(); +} + +void CompactLocationBar::CancelPopupTimer() { + popup_timer_->Stop(); +} + +void CompactLocationBar::HidePopup() { + current_contents_ = NULL; + if (popup_) { + CancelPopupTimer(); + popup_->Hide(); + } +} + +void CompactLocationBar::Init() { + ThemeProvider* tp = browser()->profile()->GetThemeProvider(); + SkColor color = tp->GetColor(BrowserThemeProvider::COLOR_BUTTON_BACKGROUND); + SkBitmap* background = tp->GetBitmapNamed(IDR_THEME_BUTTON_BACKGROUND); + + // Reload button. + reload_ = new views::ImageButton(this); + reload_->set_tag(IDC_RELOAD); + reload_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_RELOAD)); + reload_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_RELOAD)); + reload_->SetID(VIEW_ID_RELOAD_BUTTON); + + reload_->SetImage(views::CustomButton::BS_NORMAL, + tp->GetBitmapNamed(IDR_RELOAD)); + reload_->SetImage(views::CustomButton::BS_HOT, + tp->GetBitmapNamed(IDR_RELOAD_H)); + reload_->SetImage(views::CustomButton::BS_PUSHED, + tp->GetBitmapNamed(IDR_RELOAD_P)); + reload_->SetBackground(color, background, + tp->GetBitmapNamed(IDR_BUTTON_MASK)); + + AddChildView(reload_); + + // Location bar. + location_entry_.reset(new AutocompleteEditViewGtk( + this, browser()->toolbar_model(), browser()->profile(), + browser()->command_updater(), false, this)); + + + location_entry_->Init(); + location_entry_->Update(browser()->GetSelectedTabContents()); + gtk_widget_show_all(location_entry_->widget()); + gtk_widget_hide(location_entry_->widget()); + + location_entry_view_ = new views::NativeViewHost; + AddChildView(location_entry_view_); + location_entry_view_->set_focus_view(this); + location_entry_view_->Attach(location_entry_->widget()); + + // TODO(oshima): Add Star Button + location_entry_->Update(browser()->GetSelectedTabContents()); +} + +//////////////////////////////////////////////////////////////////////////////// +// views::View overrides: + +gfx::Size CompactLocationBar::GetPreferredSize() { + if (!reload_) + return gfx::Size(); // Not initialized yet, do nothing. + + gfx::Size sz = reload_->GetPreferredSize(); + + return gfx::Size(500, sz.height()); +} + +void CompactLocationBar::Layout() { + if (!reload_) + return; // Not initialized yet, do nothing. + + int cur_x = 0; + + gfx::Size sz = reload_->GetPreferredSize(); + reload_->SetBounds(cur_x, 0, sz.width(), sz.height()); + cur_x += sz.width(); + + cur_x += 2; + + // The location bar gets the rest of the space in the middle. + location_entry_view_->SetBounds(cur_x, 0, width() - cur_x * 2 - 2, height()); + + cur_x = width() - sz.width(); +} + +void CompactLocationBar::Paint(gfx::Canvas* canvas) { + View::Paint(canvas); +} + +void CompactLocationBar::ViewHierarchyChanged(bool is_add, View* parent, + View* child) { + if (is_add && child == this) + Init(); +} + +void CompactLocationBar::OnMouseEntered(const views::MouseEvent& event) { + CancelPopupTimer(); +} + +void CompactLocationBar::OnMouseExited(const views::MouseEvent& event) { + StartPopupTimer(); +} + +//////////////////////////////////////////////////////////////////////////////// +// views::ButtonListener overrides: + +void CompactLocationBar::ButtonPressed(views::Button* sender, + const views::Event& event) { + int id = sender->tag(); + browser()->ExecuteCommandWithDisposition( + id, event_utils::DispositionFromEventFlags(sender->mouse_event_flags())); +} + +//////////////////////////////////////////////////////////////////////////////// +// AutocompleteEditController overrides: + +void CompactLocationBar::OnAutocompleteAccept( + const GURL& url, + WindowOpenDisposition disposition, + PageTransition::Type transition, + const GURL& alternate_nav_url) { + browser()->OpenURL(url, GURL(), disposition, transition); +} + +void CompactLocationBar::OnChanged() { + // Other one does "DoLayout" here. +} + +void CompactLocationBar::OnInputInProgress(bool in_progress) { +} + +SkBitmap CompactLocationBar::GetFavIcon() const { + return SkBitmap(); +} + +std::wstring CompactLocationBar::GetTitle() const { + return std::wstring(); +} + +//////////////////////////////////////////////////////////////////////////////// +// BubblePositioner overrides: + +gfx::Rect CompactLocationBar::GetLocationStackBounds() const { + gfx::Point lower_left(0, height()); + ConvertPointToScreen(this, &lower_left); + return gfx::Rect(lower_left.x(), lower_left.y(), 700, 100); +} + diff --git a/chrome/browser/chromeos/compact_location_bar.h b/chrome/browser/chromeos/compact_location_bar.h new file mode 100644 index 0000000..6d70e75 --- /dev/null +++ b/chrome/browser/chromeos/compact_location_bar.h @@ -0,0 +1,111 @@ +// 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_CHROMEOS_COMPACT_LOCATION_BAR_H_ +#define CHROME_BROWSER_CHROMEOS_COMPACT_LOCATION_BAR_H_ + +#include "base/basictypes.h" +#include "base/timer.h" +#include "chrome/browser/bubble_positioner.h" +#include "chrome/browser/autocomplete/autocomplete_edit.h" +#include "views/controls/button/button.h" +#include "views/view.h" + +class AutocompleteEditViewGtk; +class Browser; +class BrowserView; +class ToolbarStarToggleGtk; +class Tab; +class TabContents; +class TabStrip; + +namespace views { +class ImageButton; +class NativeViewHost; +} // namespace views + +// CompactLocationBar is a version of location bar that is shown under +// a tab for short priod of used when Chrome is in the compact +// navigation bar mode. +// TODO(oshima): re-implement w/o using a popup, like a FindBar. +class CompactLocationBar : public views::View, + public views::ButtonListener, + public AutocompleteEditController, + public BubblePositioner { + public: + explicit CompactLocationBar(BrowserView* browser_view); + ~CompactLocationBar(); + + // Returns the bounds to locale the compact location bar under the tab. + gfx::Rect GetBoundsUnderTab(const Tab* tab) const; + + // (Re)Starts the popup timer that hides the popup after X seconds. + void StartPopupTimer(); + + // Updates the content and the location of the compact location bar. + void Update(const Tab* tab, const TabContents* contents); + + // Updates the location of the location bar popup under the given tab. + void UpdateBounds(const Tab* tab); + + private: + Browser* browser() const; + + // Cancels the popup timer. + void CancelPopupTimer(); + + // Hides the popup window. + void HidePopup(); + + // Called when the view is added to the tree to initialize the + // CompactLocationBar. + void Init(); + + // Overridden from views::View. + virtual gfx::Size GetPreferredSize(); + virtual void Layout(); + virtual void Paint(gfx::Canvas* canvas); + virtual void ViewHierarchyChanged(bool is_add, views::View* parent, + views::View* child); + virtual void OnMouseEntered(const views::MouseEvent& event); + virtual void OnMouseExited(const views::MouseEvent& event); + + // Overridden from views::ButtonListener: + virtual void ButtonPressed(views::Button* sender, const views::Event& event); + + // AutocompleteEditController implementation. + virtual void OnAutocompleteAccept(const GURL& url, + WindowOpenDisposition disposition, + PageTransition::Type transition, + const GURL& alternate_nav_url); + virtual void OnChanged(); + virtual void OnKillFocus() {} + virtual void OnSetFocus() {} + virtual void OnInputInProgress(bool in_progress); + virtual SkBitmap GetFavIcon() const; + virtual std::wstring GetTitle() const; + + // BubblePositioner implementation. + virtual gfx::Rect GetLocationStackBounds() const; + + BrowserView* browser_view_; + const TabContents* current_contents_; + + views::ImageButton* reload_; + scoped_ptr<AutocompleteEditViewGtk> location_entry_; + views::NativeViewHost* location_entry_view_; + + // scoped_ptr<ToolbarStarToggleGtk> star_; + views::NativeViewHost* star_view_; + + scoped_ptr<base::OneShotTimer<CompactLocationBar> > popup_timer_; + + // A popup window to show the compact location bar. + views::Widget* popup_; + + DISALLOW_COPY_AND_ASSIGN(CompactLocationBar); +}; + +#endif // CHROME_BROWSER_CHROMEOS_COMPACT_LOCATION_BAR_H_ + diff --git a/chrome/browser/views/frame/browser_extender.cc b/chrome/browser/views/frame/browser_extender.cc index be9cb29..ff4a1d6 100644 --- a/chrome/browser/views/frame/browser_extender.cc +++ b/chrome/browser/views/frame/browser_extender.cc @@ -4,8 +4,6 @@ #include "chrome/browser/views/frame/browser_extender.h" -#include <algorithm> - #include "chrome/browser/views/frame/browser_view.h" //////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/views/frame/browser_extender.h b/chrome/browser/views/frame/browser_extender.h index 094bd2d..106f5c9 100644 --- a/chrome/browser/views/frame/browser_extender.h +++ b/chrome/browser/views/frame/browser_extender.h @@ -9,6 +9,7 @@ #include "base/gfx/rect.h" class BrowserView; +class Tab; namespace views { class Window; @@ -58,6 +59,15 @@ class BrowserExtender { // Toggles the visibility of CompactNavigationBar. virtual void ToggleCompactNavigationBar() = 0; + // Called when a mouse entered into the |tab|. + virtual void OnMouseEnteredToTab(Tab* tab) = 0; + + // Called when a mouse moved (hovered) on the |tab|. + virtual void OnMouseMovedOnTab(Tab* tab) = 0; + + // Called when a mouse exited from the |tab|. + virtual void OnMouseExitedFromTab(Tab* tab) = 0; + // Tells if the browser can be closed. bool can_close() const { return can_close_; diff --git a/chrome/browser/views/frame/standard_extender.cc b/chrome/browser/views/frame/standard_extender.cc index c7370b8..1fe41d1 100644 --- a/chrome/browser/views/frame/standard_extender.cc +++ b/chrome/browser/views/frame/standard_extender.cc @@ -4,6 +4,8 @@ #include "chrome/browser/views/frame/browser_extender.h" +class Tab; + namespace { // StandardExtender for non ChromeOS build. This currently adds/does nothing. @@ -26,6 +28,9 @@ class StandardExtender : public BrowserExtender { virtual void ActivationChanged() {} virtual bool ShouldForceHideToolbar() { return false; } virtual void ToggleCompactNavigationBar() {} + virtual void OnMouseEnteredToTab(Tab* tab) {} + virtual void OnMouseMovedOnTab(Tab* tab) {} + virtual void OnMouseExitedFromTab(Tab* tab) {} DISALLOW_COPY_AND_ASSIGN(StandardExtender); }; diff --git a/chrome/browser/views/tabs/tab.cc b/chrome/browser/views/tabs/tab.cc index f69ced8..7876ae2 100644 --- a/chrome/browser/views/tabs/tab.cc +++ b/chrome/browser/views/tabs/tab.cc @@ -11,6 +11,9 @@ #include "app/resource_bundle.h" #include "base/compiler_specific.h" #include "base/gfx/size.h" +#include "chrome/browser/views/frame/browser_extender.h" +#include "chrome/browser/views/frame/browser_view.h" +#include "chrome/browser/views/tabs/tab_strip.h" #include "grit/generated_resources.h" #include "views/controls/menu/simple_menu_model.h" #include "views/widget/tooltip_manager.h" @@ -155,8 +158,14 @@ bool Tab::OnMousePressed(const views::MouseEvent& event) { // able to drag foreground tabs, so we don't start dragging the tab if // it was in the background. bool just_selected = !IsSelected(); - if (just_selected) + if (just_selected) { delegate_->SelectTab(this); + // This is a hack to update the compact location bar when the tab + // is selected. This is just an experiement and will be modified later. + // TODO(oshima): Improve the BrowserExtender interface if we + // decided to keep this UI, or remove this otherwise. + GetBrowserExtender()->OnMouseEnteredToTab(this); + } delegate_->MaybeStartDrag(this, event); } return true; @@ -183,6 +192,18 @@ void Tab::OnMouseReleased(const views::MouseEvent& event, bool canceled) { delegate_->CloseTab(this); } +void Tab::OnMouseEntered(const views::MouseEvent& event) { + GetBrowserExtender()->OnMouseEnteredToTab(this); +} + +void Tab::OnMouseMoved(const views::MouseEvent& event) { + GetBrowserExtender()->OnMouseMovedOnTab(this); +} + +void Tab::OnMouseExited(const views::MouseEvent& event) { + GetBrowserExtender()->OnMouseExitedFromTab(this); +} + bool Tab::GetTooltipText(int x, int y, std::wstring* tooltip) { std::wstring title = GetTitle(); if (!title.empty()) { @@ -236,6 +257,17 @@ void Tab::ButtonPressed(views::Button* sender, const views::Event& event) { /////////////////////////////////////////////////////////////////////////////// // Tab, private: +BrowserExtender* Tab::GetBrowserExtender() { + // This is a hack to BrowserExtender from a Tab. + // TODO(oshima): Fix when the decision on compact location bar is made. + // Potential candidates are: + // * Use View ID with a cached reference to BrowserView. + // * Pass the BrowserView reference to Tabs. + // * Add GetBrowserView method to Delegate. + TabStrip* tab_strip = static_cast<TabStrip*>(delegate_); + return static_cast<BrowserView*>(tab_strip->GetParent())->browser_extender(); +} + void Tab::MakePathForTab(gfx::Path* path) const { DCHECK(path); diff --git a/chrome/browser/views/tabs/tab.h b/chrome/browser/views/tabs/tab.h index a7a8d91..e543ea3 100644 --- a/chrome/browser/views/tabs/tab.h +++ b/chrome/browser/views/tabs/tab.h @@ -12,8 +12,7 @@ namespace gfx { class Path; class Point; } -class TabContents; -class Profile; +class BrowserExtender; /////////////////////////////////////////////////////////////////////////////// // @@ -96,6 +95,9 @@ class Tab : public TabRenderer, virtual bool OnMouseDragged(const views::MouseEvent& event); virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled); + virtual void OnMouseEntered(const views::MouseEvent& event); + virtual void OnMouseMoved(const views::MouseEvent& event); + virtual void OnMouseExited(const views::MouseEvent& event); virtual bool GetTooltipText(int x, int y, std::wstring* tooltip); virtual bool GetTooltipTextOrigin(int x, int y, gfx::Point* origin); virtual std::string GetClassName() const { return kTabClassName; } @@ -111,6 +113,9 @@ class Tab : public TabRenderer, // views::ButtonListener overrides: virtual void ButtonPressed(views::Button* sender, const views::Event& event); + // Returns the BrowserExtender of the window that this tab belongs to. + BrowserExtender* GetBrowserExtender(); + // Creates a path that contains the clickable region of the tab's visual // representation. Used by GetViewForPoint for hit-testing. void MakePathForTab(gfx::Path* path) const; diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc index dfdb2be..e70c88c 100644 --- a/chrome/browser/views/tabs/tab_strip.cc +++ b/chrome/browser/views/tabs/tab_strip.cc @@ -772,6 +772,10 @@ gfx::Rect TabStrip::GetIdealBounds(int index) { return tab_data_.at(index).ideal_bounds; } +Tab* TabStrip::GetSelectedTab() const { + return GetTabAtAdjustForAnimation(model()->selected_index()); +} + void TabStrip::InitTabStripButtons() { newtab_button_ = new NewTabButton(this); LoadNewTabButtonImage(); @@ -1320,7 +1324,6 @@ void TabStrip::DidProcessEvent(GdkEvent* event) { //////////////////////////////////////////////////////////////////////////////// // TabStrip, TabStripWrapper implementation: - int TabStrip::GetPreferredHeight() { return GetPreferredSize().height(); } diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h index 6d6ec7a..659d015 100644 --- a/chrome/browser/views/tabs/tab_strip.h +++ b/chrome/browser/views/tabs/tab_strip.h @@ -13,6 +13,7 @@ #include "views/controls/button/image_button.h" #include "views/view.h" +class BrowserExtender; class DraggedTabController; class ScopedMouseCloseWidthCalculator; class TabStripModel; @@ -55,7 +56,7 @@ class TabStrip : public views::View, bool CanProcessInputEvents() const; // Accessors for the model and individual Tabs. - TabStripModel* model() { return model_; } + TabStripModel* model() const { return model_; } // Destroys the active drag controller. void DestroyDragController(); @@ -66,6 +67,9 @@ class TabStrip : public views::View, // Retrieve the ideal bounds for the Tab at the specified index. gfx::Rect GetIdealBounds(int index); + // Returns the currently selected tab. + Tab* GetSelectedTab() const; + // Create the new tab button. void InitTabStripButtons(); diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index c835772..13a3f24 100755 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -961,6 +961,8 @@ 'browser/chromeos/chromeos_version_loader.h', 'browser/chromeos/clock_menu_button.cc', 'browser/chromeos/clock_menu_button.h', + 'browser/chromeos/compact_location_bar.cc', + 'browser/chromeos/compact_location_bar.h', 'browser/chromeos/compact_navigation_bar.cc', 'browser/chromeos/compact_navigation_bar.h', 'browser/chromeos/cros_library.cc', @@ -2639,8 +2641,6 @@ 'browser/password_manager/password_store_kwallet.h', 'browser/password_manager/password_store_kwallet.cc', 'browser/power_save_blocker_stub.cc', - 'browser/views/compact_navigation_bar.cc', - 'browser/views/compact_navigation_bar.h', 'browser/views/new_browser_window_widget.cc', 'browser/views/new_browser_window_widget.h', 'browser/views/panel_controller.cc', |