diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-20 16:34:13 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-20 16:34:13 +0000 |
commit | d715fb8034a11d163481f93d9473d968f9f2203e (patch) | |
tree | 0c162fd3de1c8b99ed887a326629cda105dfe685 /chrome/browser/ui/cocoa | |
parent | 97826c1ca1812f98ff4a0a03be27b932e867b22c (diff) | |
download | chromium_src-d715fb8034a11d163481f93d9473d968f9f2203e.zip chromium_src-d715fb8034a11d163481f93d9473d968f9f2203e.tar.gz chromium_src-d715fb8034a11d163481f93d9473d968f9f2203e.tar.bz2 |
Introduce InfoBarTabService API.
The new interface extracts the API bits from InfoBarTabHelper. This
change switches files under chrome/browser/autofill and
chrome/browser/api to use the API and remove the temporarily-allowed
dependency on InfoBarTabHelper.
TBRing other owners as the changes are just to match the updated API and include paths.
TBR=ben@chromium.org
BUG=140037
Review URL: https://chromiumcodereview.appspot.com/10830353
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152338 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/cocoa')
10 files changed, 25 insertions, 24 deletions
diff --git a/chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.mm b/chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.mm index 293a773..5a1825b 100644 --- a/chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.mm @@ -38,7 +38,7 @@ NSButton* CreateNSButtonWithResourceIDAndParameter( } - (id)initWithDelegate:(InfoBarDelegate*)delegate - owner:(InfoBarTabHelper*)owner { + owner:(InfoBarTabService*)owner { if ((self = [super initWithDelegate:delegate owner:owner])) { [self initializeExtraControls]; } diff --git a/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm b/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm index ef8cb28..86c6b51 100644 --- a/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm @@ -6,10 +6,10 @@ #include <cmath> +#include "chrome/browser/api/infobars/infobar_tab_service.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_infobar_delegate.h" #include "chrome/browser/extensions/image_loading_tracker.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/ui/browser_finder.h" #import "chrome/browser/ui/cocoa/animatable_view.h" #import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h" @@ -140,7 +140,7 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver, @implementation ExtensionInfoBarController - (id)initWithDelegate:(InfoBarDelegate*)delegate - owner:(InfoBarTabHelper*)owner + owner:(InfoBarTabService*)owner window:(NSWindow*)window { if ((self = [super initWithDelegate:delegate owner:owner])) { window_ = window; @@ -150,7 +150,7 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver, extensions::ExtensionHost* extensionHost = delegate_->AsExtensionInfoBarDelegate()->extension_host(); Browser* browser = - browser::FindBrowserWithWebContents(owner->web_contents()); + browser::FindBrowserWithWebContents(owner->GetWebContents()); contextMenu_.reset([[ExtensionActionContextMenu alloc] initWithExtension:extensionHost->extension() browser:browser @@ -272,9 +272,9 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver, @end -InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { +InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { NSWindow* window = - [(NSView*)owner->web_contents()->GetContentNativeView() window]; + [(NSView*)owner->GetWebContents()->GetContentNativeView() window]; ExtensionInfoBarController* controller = [[ExtensionInfoBarController alloc] initWithDelegate:this owner:owner diff --git a/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm b/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm index 940eca0..fe1be7b 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm @@ -144,7 +144,7 @@ class InfoBarNotificationObserver : public content::NotificationObserver { if (currentTabContents_) { InfoBarTabHelper* infobar_helper = currentTabContents_->infobar_tab_helper(); - for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { + for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); ++i) { InfoBar* infobar = infobar_helper-> GetInfoBarDelegateAt(i)->CreateInfoBar(infobar_helper); [self addInfoBar:infobar animate:NO]; diff --git a/chrome/browser/ui/cocoa/infobars/infobar_controller.h b/chrome/browser/ui/cocoa/infobars/infobar_controller.h index e3c18b2..1fc7b51 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_controller.h +++ b/chrome/browser/ui/cocoa/infobars/infobar_controller.h @@ -10,7 +10,7 @@ @class HoverCloseButton; @protocol InfoBarContainer; class InfoBarDelegate; -class InfoBarTabHelper; +class InfoBarTabService; @class InfoBarGradientView; // A controller for an infobar in the browser window. There is one @@ -20,7 +20,7 @@ class InfoBarTabHelper; @interface InfoBarController : NSViewController<NSTextViewDelegate> { @private id<InfoBarContainer> containerController_; // weak, owns us - InfoBarTabHelper* owner_; // weak + InfoBarTabService* owner_; // weak BOOL infoBarClosing_; @protected @@ -45,7 +45,7 @@ class InfoBarTabHelper; // Initializes a new InfoBarController. - (id)initWithDelegate:(InfoBarDelegate*)delegate - owner:(InfoBarTabHelper*)owner; + owner:(InfoBarTabService*)owner; // Returns YES if the infobar is owned. If this is NO, it is not safe to call // any delegate functions, since they might attempt to access the owner. Code diff --git a/chrome/browser/ui/cocoa/infobars/infobar_controller.mm b/chrome/browser/ui/cocoa/infobars/infobar_controller.mm index d7b584d..4c99c7e 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_controller.mm @@ -9,8 +9,8 @@ #include "base/mac/mac_util.h" #include "base/sys_string_conversions.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/infobar_tab_service.h" #include "chrome/browser/api/infobars/link_infobar_delegate.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" #import "chrome/browser/ui/cocoa/animatable_view.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h" #include "chrome/browser/ui/cocoa/event_utils.h" @@ -51,7 +51,7 @@ const float kAnimateCloseDuration = 0.12; @synthesize delegate = delegate_; - (id)initWithDelegate:(InfoBarDelegate*)delegate - owner:(InfoBarTabHelper*)owner { + owner:(InfoBarTabService*)owner { DCHECK(delegate); if ((self = [super initWithNibName:@"InfoBar" bundle:base::mac::FrameworkBundle()])) { @@ -451,13 +451,13 @@ const float kAnimateCloseDuration = 0.12; ////////////////////////////////////////////////////////////////////////// // CreateInfoBar() implementations -InfoBar* LinkInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { +InfoBar* LinkInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { LinkInfoBarController* controller = [[LinkInfoBarController alloc] initWithDelegate:this owner:owner]; return new InfoBar(controller, this); } -InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { +InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { ConfirmInfoBarController* controller = [[ConfirmInfoBarController alloc] initWithDelegate:this owner:owner]; return new InfoBar(controller, this); diff --git a/chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.h b/chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.h index 1daa635..ac6d508 100644 --- a/chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.h +++ b/chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.h @@ -10,7 +10,7 @@ #import "base/memory/scoped_nsobject.h" #include "base/memory/scoped_ptr.h" -class InfoBarTabHelper; +class InfoBarTabService; class MediaStreamDevicesMenuModel; class MediaStreamInfoBarDelegate; @class NSButton; @@ -32,7 +32,7 @@ class MediaStreamInfoBarDelegate; } - (id)initWithDelegate:(MediaStreamInfoBarDelegate*)delegate - owner:(InfoBarTabHelper*)owner; + owner:(InfoBarTabService*)owner; // Called when the selection in the device menu has changed. - (IBAction)deviceMenuChanged:(id)sender; diff --git a/chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.mm b/chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.mm index b364734..4770a2c 100644 --- a/chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.mm @@ -23,7 +23,7 @@ using InfoBarUtilities::MoveControl; using InfoBarUtilities::VerifyControlOrderAndSpacing; using l10n_util::GetNSStringWithFixup; -InfoBar* MediaStreamInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { +InfoBar* MediaStreamInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { MediaStreamInfoBarController* infobar_controller = [[MediaStreamInfoBarController alloc] initWithDelegate:this owner:owner]; @@ -52,7 +52,7 @@ InfoBar* MediaStreamInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { @implementation MediaStreamInfoBarController - (id)initWithDelegate:(MediaStreamInfoBarDelegate*)delegate - owner:(InfoBarTabHelper*)owner { + owner:(InfoBarTabService*)owner { if (self = [super initWithDelegate:delegate owner:owner]) { deviceMenuModel_.reset(new MediaStreamDevicesMenuModel(delegate)); } diff --git a/chrome/browser/ui/cocoa/infobars/translate_infobar_base.mm b/chrome/browser/ui/cocoa/infobars/translate_infobar_base.mm index e13e4da..5978e5f 100644 --- a/chrome/browser/ui/cocoa/infobars/translate_infobar_base.mm +++ b/chrome/browser/ui/cocoa/infobars/translate_infobar_base.mm @@ -29,7 +29,7 @@ using InfoBarUtilities::CreateLabel; using InfoBarUtilities::AddMenuItem; // TranslateInfoBarDelegate views specific method: -InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { +InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { TranslateInfoBarControllerBase* infobar_controller = NULL; switch (type_) { case BEFORE_TRANSLATE: @@ -100,7 +100,7 @@ InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { @implementation TranslateInfoBarControllerBase - (id)initWithDelegate:(InfoBarDelegate*)delegate - owner:(InfoBarTabHelper*)owner { + owner:(InfoBarTabService*)owner { if ((self = [super initWithDelegate:delegate owner:owner])) { originalLanguageMenuModel_.reset( new LanguagesMenuModel([self delegate], diff --git a/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm b/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm index 9af09e9..fafdca5 100644 --- a/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm +++ b/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm @@ -8,6 +8,7 @@ #import "base/string_util.h" #include "base/utf_string_conversions.h" #import "chrome/app/chrome_command_ids.h" // For translate menu command ids. +#include "chrome/browser/infobars/infobar_tab_helper.h" #import "chrome/browser/translate/translate_infobar_delegate.h" #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" #import "chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.h" diff --git a/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm b/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm index 7345b25..e5763cd 100644 --- a/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm +++ b/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm @@ -39,7 +39,7 @@ namespace { class KeystonePromotionInfoBarDelegate : public ConfirmInfoBarDelegate { public: - KeystonePromotionInfoBarDelegate(InfoBarTabHelper* infobar_helper, + KeystonePromotionInfoBarDelegate(InfoBarTabService* infobar_service, PrefService* prefs); private: @@ -71,9 +71,9 @@ class KeystonePromotionInfoBarDelegate : public ConfirmInfoBarDelegate { }; KeystonePromotionInfoBarDelegate::KeystonePromotionInfoBarDelegate( - InfoBarTabHelper* infobar_helper, + InfoBarTabService* infobar_service, PrefService* prefs) - : ConfirmInfoBarDelegate(infobar_helper), + : ConfirmInfoBarDelegate(infobar_service), prefs_(prefs), can_expire_(false), ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { @@ -198,7 +198,7 @@ bool KeystonePromotionInfoBarDelegate::ShouldExpireInternal( // default browser info bar works. if (tabContents) { InfoBarTabHelper* infobar_helper = tabContents->infobar_tab_helper(); - if (infobar_helper->infobar_count() == 0) { + if (infobar_helper->GetInfoBarCount() == 0) { infobar_helper->AddInfoBar( new KeystonePromotionInfoBarDelegate( infobar_helper, |