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

Unified Diff: chrome/browser/printing/print_dialog_cloud.cc

Issue 4396001: Merge 64807 & 64824 - Cloud Print Dialog work (Closed) Base URL: svn://svn.chromium.org/chrome/branches/552/src/
Patch Set: Created 10 years, 1 month 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
Index: chrome/browser/printing/print_dialog_cloud.cc
===================================================================
--- chrome/browser/printing/print_dialog_cloud.cc (revision 64933)
+++ chrome/browser/printing/print_dialog_cloud.cc (working copy)
@@ -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,
@@ -225,7 +227,6 @@
}
}
-
void CloudPrintFlowHandler::RegisterMessages() {
if (!dom_ui_)
return;
@@ -358,6 +359,16 @@
// 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,
@@ -405,7 +416,7 @@
}
std::wstring CloudPrintHtmlDialogDelegate::GetDialogTitle() const {
- return l10n_util::GetString(IDS_CLOUD_PRINT_TITLE);
+ return std::wstring();
}
GURL CloudPrintHtmlDialogDelegate::GetDialogContentURL() const {
@@ -432,6 +443,8 @@
void CloudPrintHtmlDialogDelegate::OnDialogClosed(
const std::string& json_retval) {
+ // Get the final dialog size and store it.
+ flow_handler_->StoreDialogClientSize();
delete this;
}
@@ -441,6 +454,10 @@
*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
@@ -473,11 +490,25 @@
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);
}
« no previous file with comments | « chrome/browser/printing/cloud_print/cloud_print_setup_flow.h ('k') | chrome/browser/printing/print_dialog_cloud_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698