Commit 45da6c72 authored by oshima@chromium.org's avatar oshima@chromium.org

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
parent 799c8ef9
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "app/theme_provider.h" #include "app/theme_provider.h"
#include "chrome/app/chrome_dll_resource.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/compact_navigation_bar.h"
#include "chrome/browser/chromeos/main_menu.h" #include "chrome/browser/chromeos/main_menu.h"
#include "chrome/browser/chromeos/status_area_view.h" #include "chrome/browser/chromeos/status_area_view.h"
...@@ -14,6 +15,8 @@ ...@@ -14,6 +15,8 @@
#include "chrome/browser/views/frame/browser_frame_gtk.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.h"
#include "chrome/browser/views/tabs/tab_overview_types.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 "chrome/browser/views/toolbar_view.h"
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
#include "grit/theme_resources.h" #include "grit/theme_resources.h"
...@@ -60,6 +63,7 @@ class NormalExtender : public BrowserExtender, ...@@ -60,6 +63,7 @@ class NormalExtender : public BrowserExtender,
main_menu_->SetImage(views::CustomButton::BS_PUSHED, image); main_menu_->SetImage(views::CustomButton::BS_PUSHED, image);
browser_view()->AddChildView(main_menu_); browser_view()->AddChildView(main_menu_);
compact_location_bar_.reset(new CompactLocationBar(browser_view()));
compact_navigation_bar_ = compact_navigation_bar_ =
new CompactNavigationBar(browser_view()->browser()); new CompactNavigationBar(browser_view()->browser());
browser_view()->AddChildView(compact_navigation_bar_); browser_view()->AddChildView(compact_navigation_bar_);
...@@ -96,6 +100,12 @@ class NormalExtender : public BrowserExtender, ...@@ -96,6 +100,12 @@ class NormalExtender : public BrowserExtender,
status_area_->SetVisible(true); 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. // Layout main menu before tab strip.
gfx::Size main_menu_size = main_menu_->GetPreferredSize(); gfx::Size main_menu_size = main_menu_->GetPreferredSize();
main_menu_->SetBounds(bounds.x(), bounds.y(), main_menu_->SetBounds(bounds.x(), bounds.y(),
...@@ -164,7 +174,28 @@ class NormalExtender : public BrowserExtender, ...@@ -164,7 +174,28 @@ class NormalExtender : public BrowserExtender,
compact_navigation_bar_enabled_ = !compact_navigation_bar_enabled_; 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: 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. // Creates system menu.
void InitSystemMenu() { void InitSystemMenu() {
system_menu_contents_.reset(new views::SimpleMenuModel(browser_view())); system_menu_contents_.reset(new views::SimpleMenuModel(browser_view()));
...@@ -196,7 +227,7 @@ class NormalExtender : public BrowserExtender, ...@@ -196,7 +227,7 @@ class NormalExtender : public BrowserExtender,
// Status Area view. // Status Area view.
StatusAreaView* status_area_; StatusAreaView* status_area_;
// System menus // System menus.
scoped_ptr<views::SimpleMenuModel> system_menu_contents_; scoped_ptr<views::SimpleMenuModel> system_menu_contents_;
scoped_ptr<views::Menu2> system_menu_menu_; scoped_ptr<views::Menu2> system_menu_menu_;
...@@ -206,6 +237,9 @@ class NormalExtender : public BrowserExtender, ...@@ -206,6 +237,9 @@ class NormalExtender : public BrowserExtender,
// A toggle flag to show/hide the compact navigation bar. // A toggle flag to show/hide the compact navigation bar.
bool compact_navigation_bar_enabled_; bool compact_navigation_bar_enabled_;
// CompactLocationBar view.
scoped_ptr<CompactLocationBar> compact_location_bar_;
DISALLOW_COPY_AND_ASSIGN(NormalExtender); DISALLOW_COPY_AND_ASSIGN(NormalExtender);
}; };
...@@ -275,6 +309,12 @@ class PopupExtender : public BrowserExtender { ...@@ -275,6 +309,12 @@ class PopupExtender : public BrowserExtender {
virtual void ToggleCompactNavigationBar() {} 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. // Controls interactions with the window manager for popup panels.
scoped_ptr<PanelController> panel_controller_; scoped_ptr<PanelController> panel_controller_;
......
// 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);
}
// 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_
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include "chrome/browser/views/frame/browser_extender.h" #include "chrome/browser/views/frame/browser_extender.h"
#include <algorithm>
#include "chrome/browser/views/frame/browser_view.h" #include "chrome/browser/views/frame/browser_view.h"
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/gfx/rect.h" #include "base/gfx/rect.h"
class BrowserView; class BrowserView;
class Tab;
namespace views { namespace views {
class Window; class Window;
...@@ -58,6 +59,15 @@ class BrowserExtender { ...@@ -58,6 +59,15 @@ class BrowserExtender {
// Toggles the visibility of CompactNavigationBar. // Toggles the visibility of CompactNavigationBar.
virtual void ToggleCompactNavigationBar() = 0; 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. // Tells if the browser can be closed.
bool can_close() const { bool can_close() const {
return can_close_; return can_close_;
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "chrome/browser/views/frame/browser_extender.h" #include "chrome/browser/views/frame/browser_extender.h"
class Tab;
namespace { namespace {
// StandardExtender for non ChromeOS build. This currently adds/does nothing. // StandardExtender for non ChromeOS build. This currently adds/does nothing.
...@@ -26,6 +28,9 @@ class StandardExtender : public BrowserExtender { ...@@ -26,6 +28,9 @@ class StandardExtender : public BrowserExtender {
virtual void ActivationChanged() {} virtual void ActivationChanged() {}
virtual bool ShouldForceHideToolbar() { return false; } virtual bool ShouldForceHideToolbar() { return false; }
virtual void ToggleCompactNavigationBar() {} virtual void ToggleCompactNavigationBar() {}
virtual void OnMouseEnteredToTab(Tab* tab) {}
virtual void OnMouseMovedOnTab(Tab* tab) {}
virtual void OnMouseExitedFromTab(Tab* tab) {}
DISALLOW_COPY_AND_ASSIGN(StandardExtender); DISALLOW_COPY_AND_ASSIGN(StandardExtender);
}; };
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
#include "app/resource_bundle.h" #include "app/resource_bundle.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/gfx/size.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 "grit/generated_resources.h"
#include "views/controls/menu/simple_menu_model.h" #include "views/controls/menu/simple_menu_model.h"
#include "views/widget/tooltip_manager.h" #include "views/widget/tooltip_manager.h"
...@@ -155,8 +158,14 @@ bool Tab::OnMousePressed(const views::MouseEvent& event) { ...@@ -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 // able to drag foreground tabs, so we don't start dragging the tab if
// it was in the background. // it was in the background.
bool just_selected = !IsSelected(); bool just_selected = !IsSelected();
if (just_selected) if (just_selected) {
delegate_->SelectTab(this); 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); delegate_->MaybeStartDrag(this, event);
} }
return true; return true;
...@@ -183,6 +192,18 @@ void Tab::OnMouseReleased(const views::MouseEvent& event, bool canceled) { ...@@ -183,6 +192,18 @@ void Tab::OnMouseReleased(const views::MouseEvent& event, bool canceled) {
delegate_->CloseTab(this); 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) { bool Tab::GetTooltipText(int x, int y, std::wstring* tooltip) {
std::wstring title = GetTitle(); std::wstring title = GetTitle();
if (!title.empty()) { if (!title.empty()) {
...@@ -236,6 +257,17 @@ void Tab::ButtonPressed(views::Button* sender, const views::Event& event) { ...@@ -236,6 +257,17 @@ void Tab::ButtonPressed(views::Button* sender, const views::Event& event) {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Tab, private: // 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 { void Tab::MakePathForTab(gfx::Path* path) const {
DCHECK(path); DCHECK(path);
......
...@@ -12,8 +12,7 @@ namespace gfx { ...@@ -12,8 +12,7 @@ namespace gfx {
class Path; class Path;
class Point; class Point;
} }
class TabContents; class BrowserExtender;
class Profile;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
...@@ -96,6 +95,9 @@ class Tab : public TabRenderer, ...@@ -96,6 +95,9 @@ class Tab : public TabRenderer,
virtual bool OnMouseDragged(const views::MouseEvent& event); virtual bool OnMouseDragged(const views::MouseEvent& event);
virtual void OnMouseReleased(const views::MouseEvent& event, virtual void OnMouseReleased(const views::MouseEvent& event,
bool canceled); 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 GetTooltipText(int x, int y, std::wstring* tooltip);
virtual bool GetTooltipTextOrigin(int x, int y, gfx::Point* origin); virtual bool GetTooltipTextOrigin(int x, int y, gfx::Point* origin);
virtual std::string GetClassName() const { return kTabClassName; } virtual std::string GetClassName() const { return kTabClassName; }
...@@ -111,6 +113,9 @@ class Tab : public TabRenderer, ...@@ -111,6 +113,9 @@ class Tab : public TabRenderer,
// views::ButtonListener overrides: // views::ButtonListener overrides:
virtual void ButtonPressed(views::Button* sender, const views::Event& event); 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 // Creates a path that contains the clickable region of the tab's visual
// representation. Used by GetViewForPoint for hit-testing. // representation. Used by GetViewForPoint for hit-testing.
void MakePathForTab(gfx::Path* path) const; void MakePathForTab(gfx::Path* path) const;
......
...@@ -772,6 +772,10 @@ gfx::Rect TabStrip::GetIdealBounds(int index) { ...@@ -772,6 +772,10 @@ gfx::Rect TabStrip::GetIdealBounds(int index) {
return tab_data_.at(index).ideal_bounds; return tab_data_.at(index).ideal_bounds;
} }
Tab* TabStrip::GetSelectedTab() const {
return GetTabAtAdjustForAnimation(model()->selected_index());
}
void TabStrip::InitTabStripButtons() { void TabStrip::InitTabStripButtons() {
newtab_button_ = new NewTabButton(this); newtab_button_ = new NewTabButton(this);
LoadNewTabButtonImage(); LoadNewTabButtonImage();
...@@ -1320,7 +1324,6 @@ void TabStrip::DidProcessEvent(GdkEvent* event) { ...@@ -1320,7 +1324,6 @@ void TabStrip::DidProcessEvent(GdkEvent* event) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// TabStrip, TabStripWrapper implementation: // TabStrip, TabStripWrapper implementation:
int TabStrip::GetPreferredHeight() { int TabStrip::GetPreferredHeight() {
return GetPreferredSize().height(); return GetPreferredSize().height();
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "views/controls/button/image_button.h" #include "views/controls/button/image_button.h"
#include "views/view.h" #include "views/view.h"
class BrowserExtender;
class DraggedTabController; class DraggedTabController;
class ScopedMouseCloseWidthCalculator; class ScopedMouseCloseWidthCalculator;
class TabStripModel; class TabStripModel;
...@@ -55,7 +56,7 @@ class TabStrip : public views::View, ...@@ -55,7 +56,7 @@ class TabStrip : public views::View,
bool CanProcessInputEvents() const; bool CanProcessInputEvents() const;
// Accessors for the model and individual Tabs. // Accessors for the model and individual Tabs.
TabStripModel* model() { return model_; } TabStripModel* model() const { return model_; }
// Destroys the active drag controller. // Destroys the active drag controller.
void DestroyDragController(); void DestroyDragController();
...@@ -66,6 +67,9 @@ class TabStrip : public views::View, ...@@ -66,6 +67,9 @@ class TabStrip : public views::View,
// Retrieve the ideal bounds for the Tab at the specified index. // Retrieve the ideal bounds for the Tab at the specified index.
gfx::Rect GetIdealBounds(int index); gfx::Rect GetIdealBounds(int index);
// Returns the currently selected tab.
Tab* GetSelectedTab() const;
// Create the new tab button. // Create the new tab button.
void InitTabStripButtons(); void InitTabStripButtons();
......
...@@ -961,6 +961,8 @@ ...@@ -961,6 +961,8 @@
'browser/chromeos/chromeos_version_loader.h', 'browser/chromeos/chromeos_version_loader.h',
'browser/chromeos/clock_menu_button.cc', 'browser/chromeos/clock_menu_button.cc',
'browser/chromeos/clock_menu_button.h', '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.cc',
'browser/chromeos/compact_navigation_bar.h', 'browser/chromeos/compact_navigation_bar.h',
'browser/chromeos/cros_library.cc', 'browser/chromeos/cros_library.cc',
...@@ -2639,8 +2641,6 @@ ...@@ -2639,8 +2641,6 @@
'browser/password_manager/password_store_kwallet.h', 'browser/password_manager/password_store_kwallet.h',
'browser/password_manager/password_store_kwallet.cc', 'browser/password_manager/password_store_kwallet.cc',
'browser/power_save_blocker_stub.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.cc',
'browser/views/new_browser_window_widget.h', 'browser/views/new_browser_window_widget.h',
'browser/views/panel_controller.cc', 'browser/views/panel_controller.cc',
......
...@@ -1384,7 +1384,7 @@ int View::GetLineScrollIncrement(ScrollView* scroll_view, ...@@ -1384,7 +1384,7 @@ int View::GetLineScrollIncrement(ScrollView* scroll_view,
return 0; return 0;
} }
ThemeProvider* View::GetThemeProvider() { ThemeProvider* View::GetThemeProvider() const {
Widget* widget = GetWidget(); Widget* widget = GetWidget();
return widget ? widget->GetThemeProvider() : NULL; return widget ? widget->GetThemeProvider() : NULL;
} }
......
...@@ -936,7 +936,7 @@ class View : public AcceleratorTarget { ...@@ -936,7 +936,7 @@ class View : public AcceleratorTarget {
bool is_horizontal, bool is_positive); bool is_horizontal, bool is_positive);
// Get the theme provider from the parent widget. // Get the theme provider from the parent widget.
ThemeProvider* GetThemeProvider(); ThemeProvider* GetThemeProvider() const;
protected: protected:
// The id of this View. Used to find this View. // The id of this View. Used to find this View.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment