summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/automation/automation_provider_win.cc2
-rw-r--r--chrome/browser/external_tab_container.cc14
-rw-r--r--chrome/browser/external_tab_container.h8
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc14
-rw-r--r--chrome/browser/tab_contents/tab_contents_delegate.h3
5 files changed, 36 insertions, 5 deletions
diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc
index 9539498..c352018 100644
--- a/chrome/browser/automation/automation_provider_win.cc
+++ b/chrome/browser/automation/automation_provider_win.cc
@@ -325,7 +325,7 @@ void AutomationProvider::CreateExternalTab(
external_tab_container->Init(profile, settings.parent, settings.dimensions,
settings.style, settings.load_requests_via_automation,
settings.handle_top_level_requests, NULL, settings.initial_url,
- settings.referrer);
+ settings.referrer, settings.infobars_enabled);
if (AddExternalTab(external_tab_container)) {
TabContents* tab_contents = external_tab_container->tab_contents();
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc
index e6d1211..4c46493 100644
--- a/chrome/browser/external_tab_container.cc
+++ b/chrome/browser/external_tab_container.cc
@@ -54,7 +54,8 @@ ExternalTabContainer::ExternalTabContainer(
external_method_factory_(this),
enabled_extension_automation_(false),
waiting_for_unload_event_(false),
- pending_(false) {
+ pending_(false),
+ infobars_enabled_(true) {
}
ExternalTabContainer::~ExternalTabContainer() {
@@ -69,7 +70,8 @@ bool ExternalTabContainer::Init(Profile* profile,
bool handle_top_level_requests,
TabContents* existing_contents,
const GURL& initial_url,
- const GURL& referrer) {
+ const GURL& referrer,
+ bool infobars_enabled) {
if (IsWindow()) {
NOTREACHED();
return false;
@@ -77,6 +79,7 @@ bool ExternalTabContainer::Init(Profile* profile,
load_requests_via_automation_ = load_requests_via_automation;
handle_top_level_requests_ = handle_top_level_requests;
+ infobars_enabled_ = infobars_enabled;
set_window_style(WS_POPUP | WS_CLIPCHILDREN);
views::WidgetWin::Init(NULL, bounds);
@@ -351,7 +354,8 @@ void ExternalTabContainer::AddNewContents(TabContents* source,
handle_top_level_requests_,
new_contents,
GURL(),
- GURL());
+ GURL(),
+ true);
if (result) {
uintptr_t cookie = reinterpret_cast<uintptr_t>(new_container.get());
@@ -379,6 +383,10 @@ void ExternalTabContainer::TabContentsCreated(TabContents* new_contents) {
RegisterRenderViewHostForAutomation(rvh, true);
}
+bool ExternalTabContainer::infobars_enabled() {
+ return infobars_enabled_;
+}
+
void ExternalTabContainer::ActivateContents(TabContents* contents) {
}
diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h
index 123d13c..dcf30ee 100644
--- a/chrome/browser/external_tab_container.h
+++ b/chrome/browser/external_tab_container.h
@@ -65,7 +65,8 @@ class ExternalTabContainer : public TabContentsDelegate,
bool handle_top_level_requests,
TabContents* existing_tab_contents,
const GURL& initial_url,
- const GURL& referrer);
+ const GURL& referrer,
+ bool infobars_enabled);
// Unhook the keystroke listener and notify about the closing TabContents.
// This function gets called from three places, which is fine.
@@ -202,6 +203,8 @@ class ExternalTabContainer : public TabContentsDelegate,
virtual void TabContentsCreated(TabContents* new_contents);
+ virtual bool infobars_enabled();
+
protected:
// Overridden from views::WidgetWin:
virtual LRESULT OnCreate(LPCREATESTRUCT create_struct);
@@ -325,6 +328,9 @@ class ExternalTabContainer : public TabContentsDelegate,
// from the host.
bool pending_;
+ // Set to true if the ExternalTabContainer if infobars should be enabled.
+ bool infobars_enabled_;
+
DISALLOW_COPY_AND_ASSIGN(ExternalTabContainer);
};
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index c8d3e95..33d631b 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -951,6 +951,11 @@ bool TabContents::FocusLocationBarByDefault() {
}
void TabContents::AddInfoBar(InfoBarDelegate* delegate) {
+ if (delegate_ && !delegate_->infobars_enabled()) {
+ delegate->InfoBarClosed();
+ return;
+ }
+
// Look through the existing InfoBarDelegates we have for a match. If we've
// already got one that matches, then we don't add the new one.
for (int i = 0; i < infobar_delegate_count(); ++i) {
@@ -977,6 +982,10 @@ void TabContents::AddInfoBar(InfoBarDelegate* delegate) {
}
void TabContents::RemoveInfoBar(InfoBarDelegate* delegate) {
+ if (delegate_ && !delegate_->infobars_enabled()) {
+ return;
+ }
+
std::vector<InfoBarDelegate*>::iterator it =
find(infobar_delegates_.begin(), infobar_delegates_.end(), delegate);
if (it != infobar_delegates_.end()) {
@@ -997,6 +1006,11 @@ void TabContents::RemoveInfoBar(InfoBarDelegate* delegate) {
void TabContents::ReplaceInfoBar(InfoBarDelegate* old_delegate,
InfoBarDelegate* new_delegate) {
+ if (delegate_ && !delegate_->infobars_enabled()) {
+ new_delegate->InfoBarClosed();
+ return;
+ }
+
std::vector<InfoBarDelegate*>::iterator it =
find(infobar_delegates_.begin(), infobar_delegates_.end(), old_delegate);
DCHECK(it != infobar_delegates_.end());
diff --git a/chrome/browser/tab_contents/tab_contents_delegate.h b/chrome/browser/tab_contents/tab_contents_delegate.h
index 25653f4..9a84f83 100644
--- a/chrome/browser/tab_contents/tab_contents_delegate.h
+++ b/chrome/browser/tab_contents/tab_contents_delegate.h
@@ -283,6 +283,9 @@ class TabContentsDelegate : public AutomationResourceRoutingDelegate {
// typically happens when popups are created.
virtual void TabContentsCreated(TabContents* new_contents) {}
+ // Returns whether infobars are enabled. Overrideable by child classes.
+ virtual bool infobars_enabled() { return true; }
+
protected:
~TabContentsDelegate() {}
};