summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-22 22:51:07 +0000
committerscottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-22 22:51:07 +0000
commit6085c70d3d597116492a31930402f2f6e3975ab2 (patch)
tree1ae9130c402419e43500584be03f42e76a42d68d
parenta0b4d97b94020a7f41008cfc06e2724799c281e8 (diff)
downloadchromium_src-6085c70d3d597116492a31930402f2f6e3975ab2.zip
chromium_src-6085c70d3d597116492a31930402f2f6e3975ab2.tar.gz
chromium_src-6085c70d3d597116492a31930402f2f6e3975ab2.tar.bz2
Memory leak fix.
CID=15760 BUG=none TEST=none Review URL: http://codereview.chromium.org/6719003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79061 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_main.cc8
-rw-r--r--chrome/browser/printing/print_dialog_cloud.cc95
-rw-r--r--chrome/browser/printing/print_dialog_cloud.h50
-rw-r--r--chrome/browser/printing/print_dialog_cloud_internal.h5
-rw-r--r--chrome/browser/printing/print_dialog_cloud_uitest.cc2
-rw-r--r--chrome/browser/printing/printing_message_filter.cc2
6 files changed, 62 insertions, 100 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 873b49e..0fb668a 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -1750,10 +1750,10 @@ int BrowserMain(const MainFunctionParams& parameters) {
file_type = parsed_command_line.GetSwitchValueASCII(
switches::kCloudPrintFileType);
}
- PrintDialogCloud::CreatePrintDialogForFile(cloud_print_file,
- print_job_title,
- file_type,
- false);
+ print_dialog_cloud::CreatePrintDialogForFile(cloud_print_file,
+ print_job_title,
+ file_type,
+ false);
}
}
diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc
index 6d8c847..c021f42 100644
--- a/chrome/browser/printing/print_dialog_cloud.cc
+++ b/chrome/browser/printing/print_dialog_cloud.cc
@@ -504,66 +504,23 @@ bool CloudPrintHtmlDialogDelegate::ShouldShowDialogTitle() const {
return false;
}
-} // namespace internal_cloud_print_helpers
-
-// static, called on the IO thread. This is the main entry point into
-// creating the dialog.
-
-// TODO(scottbyer): The signature here will need to change as the
-// workflow through the printing code changes to allow for dynamically
-// changing page setup parameters while the dialog is active.
-void PrintDialogCloud::CreatePrintDialogForFile(const FilePath& path_to_file,
- const string16& print_job_title,
- const std::string& file_type,
- bool modal) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE) ||
- BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- NewRunnableFunction(&PrintDialogCloud::CreateDialogImpl,
- path_to_file,
- print_job_title,
- file_type,
- modal));
-}
-
-// static, called from the UI thread.
-void PrintDialogCloud::CreateDialogImpl(const FilePath& path_to_file,
- const string16& print_job_title,
- const std::string& file_type,
- bool modal) {
+// Called from the UI thread, starts up the dialog.
+void CreateDialogImpl(const FilePath& path_to_file,
+ const string16& print_job_title,
+ const std::string& file_type,
+ bool modal) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- new PrintDialogCloud(path_to_file, print_job_title, file_type, modal);
-}
+ Browser* browser = BrowserList::GetLastActive();
-// Initialize the print dialog. Called on the UI thread.
-PrintDialogCloud::PrintDialogCloud(const FilePath& path_to_file,
- const string16& print_job_title,
- const std::string& file_type,
- bool modal)
- : browser_(BrowserList::GetLastActive()) {
- Init(path_to_file, print_job_title, file_type, modal);
-}
-
-PrintDialogCloud::~PrintDialogCloud() {
-}
-
-void PrintDialogCloud::Init(const FilePath& path_to_file,
- const string16& print_job_title,
- const std::string& file_type,
- bool modal) {
- // TODO(scottbyer): Verify GAIA login valid, execute GAIA login if not (should
- // be distilled out of bookmark sync.)
const int kDefaultWidth = 497;
const int kDefaultHeight = 332;
string16 job_title = print_job_title;
Profile* profile = NULL;
if (modal) {
- DCHECK(browser_);
- if (job_title.empty() && browser_->GetSelectedTabContents())
- job_title = browser_->GetSelectedTabContents()->GetTitle();
- profile = browser_->GetProfile();
+ DCHECK(browser);
+ if (job_title.empty() && browser->GetSelectedTabContents())
+ job_title = browser->GetSelectedTabContents()->GetTitle();
+ profile = browser->GetProfile();
} else {
profile = ProfileManager::GetDefaultProfile();
}
@@ -587,9 +544,37 @@ void PrintDialogCloud::Init(const FilePath& path_to_file,
path_to_file, width, height, std::string(), job_title, file_type,
modal);
if (modal) {
- DCHECK(browser_);
- browser_->BrowserShowHtmlDialog(dialog_delegate, NULL);
+ DCHECK(browser);
+ browser->BrowserShowHtmlDialog(dialog_delegate, NULL);
} else {
browser::ShowHtmlDialog(NULL, profile, dialog_delegate);
}
}
+
+} // namespace internal_cloud_print_helpers
+
+namespace print_dialog_cloud {
+
+// Called on the FILE or UI thread. This is the main entry point into creating
+// the dialog.
+
+// TODO(scottbyer): The signature here will need to change as the
+// workflow through the printing code changes to allow for dynamically
+// changing page setup parameters while the dialog is active.
+void CreatePrintDialogForFile(const FilePath& path_to_file,
+ const string16& print_job_title,
+ const std::string& file_type,
+ bool modal) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE) ||
+ BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ NewRunnableFunction(&internal_cloud_print_helpers::CreateDialogImpl,
+ path_to_file,
+ print_job_title,
+ file_type,
+ modal));
+}
+
+} // end namespace
diff --git a/chrome/browser/printing/print_dialog_cloud.h b/chrome/browser/printing/print_dialog_cloud.h
index 0dde6b5..03bc736 100644
--- a/chrome/browser/printing/print_dialog_cloud.h
+++ b/chrome/browser/printing/print_dialog_cloud.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -11,45 +11,17 @@
#include "base/basictypes.h"
#include "base/string16.h"
-class Browser;
class FilePath;
-namespace IPC {
-class Message;
-}
-
-class PrintDialogCloud {
- public:
- // Called on the IO or UI thread.
- static void CreatePrintDialogForFile(const FilePath& path_to_file,
- const string16& print_job_title,
- const std::string& file_type,
- bool modal);
-
- private:
- friend class PrintDialogCloudTest;
-
- explicit PrintDialogCloud(const FilePath& path_to_file,
- const string16& print_job_title,
- const std::string& file_type,
- bool modal);
- ~PrintDialogCloud();
-
- void Init(const FilePath& path_to_file,
- const string16& print_job_title,
- const std::string& file_type,
- bool modal);
-
- // Called as a task from the UI thread, creates an object instance
- // to run the HTML/JS based print dialog for printing through the cloud.
- static void CreateDialogImpl(const FilePath& path_to_file,
- const string16& print_job_title,
- const std::string& file_type,
- bool modal);
-
- Browser* browser_;
-
- DISALLOW_COPY_AND_ASSIGN(PrintDialogCloud);
-};
+namespace print_dialog_cloud {
+
+// Called on the FILE or UI thread. Even though this may start up a modal
+// dialog, it will return immediately. The dialog is handled asynchronously.
+void CreatePrintDialogForFile(const FilePath& path_to_file,
+ const string16& print_job_title,
+ const std::string& file_type,
+ bool modal);
+
+} // end namespace
#endif // CHROME_BROWSER_PRINTING_PRINT_DIALOG_CLOUD_H_
diff --git a/chrome/browser/printing/print_dialog_cloud_internal.h b/chrome/browser/printing/print_dialog_cloud_internal.h
index 02e4d50..3a30a09 100644
--- a/chrome/browser/printing/print_dialog_cloud_internal.h
+++ b/chrome/browser/printing/print_dialog_cloud_internal.h
@@ -179,6 +179,11 @@ class CloudPrintHtmlDialogDelegate : public HtmlDialogUIDelegate {
DISALLOW_COPY_AND_ASSIGN(CloudPrintHtmlDialogDelegate);
};
+void CreateDialogImpl(const FilePath& path_to_file,
+ const string16& print_job_title,
+ const std::string& file_type,
+ bool modal);
+
} // namespace internal_cloud_print_helpers
#endif // CHROME_BROWSER_PRINTING_PRINT_DIALOG_CLOUD_INTERNAL_H_
diff --git a/chrome/browser/printing/print_dialog_cloud_uitest.cc b/chrome/browser/printing/print_dialog_cloud_uitest.cc
index b852c72..1f23af4 100644
--- a/chrome/browser/printing/print_dialog_cloud_uitest.cc
+++ b/chrome/browser/printing/print_dialog_cloud_uitest.cc
@@ -199,7 +199,7 @@ class PrintDialogCloudTest : public InProcessBrowserTest {
test_data_directory_.AppendASCII("printing/cloud_print_uitest.pdf");
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableFunction(&PrintDialogCloud::CreateDialogImpl,
+ NewRunnableFunction(&internal_cloud_print_helpers::CreateDialogImpl,
path_to_pdf,
string16(),
std::string("application/pdf"),
diff --git a/chrome/browser/printing/printing_message_filter.cc b/chrome/browser/printing/printing_message_filter.cc
index 8234bc7..95b776f 100644
--- a/chrome/browser/printing/printing_message_filter.cc
+++ b/chrome/browser/printing/printing_message_filter.cc
@@ -155,7 +155,7 @@ void PrintingMessageFilter::OnTempFileForPrintingWritten(int sequence_number) {
}
if (cloud_print_enabled_)
- PrintDialogCloud::CreatePrintDialogForFile(
+ print_dialog_cloud::CreatePrintDialogForFile(
it->second,
string16(),
std::string("application/pdf"),