| Index: chrome/browser/printing/print_dialog_cloud.cc
|
| diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc
|
| index 3fdad4bc0489c90c9fdab2f67b8240962792bd4b..1af016e06236b857629fd0e28a736ae34fc248da 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,
|
| @@ -425,7 +436,7 @@ bool CloudPrintHtmlDialogDelegate::IsDialogModal() const {
|
| }
|
|
|
| std::wstring CloudPrintHtmlDialogDelegate::GetDialogTitle() const {
|
| - return l10n_util::GetString(IDS_CLOUD_PRINT_TITLE);
|
| + return std::wstring();
|
| }
|
|
|
| GURL CloudPrintHtmlDialogDelegate::GetDialogContentURL() const {
|
| @@ -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, 500, 400, std::string(), print_job_title);
|
| + path_to_pdf, width, height, std::string(), print_job_title);
|
| browser_->BrowserShowHtmlDialog(dialog_delegate, NULL);
|
| }
|
|
|
|
|