diff options
author | scottbyer@google.com <scottbyer@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-02 21:57:35 +0000 |
---|---|---|
committer | scottbyer@google.com <scottbyer@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-02 21:57:35 +0000 |
commit | ea161da013c64b7d63921a3a23289a667d284e0e (patch) | |
tree | a69d71b4b815b7a61143e101147ea0124ddf56b8 /chrome/browser/printing | |
parent | bdcbfd7bca18798c4ae1169e3c79f5c816df390f (diff) | |
download | chromium_src-ea161da013c64b7d63921a3a23289a667d284e0e.zip chromium_src-ea161da013c64b7d63921a3a23289a667d284e0e.tar.gz chromium_src-ea161da013c64b7d63921a3a23289a667d284e0e.tar.bz2 |
Cloud Print Dialog work.
Allow an HTML dialog to suppress the title bar in a Chromium OS bubble window.
For the Cloud Print dialog, remember the last size requested by the contents.
BUG=chromium-os:8494
TEST=none
Review URL: http://codereview.chromium.org/4110010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64824 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/printing')
-rw-r--r-- | chrome/browser/printing/cloud_print/cloud_print_setup_flow.h | 1 | ||||
-rw-r--r-- | chrome/browser/printing/print_dialog_cloud.cc | 43 | ||||
-rw-r--r-- | chrome/browser/printing/print_dialog_cloud_internal.h | 2 |
3 files changed, 40 insertions, 6 deletions
diff --git a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.h b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.h index d79e578..c6f71ea 100644 --- a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.h +++ b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.h @@ -70,6 +70,7 @@ class CloudPrintSetupFlow : public HtmlDialogUIDelegate, virtual void OnCloseContents(TabContents* source, bool* out_close_dialog); virtual std::wstring GetDialogTitle() const; virtual bool IsDialogModal() const; + virtual bool ShouldShowDialogTitle() const { return true; } // GaiaAuthConsumer implementation. virtual void OnClientLoginFailure( diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc index 89b750c..1af016e 100644 --- a/chrome/browser/printing/print_dialog_cloud.cc +++ b/chrome/browser/printing/print_dialog_cloud.cc @@ -15,14 +15,17 @@ #include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/dom_ui/dom_ui.h" #include "chrome/browser/dom_ui/dom_ui_util.h" -#include "chrome/browser/dom_ui/html_dialog_ui.h" +#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/printing/cloud_print/cloud_print_url.h" +#include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tab_contents/tab_contents_view.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" +#include "chrome/common/pref_names.h" #include "chrome/common/render_messages_params.h" #include "chrome/common/url_constants.h" #include "webkit/glue/webpreferences.h" @@ -92,7 +95,6 @@ // high-level flow (where the PDF data is generated before even // bringing up the dialog) isn't what we want. - namespace internal_cloud_print_helpers { bool GetRealOrInt(const DictionaryValue& dictionary, @@ -245,7 +247,6 @@ void CloudPrintFlowHandler::CancelAnyRunningTask() { } } - void CloudPrintFlowHandler::RegisterMessages() { if (!dom_ui_) return; @@ -378,6 +379,16 @@ void CloudPrintFlowHandler::HandleSetPageParameters(const ListValue* args) { // that point. } +void CloudPrintFlowHandler::StoreDialogClientSize() const { + if (dom_ui_ && dom_ui_->tab_contents() && dom_ui_->tab_contents()->view()) { + gfx::Size size = dom_ui_->tab_contents()->view()->GetContainerSize(); + dom_ui_->GetProfile()->GetPrefs()->SetInteger( + prefs::kCloudPrintDialogWidth, size.width()); + dom_ui_->GetProfile()->GetPrefs()->SetInteger( + prefs::kCloudPrintDialogHeight, size.height()); + } +} + CloudPrintHtmlDialogDelegate::CloudPrintHtmlDialogDelegate( const FilePath& path_to_pdf, int width, int height, @@ -452,6 +463,8 @@ std::string CloudPrintHtmlDialogDelegate::GetDialogArgs() const { void CloudPrintHtmlDialogDelegate::OnDialogClosed( const std::string& json_retval) { + // Get the final dialog size and store it. + flow_handler_->StoreDialogClientSize(); delete this; } @@ -461,6 +474,10 @@ void CloudPrintHtmlDialogDelegate::OnCloseContents(TabContents* source, *out_close_dialog = true; } +bool CloudPrintHtmlDialogDelegate::ShouldShowDialogTitle() const { + return false; +} + } // end of namespace internal_cloud_print_helpers // static, called on the IO thread. This is the main entry point into @@ -493,11 +510,25 @@ PrintDialogCloud::PrintDialogCloud(const FilePath& path_to_pdf) if (browser_ && browser_->GetSelectedTabContents()) print_job_title = browser_->GetSelectedTabContents()->GetTitle(); - // TODO(scottbyer): Get the dialog width, height from the dialog - // contents, and take the screen size into account. + const int kDefaultWidth = 497; + const int kDefaultHeight = 332; + + PrefService* pref_service = browser_->GetProfile()->GetPrefs(); + DCHECK(pref_service); + if (!pref_service->FindPreference(prefs::kCloudPrintDialogWidth)) { + pref_service->RegisterIntegerPref(prefs::kCloudPrintDialogWidth, + kDefaultWidth); + } + if (!pref_service->FindPreference(prefs::kCloudPrintDialogHeight)) { + pref_service->RegisterIntegerPref(prefs::kCloudPrintDialogHeight, + kDefaultHeight); + } + + int width = pref_service->GetInteger(prefs::kCloudPrintDialogWidth); + int height = pref_service->GetInteger(prefs::kCloudPrintDialogHeight); HtmlDialogUIDelegate* dialog_delegate = new internal_cloud_print_helpers::CloudPrintHtmlDialogDelegate( - path_to_pdf, 497, 354, std::string(), print_job_title); + path_to_pdf, width, height, std::string(), print_job_title); browser_->BrowserShowHtmlDialog(dialog_delegate, NULL); } diff --git a/chrome/browser/printing/print_dialog_cloud_internal.h b/chrome/browser/printing/print_dialog_cloud_internal.h index 4148623..9c83154 100644 --- a/chrome/browser/printing/print_dialog_cloud_internal.h +++ b/chrome/browser/printing/print_dialog_cloud_internal.h @@ -114,6 +114,7 @@ class CloudPrintFlowHandler : public DOMMessageHandler, virtual void SetDialogDelegate(CloudPrintHtmlDialogDelegate *delegate); void CancelAnyRunningTask(); + void StoreDialogClientSize() const; private: // For unit testing. @@ -150,6 +151,7 @@ class CloudPrintHtmlDialogDelegate : public HtmlDialogUIDelegate { virtual std::string GetDialogArgs() const; virtual void OnDialogClosed(const std::string& json_retval); virtual void OnCloseContents(TabContents* source, bool* out_close_dialog); + virtual bool ShouldShowDialogTitle() const; private: friend class ::CloudPrintHtmlDialogDelegateTest; |