Remove from notification center when web contents is destroyed.

This commit is contained in:
Cheng Zhao 2014-04-23 11:20:12 +08:00
parent 54060ed53d
commit 5e0dd5c687
4 changed files with 10 additions and 0 deletions

View file

@ -15,6 +15,7 @@ class InspectableWebContentsViewMac : public InspectableWebContentsView {
public:
explicit InspectableWebContentsViewMac(
InspectableWebContentsImpl* inspectable_web_contents_impl);
virtual ~InspectableWebContentsViewMac();
virtual gfx::NativeView GetNativeView() const OVERRIDE;
virtual void ShowDevTools() OVERRIDE;

View file

@ -17,6 +17,10 @@ InspectableWebContentsViewMac::InspectableWebContentsViewMac(InspectableWebConte
view_([[BRYInspectableWebContentsView alloc] initWithInspectableWebContentsViewMac:this]) {
}
InspectableWebContentsViewMac::~InspectableWebContentsViewMac() {
[view_ removeFromNotificationCenter];
}
gfx::NativeView InspectableWebContentsViewMac::GetNativeView() const {
return view_.get();
}

View file

@ -8,6 +8,7 @@
BRYInspectableWebContentsViewPrivate *_private;
}
- (void)removeFromNotificationCenter;
- (IBAction)showDevTools:(id)sender;
@end

View file

@ -76,6 +76,10 @@ void SetActive(content::WebContents* web_contents, bool active) {
[super dealloc];
}
- (void)removeFromNotificationCenter {
[NSNotificationCenter.defaultCenter removeObserver:self];
}
- (IBAction)showDevTools:(id)sender {
_private->inspectableWebContentsView->inspectable_web_contents()->ShowDevTools();
}