diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-03 00:11:07 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-03 00:11:07 +0000 |
commit | 05acb55477b46dea9faf43e874f2bbb9f0640cb8 (patch) | |
tree | 3dbcd1823e16a18e2037fe0c52cb0aea84f1205a /chrome/browser/printing | |
parent | 87d4d4c0fc7677350e465fac93890b68f9f3be96 (diff) | |
download | chromium_src-05acb55477b46dea9faf43e874f2bbb9f0640cb8.zip chromium_src-05acb55477b46dea9faf43e874f2bbb9f0640cb8.tar.gz chromium_src-05acb55477b46dea9faf43e874f2bbb9f0640cb8.tar.bz2 |
Cloud print: Code cleanup for PrintDialogCloud and friends.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6368047
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73547 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/printing')
-rw-r--r-- | chrome/browser/printing/print_dialog_cloud.cc | 42 | ||||
-rw-r--r-- | chrome/browser/printing/print_dialog_cloud.h | 8 | ||||
-rw-r--r-- | chrome/browser/printing/print_dialog_cloud_internal.h | 13 |
3 files changed, 33 insertions, 30 deletions
diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc index 8a0805a..4721c47 100644 --- a/chrome/browser/printing/print_dialog_cloud.cc +++ b/chrome/browser/printing/print_dialog_cloud.cc @@ -6,7 +6,6 @@ #include "chrome/browser/printing/print_dialog_cloud_internal.h" #include "base/base64.h" -#include "base/command_line.h" #include "base/file_util.h" #include "base/json/json_reader.h" #include "base/values.h" @@ -23,8 +22,6 @@ #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/browser/ui/browser_dialogs.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/notification_source.h" #include "chrome/common/notification_type.h" @@ -405,6 +402,7 @@ CloudPrintHtmlDialogDelegate::CloudPrintHtmlDialogDelegate( Init(width, height, json_arguments); } +// For unit testing. CloudPrintHtmlDialogDelegate::CloudPrintHtmlDialogDelegate( CloudPrintFlowHandler* flow_handler, int width, int height, @@ -416,12 +414,11 @@ CloudPrintHtmlDialogDelegate::CloudPrintHtmlDialogDelegate( Init(width, height, json_arguments); } -void CloudPrintHtmlDialogDelegate::Init( - int width, int height, const std::string& json_arguments) { +void CloudPrintHtmlDialogDelegate::Init(int width, int height, + const std::string& json_arguments) { // This information is needed to show the dialog HTML content. DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - std::string cloud_print_url(chrome::kCloudPrintResourcesURL); - params_.url = GURL(cloud_print_url); + params_.url = GURL(chrome::kCloudPrintResourcesURL); params_.height = height; params_.width = width; params_.json_input = json_arguments; @@ -494,7 +491,7 @@ bool CloudPrintHtmlDialogDelegate::ShouldShowDialogTitle() const { return false; } -} // end of namespace internal_cloud_print_helpers +} // namespace internal_cloud_print_helpers // static, called on the IO thread. This is the main entry point into // creating the dialog. @@ -528,26 +525,32 @@ void PrintDialogCloud::CreateDialogImpl(const FilePath& path_to_pdf, PrintDialogCloud::PrintDialogCloud(const FilePath& path_to_pdf, const string16& print_job_title, bool modal) - : browser_(BrowserList::GetLastActive()), - print_job_title_(print_job_title), - modal_(modal) { + : browser_(BrowserList::GetLastActive()) { + Init(path_to_pdf, print_job_title, modal); +} + +PrintDialogCloud::~PrintDialogCloud() { +} +void PrintDialogCloud::Init(const FilePath& path_to_pdf, + const string16& print_job_title, + 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; - PrefService* pref_service = NULL; - if (modal_) { + if (modal) { DCHECK(browser_); - if (print_job_title_.empty() && browser_->GetSelectedTabContents()) - print_job_title_ = browser_->GetSelectedTabContents()->GetTitle(); + if (job_title.empty() && browser_->GetSelectedTabContents()) + job_title = browser_->GetSelectedTabContents()->GetTitle(); profile = browser_->GetProfile(); } else { profile = ProfileManager::GetDefaultProfile(); } DCHECK(profile); - pref_service = profile->GetPrefs(); + PrefService* pref_service = profile->GetPrefs(); DCHECK(pref_service); if (!pref_service->FindPreference(prefs::kCloudPrintDialogWidth)) { pref_service->RegisterIntegerPref(prefs::kCloudPrintDialogWidth, @@ -563,14 +566,11 @@ PrintDialogCloud::PrintDialogCloud(const FilePath& path_to_pdf, HtmlDialogUIDelegate* dialog_delegate = new internal_cloud_print_helpers::CloudPrintHtmlDialogDelegate( - path_to_pdf, width, height, std::string(), print_job_title_, modal_); - if (modal_) { + path_to_pdf, width, height, std::string(), job_title, modal); + if (modal) { DCHECK(browser_); browser_->BrowserShowHtmlDialog(dialog_delegate, NULL); } else { browser::ShowHtmlDialog(NULL, profile, dialog_delegate); } } - -PrintDialogCloud::~PrintDialogCloud() { -} diff --git a/chrome/browser/printing/print_dialog_cloud.h b/chrome/browser/printing/print_dialog_cloud.h index e4cd4cb..01fc5c9 100644 --- a/chrome/browser/printing/print_dialog_cloud.h +++ b/chrome/browser/printing/print_dialog_cloud.h @@ -7,11 +7,11 @@ #pragma once #include "base/basictypes.h" -#include "base/gtest_prod_util.h" #include "base/string16.h" class Browser; class FilePath; + namespace IPC { class Message; } @@ -31,6 +31,10 @@ class PrintDialogCloud { bool modal); ~PrintDialogCloud(); + void Init(const FilePath& path_to_pdf, + const string16& print_job_title, + 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_pdf, @@ -38,8 +42,6 @@ class PrintDialogCloud { bool modal); Browser* browser_; - string16 print_job_title_; - bool modal_; DISALLOW_COPY_AND_ASSIGN(PrintDialogCloud); }; diff --git a/chrome/browser/printing/print_dialog_cloud_internal.h b/chrome/browser/printing/print_dialog_cloud_internal.h index fb1dbc8..6ed27b4 100644 --- a/chrome/browser/printing/print_dialog_cloud_internal.h +++ b/chrome/browser/printing/print_dialog_cloud_internal.h @@ -107,18 +107,18 @@ class CloudPrintFlowHandler : public DOMMessageHandler, void HandleSendPrintData(const ListValue* args); void HandleSetPageParameters(const ListValue* args); + virtual void SetDialogDelegate(CloudPrintHtmlDialogDelegate *delegate); + void StoreDialogClientSize() const; + + private: + virtual scoped_refptr<CloudPrintDataSender> CreateCloudPrintDataSender(); + // Call to get the debugger loaded on our hosted dialog page // specifically. Since we're not in an official browser tab, only // way to get the debugger going. void ShowDebugger(); - virtual void SetDialogDelegate(CloudPrintHtmlDialogDelegate *delegate); void CancelAnyRunningTask(); - void StoreDialogClientSize() const; - - private: - // For unit testing. - virtual scoped_refptr<CloudPrintDataSender> CreateCloudPrintDataSender(); CloudPrintHtmlDialogDelegate* dialog_delegate_; NotificationRegistrar registrar_; @@ -157,6 +157,7 @@ class CloudPrintHtmlDialogDelegate : public HtmlDialogUIDelegate { private: friend class ::CloudPrintHtmlDialogDelegateTest; + // For unit testing. CloudPrintHtmlDialogDelegate(CloudPrintFlowHandler* flow_handler, int width, int height, const std::string& json_arguments, |