Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4076)

Unified Diff: chrome/browser/cocoa/extensions/extension_infobar_controller.mm

Issue 4767001: Make TabContents own its infobar delegates.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/cocoa/extensions/extension_infobar_controller.mm
===================================================================
--- chrome/browser/cocoa/extensions/extension_infobar_controller.mm (revision 65711)
+++ chrome/browser/cocoa/extensions/extension_infobar_controller.mm (working copy)
@@ -47,25 +47,21 @@
// A helper class to bridge the asynchronous Skia bitmap loading mechanism to
// the extension's button.
-class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver,
- public ImageLoadingTracker::Observer {
+class InfobarBridge : public ImageLoadingTracker::Observer {
public:
explicit InfobarBridge(ExtensionInfoBarController* owner)
: owner_(owner),
- delegate_([owner delegate]->AsExtensionInfoBarDelegate()),
tracker_(this) {
- delegate_->set_observer(this);
LoadIcon();
}
virtual ~InfobarBridge() {
- if (delegate_)
- delegate_->set_observer(NULL);
}
// Load the Extension's icon image.
void LoadIcon() {
- const Extension* extension = delegate_->extension_host()->extension();
+ const Extension* extension = [owner_ delegate]->
+ AsExtensionInfoBarDelegate()->extension_host()->extension();
ExtensionResource icon_resource = extension->GetIconResource(
Extension::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY);
if (!icon_resource.relative_path().empty()) {
@@ -81,11 +77,9 @@
// ImageLoadingTracker::Observer implementation.
// TODO(andybons): The infobar view implementations share a lot of the same
// code. Come up with a strategy to share amongst them.
- virtual void OnImageLoaded(
- SkBitmap* image, ExtensionResource resource, int index) {
- if (!delegate_)
- return; // The delegate can go away while the image asynchronously loads.
-
+ virtual void OnImageLoaded(SkBitmap* image,
+ ExtensionResource resource,
+ int index) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
// Fall back on the default extension icon on failure.
@@ -112,18 +106,10 @@
[owner_ setButtonImage:gfx::SkBitmapToNSImage(canvas->ExtractBitmap())];
}
- // Overridden from ExtensionInfoBarDelegate::DelegateObserver:
- virtual void OnDelegateDeleted() {
- delegate_ = NULL;
- }
-
private:
// Weak. Owns us.
ExtensionInfoBarController* owner_;
- // Weak.
- ExtensionInfoBarDelegate* delegate_;
-
// Loads the extensions's icon on the file thread.
ImageLoadingTracker tracker_;

Powered by Google App Engine
This is Rietveld 408576698