summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-05 19:13:44 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-05 19:13:44 +0000
commitab861b4d129b7dfc67ab7b1dc8ccfbacff3dde17 (patch)
treeb0b97b6a1427ff1b8c853c11dcfadf63f3b90bb4 /chrome/browser
parentac3fa8e2ef53e83b113d726209525f4af4aa46f1 (diff)
downloadchromium_src-ab861b4d129b7dfc67ab7b1dc8ccfbacff3dde17.zip
chromium_src-ab861b4d129b7dfc67ab7b1dc8ccfbacff3dde17.tar.gz
chromium_src-ab861b4d129b7dfc67ab7b1dc8ccfbacff3dde17.tar.bz2
This CL adds support for displaying Chrome InfoBars in pages rendered via ChromeFrame. To achieve this
the ExternalTabContainer now creates a view which comprises of the InfoBarContainer and the TabContentsContainer view. It uses the GridLayout manager to layout this view. The InfoBarContainer no longer depends on the BrowserView. It now passes notifications to the InfoBarContainerDelegate interface which is implemented by the BrowserView and the ExternalTabContainer. Fixes bug http://code.google.com/p/chromium/issues/detail?id=24051 Bug=24051 Review URL: http://codereview.chromium.org/573022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38228 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/external_tab_container.cc51
-rw-r--r--chrome/browser/external_tab_container.h10
-rw-r--r--chrome/browser/views/frame/browser_view.cc4
-rw-r--r--chrome/browser/views/frame/browser_view.h8
-rw-r--r--chrome/browser/views/infobars/infobar_container.cc27
-rw-r--r--chrome/browser/views/infobars/infobar_container.h14
6 files changed, 88 insertions, 26 deletions
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc
index 6e89fcd..993411c 100644
--- a/chrome/browser/external_tab_container.cc
+++ b/chrome/browser/external_tab_container.cc
@@ -30,6 +30,8 @@
#include "chrome/common/notification_service.h"
#include "chrome/test/automation/automation_messages.h"
#include "grit/generated_resources.h"
+#include "views/grid_layout.h"
+#include "views/widget/root_view.h"
#include "views/window/window.h"
static const wchar_t kWindowObjectKey[] = L"ChromeWindowObject";
@@ -105,14 +107,6 @@ bool ExternalTabContainer::Init(Profile* profile,
BindingsPolicy::EXTERNAL_HOST);
}
- // Create a TabContentsContainer to handle focus cycling using Tab and
- // Shift-Tab.
- tab_contents_container_ = new TabContentsContainer;
- SetContentsView(tab_contents_container_);
-
- // Note that SetTabContents must be called after AddChildView is called
- tab_contents_container_->ChangeTabContents(tab_contents_);
-
NavigationController* controller = &tab_contents_->controller();
registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
Source<NavigationController>(controller));
@@ -156,6 +150,7 @@ bool ExternalTabContainer::Init(Profile* profile,
disabled_context_menu_ids_.push_back(
IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD);
LoadAccelerators();
+ SetupExternalTabView();
return true;
}
@@ -201,6 +196,7 @@ void ExternalTabContainer::Uninitialize() {
}
request_context_ = NULL;
+ tab_contents_container_ = NULL;
}
bool ExternalTabContainer::Reinitialize(
@@ -759,6 +755,12 @@ void ExternalTabContainer::SetEnableExtensionAutomation(
}
}
+void ExternalTabContainer::InfoBarSizeChanged(bool is_animating) {
+ if (GetRootView()) {
+ GetRootView()->Layout();
+ }
+}
+
// ExternalTabContainer instances do not have a window.
views::Window* ExternalTabContainer::GetWindow() {
return NULL;
@@ -887,3 +889,36 @@ void ExternalTabContainer::ServicePendingOpenURLRequests() {
pending_open_url_requests_.clear();
}
+void ExternalTabContainer::SetupExternalTabView() {
+ // Create a TabContentsContainer to handle focus cycling using Tab and
+ // Shift-Tab.
+ tab_contents_container_ = new TabContentsContainer;
+
+ // The views created here will be destroyed when the ExternalTabContainer
+ // widget is torn down.
+ views::View* external_tab_view = new views::View();
+
+ InfoBarContainer* info_bar_container = new InfoBarContainer(this);
+ info_bar_container->ChangeTabContents(tab_contents_);
+
+ views::GridLayout* layout = new views::GridLayout(external_tab_view);
+ views::ColumnSet* columns = layout->AddColumnSet(0); // Give this column an
+ // identifier of 0.
+ columns->AddColumn(views::GridLayout::FILL,
+ views::GridLayout::FILL,
+ 1,
+ views::GridLayout::USE_PREF,
+ 0,
+ 0);
+
+ external_tab_view->SetLayoutManager(layout);
+
+ layout->StartRow(0, 0);
+ layout->AddView(info_bar_container);
+ layout->StartRow(1, 0);
+ layout->AddView(tab_contents_container_);
+ SetContentsView(external_tab_view);
+ // Note that SetTabContents must be called after AddChildView is called
+ tab_contents_container_->ChangeTabContents(tab_contents_);
+}
+
diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h
index f875e66..0cfdd49 100644
--- a/chrome/browser/external_tab_container.h
+++ b/chrome/browser/external_tab_container.h
@@ -13,6 +13,7 @@
#include "chrome/browser/browser.h"
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
+#include "chrome/browser/views/infobars/infobar_container.h"
#include "chrome/browser/views/unhandled_keyboard_event_handler.h"
#include "chrome/common/navigation_types.h"
#include "chrome/common/notification_observer.h"
@@ -37,7 +38,8 @@ class ExternalTabContainer : public TabContentsDelegate,
public NotificationObserver,
public views::WidgetWin,
public base::RefCounted<ExternalTabContainer>,
- public views::AcceleratorTarget {
+ public views::AcceleratorTarget,
+ public InfoBarContainer::Delegate {
public:
typedef std::map<intptr_t, scoped_refptr<ExternalTabContainer> > PendingTabs;
@@ -183,6 +185,9 @@ class ExternalTabContainer : public TabContentsDelegate,
pending_ = pending;
}
+ // InfoBarContainer::Delegate overrides
+ virtual void InfoBarSizeChanged(bool is_animating);
+
protected:
// Overridden from views::WidgetWin:
virtual LRESULT OnCreate(LPCREATESTRUCT create_struct);
@@ -231,6 +236,9 @@ class ExternalTabContainer : public TabContentsDelegate,
// Scheduled as a task in ExternalTabContainer::Reinitialize
void OnReinitialize();
+ // Creates and initializes the view hierarchy for this ExternalTabContainer.
+ void SetupExternalTabView();
+
TabContents* tab_contents_;
scoped_refptr<AutomationProvider> automation_;
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index caa6224..f7c6429 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -1594,6 +1594,10 @@ void BrowserView::SetAccessibleName(const std::wstring& name) {
accessible_name_ = name;
}
+void BrowserView::InfoBarSizeChanged(bool is_animating) {
+ SelectedTabToolbarSizeChanged(is_animating);
+}
+
views::LayoutManager* BrowserView::CreateLayoutManager() const {
return new BrowserViewLayout;
}
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index c2f73cc..5bcfcd1 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -18,6 +18,8 @@
#include "chrome/browser/browser_window.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/views/frame/browser_frame.h"
+#include "chrome/browser/views/infobars/infobar_container.h"
+#include "chrome/browser/views/tabs/tab_strip.h"
#include "chrome/browser/views/tabs/base_tab_strip.h"
#include "chrome/browser/views/unhandled_keyboard_event_handler.h"
#include "views/window/client_view.h"
@@ -71,7 +73,8 @@ class BrowserView : public BrowserWindow,
public TabStripModelObserver,
public menus::SimpleMenuModel::Delegate,
public views::WindowDelegate,
- public views::ClientView {
+ public views::ClientView,
+ public InfoBarContainer::Delegate {
public:
// The browser view's class name.
static const char kViewClassName[];
@@ -362,6 +365,9 @@ class BrowserView : public BrowserWindow,
virtual bool GetAccessibleName(std::wstring* name);
virtual void SetAccessibleName(const std::wstring& name);
+ // InfoBarContainer::Delegate overrides
+ virtual void InfoBarSizeChanged(bool is_animating);
+
// Returns BrowserExtender.
BrowserExtender* browser_extender() const {
return browser_extender_.get();
diff --git a/chrome/browser/views/infobars/infobar_container.cc b/chrome/browser/views/infobars/infobar_container.cc
index 3e91d36..cea200a 100644
--- a/chrome/browser/views/infobars/infobar_container.cc
+++ b/chrome/browser/views/infobars/infobar_container.cc
@@ -7,23 +7,22 @@
#include "chrome/browser/tab_contents/infobar_delegate.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/view_ids.h"
-#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/infobars/infobars.h"
#include "chrome/common/notification_service.h"
// InfoBarContainer, public: ---------------------------------------------------
-InfoBarContainer::InfoBarContainer(BrowserView* browser_view)
- : browser_view_(browser_view),
+InfoBarContainer::InfoBarContainer(Delegate* delegate)
+ : delegate_(delegate),
tab_contents_(NULL) {
SetID(VIEW_ID_INFO_BAR_CONTAINER);
}
InfoBarContainer::~InfoBarContainer() {
// We NULL this pointer before resetting the TabContents to prevent view
- // hierarchy modifications from attempting to adjust the BrowserView, which is
- // in the process of shutting down.
- browser_view_ = NULL;
+ // hierarchy modifications from attempting to resize the delegate which
+ // could be in the process of shutting down.
+ delegate_ = NULL;
ChangeTabContents(NULL);
}
@@ -46,8 +45,8 @@ void InfoBarContainer::ChangeTabContents(TabContents* contents) {
}
void InfoBarContainer::InfoBarAnimated(bool completed) {
- if (browser_view_)
- browser_view_->SelectedTabToolbarSizeChanged(!completed);
+ if (delegate_)
+ delegate_->InfoBarSizeChanged(!completed);
}
void InfoBarContainer::RemoveDelegate(InfoBarDelegate* delegate) {
@@ -58,7 +57,7 @@ void InfoBarContainer::RemoveDelegate(InfoBarDelegate* delegate) {
gfx::Size InfoBarContainer::GetPreferredSize() {
// We do not have a preferred width (we will expand to fit the available width
- // of the BrowserView). Our preferred height is the sum of the preferred
+ // of the delegate). Our preferred height is the sum of the preferred
// heights of the InfoBars contained within us.
int height = 0;
for (int i = 0; i < GetChildViewCount(); ++i)
@@ -100,10 +99,12 @@ void InfoBarContainer::SetAccessibleName(const std::wstring& name) {
void InfoBarContainer::ViewHierarchyChanged(bool is_add,
views::View* parent,
views::View* child) {
- if (parent == this && child->GetParent() == this && browser_view_) {
- // An InfoBar child was added or removed. Tell the BrowserView it needs to
- // re-layout since our preferred size will have changed.
- browser_view_->SelectedTabToolbarSizeChanged(false);
+ if (parent == this && child->GetParent() == this) {
+ if (delegate_) {
+ // An InfoBar child was added or removed. Tell the delegate it needs to
+ // re-layout since our preferred size will have changed.
+ delegate_->InfoBarSizeChanged(false);
+ }
}
}
diff --git a/chrome/browser/views/infobars/infobar_container.h b/chrome/browser/views/infobars/infobar_container.h
index c114c5c..c71f5b9 100644
--- a/chrome/browser/views/infobars/infobar_container.h
+++ b/chrome/browser/views/infobars/infobar_container.h
@@ -17,7 +17,15 @@ class TabContents;
class InfoBarContainer : public views::View,
public NotificationObserver {
public:
- explicit InfoBarContainer(BrowserView* browser_view);
+ // Implement this interface when you want to receive notifications from the
+ // InfoBarContainer
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+ virtual void InfoBarSizeChanged(bool is_animating) = 0;
+ };
+
+ explicit InfoBarContainer(Delegate* delegate);
virtual ~InfoBarContainer();
// Changes the TabContents for which this container is showing InfoBars. Can
@@ -73,8 +81,8 @@ class InfoBarContainer : public views::View,
NotificationRegistrar registrar_;
- // The BrowserView that hosts this InfoBarContainer.
- BrowserView* browser_view_;
+ // The Delegate which receives notifications from the InfoBarContainer.
+ Delegate* delegate_;
// The TabContents for which we are currently showing InfoBars.
TabContents* tab_contents_;