Commit 68059696 authored by droger@chromium.org's avatar droger@chromium.org

Remove InfoBarDelegate::web_contents()

In order to move InfoBarDelegate to the infobar components, all dependencies on
content/ must be removed.
This CL removes the InfoBarDelegate::web_contents() method and callers use
InfoBarService::WebContentsFromInfobar() instead.

BUG=354379
TBR=jochen

Review URL: https://codereview.chromium.org/230453004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263044 0039d316-1c4b-4281-b951-d872f2087c98
parent 30be97b4
......@@ -100,10 +100,11 @@ base::string16 AutofillCCInfoBarDelegate::GetLinkText() const {
}
bool AutofillCCInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
web_contents()->OpenURL(content::OpenURLParams(
GURL(autofill::kHelpURL), content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
content::OpenURLParams(
GURL(autofill::kHelpURL), content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
return false;
}
......
......@@ -115,10 +115,12 @@ bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked(
WindowOpenDisposition disposition) {
content::RecordAction(
base::UserMetricsAction("RegisterProtocolHandler.InfoBar_LearnMore"));
web_contents()->OpenURL(content::OpenURLParams(
GURL(chrome::kLearnMoreRegisterProtocolHandlerURL), content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
content::OpenURLParams(
GURL(chrome::kLearnMoreRegisterProtocolHandlerURL),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
return false;
}
......
......@@ -57,6 +57,10 @@ ExtensionInfoBarDelegate::ExtensionInfoBarDelegate(
height_ = InfoBar::kDefaultBarTargetHeight;
}
content::WebContents* ExtensionInfoBarDelegate::GetWebContents() {
return InfoBarService::WebContentsFromInfoBar(infobar());
}
// ExtensionInfoBarDelegate::CreateInfoBar() is implemented in platform-specific
// files.
......
......@@ -13,6 +13,10 @@
class Browser;
class GURL;
namespace content {
class WebContents;
}
namespace extensions {
class Extension;
class ExtensionViewHost;
......@@ -41,6 +45,9 @@ class ExtensionInfoBarDelegate : public InfoBarDelegate,
bool closing() const { return closing_; }
// Returns the WebContents associated with the ExtensionInfoBarDelegate.
content::WebContents* GetWebContents();
private:
ExtensionInfoBarDelegate(Browser* browser,
const extensions::Extension* extension,
......
......@@ -113,9 +113,11 @@ bool GeolocationInfoBarDelegate::Accept() {
void GeolocationInfoBarDelegate::SetPermission(bool update_content_setting,
bool allowed) {
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
controller_->OnPermissionSet(
id_, requesting_frame_,
web_contents()->GetLastCommittedURL().GetOrigin(),
web_contents->GetLastCommittedURL().GetOrigin(),
update_content_setting, allowed);
}
......@@ -175,10 +177,11 @@ bool GeolocationInfoBarDelegate::LinkClicked(
"https://www.google.com/support/chrome/bin/answer.py?answer=142065";
#endif
web_contents()->OpenURL(content::OpenURLParams(
google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
content::OpenURLParams(
google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
return false; // Do not dismiss the info bar.
}
......@@ -58,7 +58,8 @@ void GoogleURLTrackerInfoBarDelegate::Close(bool redo_search) {
new_search_url = search_url_.ReplaceComponents(replacements);
}
content::WebContents* contents = web_contents();
content::WebContents* contents =
InfoBarService::WebContentsFromInfoBar(infobar());
infobar()->RemoveSelf();
// WARNING: |this| may be deleted at this point! Do not access any members!
......@@ -106,13 +107,14 @@ base::string16 GoogleURLTrackerInfoBarDelegate::GetLinkText() const {
bool GoogleURLTrackerInfoBarDelegate::LinkClicked(
WindowOpenDisposition disposition) {
web_contents()->OpenURL(content::OpenURLParams(
google_util::AppendGoogleLocaleParam(GURL(
"https://www.google.com/support/chrome/bin/answer.py?"
"answer=1618699")),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
content::OpenURLParams(
google_util::AppendGoogleLocaleParam(GURL(
"https://www.google.com/support/chrome/bin/answer.py?"
"answer=1618699")),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
return false;
}
......
......@@ -95,9 +95,13 @@ TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() {
}
void InfoBarDelegate::StoreActiveEntryUniqueID() {
DCHECK(web_contents());
// TODO(droger): Remove this dependency on InfoBarService, see
// http://crbug.com/354379.
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
DCHECK(web_contents);
NavigationEntry* active_entry =
web_contents()->GetController().GetActiveEntry();
web_contents->GetController().GetActiveEntry();
contents_unique_id_ = active_entry ? active_entry->GetUniqueID() : 0;
}
......@@ -107,10 +111,6 @@ gfx::Image InfoBarDelegate::GetIcon() const {
ResourceBundle::GetSharedInstance().GetNativeImageNamed(icon_id);
}
content::WebContents* InfoBarDelegate::web_contents() {
return InfoBarService::WebContentsFromInfoBar(infobar_);
}
InfoBarDelegate::InfoBarDelegate() : contents_unique_id_(0) {
}
......
......@@ -22,10 +22,6 @@ class ThemeInstalledInfoBarDelegate;
class ThreeDAPIInfoBarDelegate;
class TranslateInfoBarDelegate;
namespace content {
class WebContents;
}
namespace gfx {
class Image;
}
......@@ -125,12 +121,6 @@ class InfoBarDelegate {
// empty, no icon is shown.
virtual gfx::Image GetIcon() const;
// This trivial getter is defined out-of-line in order to avoid needing to
// #include infobar.h, which would lead to circular #includes.
// TODO(droger): Remove this function and have callers use
// InfoBarService::WebContentsFromInfoBar() instead.
content::WebContents* web_contents();
protected:
InfoBarDelegate();
......
......@@ -91,13 +91,15 @@ bool InsecureContentInfoBarDelegate::Cancel() {
(type_ == DISPLAY) ? DISPLAY_USER_OVERRIDE : RUN_USER_OVERRIDE,
NUM_EVENTS);
web_contents()->SendToAllFrames((type_ == DISPLAY) ?
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
web_contents->SendToAllFrames((type_ == DISPLAY) ?
static_cast<IPC::Message*>(
new ChromeViewMsg_SetAllowDisplayingInsecureContent(MSG_ROUTING_NONE,
true)) :
new ChromeViewMsg_SetAllowRunningInsecureContent(MSG_ROUTING_NONE, true));
web_contents()->GetMainFrame()->Send(new ChromeViewMsg_ReloadFrame(
web_contents()->GetMainFrame()->GetRoutingID()));
web_contents->GetMainFrame()->Send(new ChromeViewMsg_ReloadFrame(
web_contents->GetMainFrame()->GetRoutingID()));
return true;
}
......@@ -107,11 +109,13 @@ base::string16 InsecureContentInfoBarDelegate::GetLinkText() const {
bool InsecureContentInfoBarDelegate::LinkClicked(
WindowOpenDisposition disposition) {
web_contents()->OpenURL(content::OpenURLParams(
google_util::AppendGoogleLocaleParam(GURL("https://www.google.com/"
"support/chrome/bin/answer.py?answer=1342714")),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
content::OpenURLParams(
google_util::AppendGoogleLocaleParam(GURL(
"https://www.google.com/"
"support/chrome/bin/answer.py?answer=1342714")),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
return false;
}
......@@ -122,8 +122,10 @@ bool ManagedModeWarningInfoBarDelegate::ShouldExpire(
}
void ManagedModeWarningInfoBarDelegate::InfoBarDismissed() {
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
ManagedModeNavigationObserver::FromWebContents(
web_contents())->WarnInfoBarDismissed();
web_contents)->WarnInfoBarDismissed();
}
base::string16 ManagedModeWarningInfoBarDelegate::GetMessageText() const {
......@@ -146,7 +148,7 @@ bool ManagedModeWarningInfoBarDelegate::Accept() {
// http://crbug.com/313377
NOTIMPLEMENTED();
#else
GoBackToSafety(web_contents());
GoBackToSafety(InfoBarService::WebContentsFromInfoBar(infobar()));
#endif
return false;
......
......@@ -137,13 +137,13 @@ base::string16 MediaStreamInfoBarDelegate::GetLinkText() const {
bool MediaStreamInfoBarDelegate::LinkClicked(
WindowOpenDisposition disposition) {
web_contents()->OpenURL(content::OpenURLParams(
google_util::AppendGoogleLocaleParam(
GURL(chrome::kMediaAccessLearnMoreUrl)),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK,
false));
InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
content::OpenURLParams(
google_util::AppendGoogleLocaleParam(
GURL(chrome::kMediaAccessLearnMoreUrl)),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
return false; // Do not dismiss the info bar.
}
......@@ -93,6 +93,8 @@ bool MidiPermissionInfoBarDelegate::Cancel() {
void MidiPermissionInfoBarDelegate::SetPermission(bool update_content_setting,
bool allowed) {
controller_->OnPermissionSet(id_, requesting_frame_, web_contents()->GetURL(),
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
controller_->OnPermissionSet(id_, requesting_frame_, web_contents->GetURL(),
update_content_setting, allowed);
}
......@@ -62,8 +62,10 @@ bool ProtectedMediaIdentifierInfoBarDelegate::Accept() {
void ProtectedMediaIdentifierInfoBarDelegate::SetPermission(
bool update_content_setting,
bool allowed) {
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
controller_->OnPermissionSet(id_, requesting_frame_,
web_contents()->GetLastCommittedURL(),
web_contents->GetLastCommittedURL(),
update_content_setting, allowed);
}
......
......@@ -50,9 +50,11 @@ base::string16 NaClInfoBarDelegate::GetLinkText() const {
}
bool NaClInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
web_contents()->OpenURL(content::OpenURLParams(
GURL("https://support.google.com/chrome/?p=ib_nacl"), content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
content::OpenURLParams(
GURL("https://support.google.com/chrome/?p=ib_nacl"),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
return false;
}
......@@ -132,10 +132,11 @@ base::string16 PepperBrokerInfoBarDelegate::GetLinkText() const {
bool PepperBrokerInfoBarDelegate::LinkClicked(
WindowOpenDisposition disposition) {
GURL learn_more_url("https://support.google.com/chrome/?p=ib_pepper_broker");
web_contents()->OpenURL(content::OpenURLParams(
learn_more_url, content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
content::OpenURLParams(
learn_more_url, content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
return false;
}
......
......@@ -57,16 +57,19 @@ PluginInfoBarDelegate::~PluginInfoBarDelegate() {
}
bool PluginInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
web_contents()->OpenURL(content::OpenURLParams(
GURL(GetLearnMoreURL()), content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
content::OpenURLParams(
GURL(GetLearnMoreURL()), content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
return false;
}
void PluginInfoBarDelegate::LoadBlockedPlugins() {
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins(
web_contents(), true, identifier_);
web_contents, true, identifier_);
}
int PluginInfoBarDelegate::GetIconID() const {
......@@ -145,7 +148,7 @@ bool UnauthorizedPluginInfoBarDelegate::Accept() {
bool UnauthorizedPluginInfoBarDelegate::Cancel() {
content::RecordAction(UserMetricsAction("BlockedPluginInfobar.AlwaysAllow"));
const GURL& url = web_contents()->GetURL();
const GURL& url = InfoBarService::WebContentsFromInfoBar(infobar())->GetURL();
content_settings_->AddExceptionForURL(url, url, CONTENT_SETTINGS_TYPE_PLUGINS,
CONTENT_SETTING_ALLOW);
LoadBlockedPlugins();
......@@ -238,10 +241,12 @@ bool OutdatedPluginInfoBarDelegate::Accept() {
// result in deleting ourselves. Accordingly, we make sure to
// not pass a reference to an object that can go away.
GURL plugin_url(plugin_metadata_->plugin_url());
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
if (plugin_metadata_->url_for_display())
installer()->OpenDownloadURL(plugin_url, web_contents());
installer()->OpenDownloadURL(plugin_url, web_contents);
else
installer()->StartInstalling(plugin_url, web_contents());
installer()->StartInstalling(plugin_url, web_contents);
return false;
}
......@@ -392,10 +397,11 @@ bool PluginInstallerInfoBarDelegate::LinkClicked(
url = google_util::AppendGoogleLocaleParam(GURL(
"https://www.google.com/support/chrome/bin/answer.py?answer=142064"));
}
web_contents()->OpenURL(content::OpenURLParams(
url, content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
content::OpenURLParams(
url, content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
return false;
}
......@@ -515,13 +521,14 @@ bool PluginMetroModeInfoBarDelegate::LinkClicked(
// TODO(shrikant): We may need to change language a little at following
// support URLs. With new approach we will just restart for both missing
// and not missing mode.
web_contents()->OpenURL(content::OpenURLParams(
GURL((mode_ == MISSING_PLUGIN) ?
"https://support.google.com/chrome/?p=ib_display_in_desktop" :
"https://support.google.com/chrome/?p=ib_redirect_to_desktop"),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
content::OpenURLParams(
GURL((mode_ == MISSING_PLUGIN) ?
"https://support.google.com/chrome/?p=ib_display_in_desktop" :
"https://support.google.com/chrome/?p=ib_redirect_to_desktop"),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
return false;
}
......
......@@ -118,8 +118,10 @@ base::string16 SSLCertResultInfoBarDelegate::GetButtonLabel(
}
bool SSLCertResultInfoBarDelegate::Accept() {
ShowCertificateViewer(web_contents(),
web_contents()->GetView()->GetTopLevelNativeWindow(),
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
ShowCertificateViewer(web_contents,
web_contents->GetView()->GetTopLevelNativeWindow(),
cert_.get());
return false; // Hiding the infobar just as the dialog opens looks weird.
}
......
......@@ -132,7 +132,8 @@ bool ThreeDAPIInfoBarDelegate::Cancel() {
UMA_HISTOGRAM_ENUMERATION("GPU.ThreeDAPIInfoBarDismissal", RELOADED,
DISMISSAL_MAX);
content::GpuDataManager::GetInstance()->UnblockDomainFrom3DAPIs(url_);
web_contents()->GetController().Reload(true);
InfoBarService::WebContentsFromInfoBar(infobar())->GetController().Reload(
true);
return true;
}
......@@ -141,12 +142,12 @@ base::string16 ThreeDAPIInfoBarDelegate::GetLinkText() const {
}
bool ThreeDAPIInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
web_contents()->OpenURL(content::OpenURLParams(
GURL("https://support.google.com/chrome/?p=ib_webgl"),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK,
false));
InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
content::OpenURLParams(
GURL("https://support.google.com/chrome/?p=ib_webgl"),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
return false;
}
......
......@@ -26,7 +26,7 @@ OptionsMenuModel::OptionsMenuModel(
: ui::SimpleMenuModel(this),
translate_infobar_delegate_(translate_delegate) {
// |translate_delegate| must already be owned.
DCHECK(translate_infobar_delegate_->web_contents());
DCHECK(translate_infobar_delegate_->GetWebContents());
base::string16 original_language = translate_delegate->language_name_at(
translate_delegate->original_language_index());
......@@ -39,7 +39,7 @@ OptionsMenuModel::OptionsMenuModel(
// Populate the menu.
// Incognito mode does not get any preferences related items.
if (!translate_delegate->web_contents()->GetBrowserContext()->
if (!translate_delegate->GetWebContents()->GetBrowserContext()->
IsOffTheRecord()) {
if (!autodetermined_source_language) {
AddCheckItem(IDC_TRANSLATE_OPTIONS_ALWAYS,
......@@ -125,7 +125,7 @@ void OptionsMenuModel::ExecuteCommand(int command_id, int event_flags) {
break;
case IDC_TRANSLATE_OPTIONS_ABOUT: {
WebContents* web_contents = translate_infobar_delegate_->web_contents();
WebContents* web_contents = translate_infobar_delegate_->GetWebContents();
if (web_contents) {
OpenURLParams params(
GURL(chrome::kAboutGoogleTranslateURL), Referrer(),
......
......@@ -133,7 +133,7 @@ void TranslateInfoBarDelegate::RevertTranslation() {
void TranslateInfoBarDelegate::ReportLanguageDetectionError() {
TranslateManager* manager =
TranslateTabHelper::GetManagerFromWebContents(web_contents());
TranslateTabHelper::GetManagerFromWebContents(GetWebContents());
if (!manager)
return;
manager->ReportLanguageDetectionError();
......@@ -145,7 +145,7 @@ void TranslateInfoBarDelegate::TranslationDeclined() {
bool TranslateInfoBarDelegate::IsTranslatableLanguageByPrefs() {
Profile* profile =
Profile::FromBrowserContext(web_contents()->GetBrowserContext());
Profile::FromBrowserContext(GetWebContents()->GetBrowserContext());
Profile* original_profile = profile->GetOriginalProfile();
scoped_ptr<TranslatePrefs> translate_prefs(
TranslateTabHelper::CreateTranslatePrefs(original_profile->GetPrefs()));
......@@ -255,7 +255,7 @@ void TranslateInfoBarDelegate::MessageInfoBarButtonPressed() {
}
// This is the "Try again..." case.
TranslateManager* manager =
TranslateTabHelper::GetManagerFromWebContents(web_contents());
TranslateTabHelper::GetManagerFromWebContents(GetWebContents());
DCHECK(manager);
manager->TranslatePage(
original_language_code(), target_language_code(), false);
......@@ -267,18 +267,22 @@ bool TranslateInfoBarDelegate::ShouldShowMessageInfoBarButton() {
bool TranslateInfoBarDelegate::ShouldShowNeverTranslateShortcut() {
DCHECK_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, step_);
return !web_contents()->GetBrowserContext()->IsOffTheRecord() &&
return !GetWebContents()->GetBrowserContext()->IsOffTheRecord() &&
(prefs_->GetTranslationDeniedCount(original_language_code()) >=
kNeverTranslateMinCount);
}
bool TranslateInfoBarDelegate::ShouldShowAlwaysTranslateShortcut() {
DCHECK_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, step_);
return !web_contents()->GetBrowserContext()->IsOffTheRecord() &&
return !GetWebContents()->GetBrowserContext()->IsOffTheRecord() &&
(prefs_->GetTranslationAcceptedCount(original_language_code()) >=
kAlwaysTranslateMinCount);
}
content::WebContents* TranslateInfoBarDelegate::GetWebContents() {
return InfoBarService::WebContentsFromInfoBar(infobar());
}
// static
base::string16 TranslateInfoBarDelegate::GetLanguageDisplayableName(
const std::string& language_code) {
......
......@@ -144,6 +144,9 @@ class TranslateInfoBarDelegate : public InfoBarDelegate {
bool ShouldShowNeverTranslateShortcut();
bool ShouldShowAlwaysTranslateShortcut();
// Returns the WebContents associated with the TranslateInfoBarDelegate.
content::WebContents* GetWebContents();
// Convenience method that returns the displayable language name for
// |language_code| in the current application locale.
static base::string16 GetLanguageDisplayableName(
......
......@@ -99,8 +99,10 @@ bool PopupBlockedInfoBarDelegate::Accept() {
url_, url_, CONTENT_SETTINGS_TYPE_POPUPS, CONTENT_SETTING_ALLOW);
// Launch popups.
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
PopupBlockerTabHelper* popup_blocker_helper =
PopupBlockerTabHelper::FromWebContents(web_contents());
PopupBlockerTabHelper::FromWebContents(web_contents);
DCHECK(popup_blocker_helper);
PopupBlockerTabHelper::PopupIdMap blocked_popups =
popup_blocker_helper->GetBlockedPopupRequests();
......
......@@ -89,7 +89,8 @@ void AutoLoginInfoBarDelegateAndroid::LoginSuccess(JNIEnv* env,
// TODO(miguelg): Test whether the Stop() and RemoveInfoBar() calls here are
// necessary, or whether OpenURL() will do this for us.
content::WebContents* contents = web_contents();
content::WebContents* contents =
InfoBarService::WebContentsFromInfoBar(infobar());
contents->Stop();
infobar()->RemoveSelf();
// WARNING: |this| may be deleted at this point! Do not access any members!
......@@ -106,8 +107,8 @@ void AutoLoginInfoBarDelegateAndroid::LoginFailed(JNIEnv* env, jobject obj) {
// TODO(miguelg): Using SimpleAlertInfoBarDelegate::Create() animates in a new
// infobar while we animate the current one closed. It would be better to use
// ReplaceInfoBar().
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents());
InfoBarService* infobar_service = InfoBarService::FromWebContents(
InfoBarService::WebContentsFromInfoBar(infobar()));
DCHECK(infobar_service);
SimpleAlertInfoBarDelegate::Create(
infobar_service, IDR_INFOBAR_WARNING,
......
......@@ -210,15 +210,19 @@ base::string16 AutoLoginInfoBarDelegate::GetButtonLabel(
bool AutoLoginInfoBarDelegate::Accept() {
// AutoLoginRedirector deletes itself.
new AutoLoginRedirector(web_contents(), params_.header.args);
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
new AutoLoginRedirector(web_contents, params_.header.args);
RecordHistogramAction(ACCEPTED);
button_pressed_ = true;
return true;
}
bool AutoLoginInfoBarDelegate::Cancel() {
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
PrefService* pref_service = Profile::FromBrowserContext(
web_contents()->GetBrowserContext())->GetPrefs();
web_contents->GetBrowserContext())->GetPrefs();
pref_service->SetBoolean(prefs::kAutologinEnabled, false);
RecordHistogramAction(REJECTED);
button_pressed_ = true;
......
......@@ -15,6 +15,7 @@ class Profile;
namespace content {
class NavigationController;
class WebContents;
}
// This is the actual infobar displayed to prompt the user to auto-login.
......
......@@ -246,7 +246,7 @@ class InfobarBridge {
extensions::ExtensionViewHost* extensionViewHost =
[self delegate]->AsExtensionInfoBarDelegate()->extension_view_host();
Browser* browser = chrome::FindBrowserWithWebContents(
[self delegate]->AsExtensionInfoBarDelegate()->web_contents());
[self delegate]->AsExtensionInfoBarDelegate()->GetWebContents());
contextMenuController_.reset([[ExtensionActionContextMenuController alloc]
initWithExtension:extensionViewHost->extension()
browser:browser
......
......@@ -50,6 +50,8 @@ base::string16 CollectedCookiesInfoBarDelegate::GetButtonLabel(
}
bool CollectedCookiesInfoBarDelegate::Accept() {
web_contents()->GetController().Reload(true);
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
web_contents->GetController().Reload(true);
return true;
}
......@@ -52,6 +52,8 @@ base::string16 MediaSettingChangedInfoBarDelegate::GetButtonLabel(
}
bool MediaSettingChangedInfoBarDelegate::Accept() {
web_contents()->GetController().Reload(true);
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
web_contents->GetController().Reload(true);
return true;
}
......@@ -131,11 +131,12 @@ base::string16 ErrorInfoBarDelegate::GetLinkText() const {
}
bool ErrorInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
web_contents()->OpenURL(content::OpenURLParams(
GURL("http://support.google.com/chrome_webstore/?p=crx_warning"),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
content::OpenURLParams(
GURL("http://support.google.com/chrome_webstore/?p=crx_warning"),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
return false;
}
......
......@@ -82,9 +82,10 @@ bool AlternateNavInfoBarDelegate::LinkClicked(
// Pretend the user typed this URL, so that navigating to it will be the
// default action when it's typed again in the future.
web_contents()->OpenURL(content::OpenURLParams(
match_.destination_url, content::Referrer(), disposition,
content::PAGE_TRANSITION_TYPED, false));
InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
content::OpenURLParams(match_.destination_url, content::Referrer(),
disposition, content::PAGE_TRANSITION_TYPED,
false));
// We should always close, even if the navigation did not occur within this
// WebContents.
......
......@@ -9,6 +9,10 @@
#include "chrome/browser/autocomplete/autocomplete_match.h"
#include "chrome/browser/infobars/infobar_delegate.h"
namespace content {
class WebContents;
}
class AlternateNavInfoBarDelegate : public InfoBarDelegate {
public:
virtual ~AlternateNavInfoBarDelegate();
......
......@@ -43,10 +43,11 @@ base::string16 GoogleApiKeysInfoBarDelegate::GetLinkText() const {
bool GoogleApiKeysInfoBarDelegate::LinkClicked(
WindowOpenDisposition disposition) {
web_contents()->OpenURL(content::OpenURLParams(
GURL("http://www.chromium.org/developers/how-tos/api-keys"),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
content::OpenURLParams(
GURL("http://www.chromium.org/developers/how-tos/api-keys"),
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
return false;
}
......@@ -81,14 +81,16 @@ base::string16 ObsoleteSystemInfoBarDelegate::GetLinkText() const {
bool ObsoleteSystemInfoBarDelegate::LinkClicked(
WindowOpenDisposition disposition) {
web_contents()->OpenURL(content::OpenURLParams(
InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
content::OpenURLParams(
#if defined(OS_MACOSX)
GURL(chrome::kMac32BitDeprecationURL),
GURL(chrome::kMac32BitDeprecationURL),
#else
GURL("http://www.google.com/support/chrome/bin/answer.py?answer=95411"),
GURL("http://www.google.com/support/chrome/bin/"
"answer.py?answer=95411"),
#endif
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
content::Referrer(),
(disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
content::PAGE_TRANSITION_LINK, false));
return false;
}
......@@ -73,7 +73,9 @@ base::string16 SessionCrashedInfoBarDelegate::GetButtonLabel(
bool SessionCrashedInfoBarDelegate::Accept() {
uint32 behavior = 0;
Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
if (browser->tab_strip_model()->count() == 1) {
const content::WebContents* active_tab =
browser->tab_strip_model()->GetWebContentsAt(0);
......
......@@ -51,6 +51,8 @@ base::string16 WebsiteSettingsInfoBarDelegate::GetButtonLabel(
}
bool WebsiteSettingsInfoBarDelegate::Accept() {
web_contents()->GetController().Reload(true);
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
web_contents->GetController().Reload(true);
return true;
}
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