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

Unified Diff: chrome/browser/ui/apps/chrome_shell_window_delegate.cc

Issue 18051015: Use scoped_ptr for ShellWindowLinkDelegate to prevent memory leak. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 months 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/ui/apps/chrome_shell_window_delegate.cc
diff --git a/chrome/browser/ui/apps/chrome_shell_window_delegate.cc b/chrome/browser/ui/apps/chrome_shell_window_delegate.cc
index 255c416f76c8b8b0604f6f13ce7645c6caf68912..8bee0518d52390c25ed88d93f2e6d96590eb4bb0 100644
--- a/chrome/browser/ui/apps/chrome_shell_window_delegate.cc
+++ b/chrome/browser/ui/apps/chrome_shell_window_delegate.cc
@@ -29,17 +29,7 @@ namespace {
bool disable_external_open_for_testing_ = false;
-class ShellWindowLinkDelegate : public content::WebContentsDelegate {
- public:
- ShellWindowLinkDelegate();
-
- private:
- virtual content::WebContents* OpenURLFromTab(
- content::WebContents* source,
- const content::OpenURLParams& params) OVERRIDE;
-
- DISALLOW_COPY_AND_ASSIGN(ShellWindowLinkDelegate);
-};
+} // namespace
ShellWindowLinkDelegate::ShellWindowLinkDelegate() {}
@@ -53,8 +43,6 @@ content::WebContents* ShellWindowLinkDelegate::OpenURLFromTab(
return NULL;
}
-} // namespace
-
ChromeShellWindowDelegate::ChromeShellWindowDelegate() {}
ChromeShellWindowDelegate::~ChromeShellWindowDelegate() {}
@@ -92,7 +80,9 @@ void ChromeShellWindowDelegate::AddNewContents(
bool user_gesture,
bool* was_blocked) {
if (!disable_external_open_for_testing_) {
- new_contents->SetDelegate(new ShellWindowLinkDelegate());
+ if (!shell_window_link_delegate_.get())
+ shell_window_link_delegate_.reset(new ShellWindowLinkDelegate());
+ new_contents->SetDelegate(shell_window_link_delegate_.get());
sky 2013/07/08 14:51:39 What is the lifetime of new_contents?
zhchbin 2013/07/09 02:00:10 It will be deleted when the ShellWindowLinkDelegat
return;
}
Browser* browser =

Powered by Google App Engine
This is Rietveld 408576698