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

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: Add virtual destructor. 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
« no previous file with comments | « chrome/browser/ui/apps/chrome_shell_window_delegate.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2ed133330948cc0e3c5af5560ed8bcdc77762728 100644
--- a/chrome/browser/ui/apps/chrome_shell_window_delegate.cc
+++ b/chrome/browser/ui/apps/chrome_shell_window_delegate.cc
@@ -29,20 +29,12 @@ 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() {}
+ShellWindowLinkDelegate::~ShellWindowLinkDelegate() {}
+
// TODO(rockot): Add a test that exercises this code. See
// http://crbug.com/254260.
content::WebContents* ShellWindowLinkDelegate::OpenURLFromTab(
@@ -53,8 +45,6 @@ content::WebContents* ShellWindowLinkDelegate::OpenURLFromTab(
return NULL;
}
-} // namespace
-
ChromeShellWindowDelegate::ChromeShellWindowDelegate() {}
ChromeShellWindowDelegate::~ChromeShellWindowDelegate() {}
@@ -92,7 +82,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());
return;
}
Browser* browser =
« no previous file with comments | « chrome/browser/ui/apps/chrome_shell_window_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698