summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/printing/print_dialog_cloud.cc18
-rw-r--r--chrome/browser/printing/print_dialog_cloud_internal.h16
-rw-r--r--chrome/browser/printing/print_dialog_cloud_unittest.cc11
3 files changed, 28 insertions, 17 deletions
diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc
index bd23746..5da3a2ff 100644
--- a/chrome/browser/printing/print_dialog_cloud.cc
+++ b/chrome/browser/printing/print_dialog_cloud.cc
@@ -235,9 +235,7 @@ void CloudPrintDataSender::SendPrintDataFile() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
AutoLock lock(lock_);
if (helper_ && print_data_.get()) {
- // TODO(scottbyer) - fill this in with the title or URL of the
- // original page.
- StringValue title("Chrome Print Test");
+ StringValue title(print_job_title_);
// Send the print data to the dialog contents. The JavaScript
// function is a preliminary API for prototyping purposes and is
@@ -341,7 +339,7 @@ scoped_refptr<CloudPrintDataSender>
CloudPrintFlowHandler::CreateCloudPrintDataSender() {
DCHECK(dom_ui_);
print_data_helper_.reset(new CloudPrintDataSenderHelper(dom_ui_));
- return new CloudPrintDataSender(print_data_helper_.get());
+ return new CloudPrintDataSender(print_data_helper_.get(), print_job_title_);
}
void CloudPrintFlowHandler::HandleSendPrintData(const Value* value) {
@@ -404,8 +402,9 @@ void CloudPrintFlowHandler::HandleSetPageParameters(const Value* value) {
CloudPrintHtmlDialogDelegate::CloudPrintHtmlDialogDelegate(
const FilePath& path_to_pdf,
int width, int height,
- const std::string& json_arguments)
- : flow_handler_(new CloudPrintFlowHandler(path_to_pdf)),
+ const std::string& json_arguments,
+ const string16& print_job_title)
+ : flow_handler_(new CloudPrintFlowHandler(path_to_pdf, print_job_title)),
owns_flow_handler_(true) {
Init(width, height, json_arguments);
}
@@ -420,7 +419,7 @@ CloudPrintHtmlDialogDelegate::CloudPrintHtmlDialogDelegate(
}
void CloudPrintHtmlDialogDelegate::Init(
- int width, int height, const std::string& json_arguments) {
+ int width, int height, const std::string& json_arguments) {
// This information is needed to show the dialog HTML content.
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
std::string cloud_print_url(chrome::kCloudPrintResourcesURL);
@@ -511,12 +510,15 @@ PrintDialogCloud::PrintDialogCloud(const FilePath& path_to_pdf)
// TODO(scottbyer): Verify GAIA login valid, execute GAIA login if not (should
// be distilled out of bookmark sync.)
+ string16 print_job_title;
+ 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.
HtmlDialogUIDelegate* dialog_delegate =
new internal_cloud_print_helpers::CloudPrintHtmlDialogDelegate(
- path_to_pdf, 500, 400, std::string());
+ path_to_pdf, 500, 400, 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 b0a804f..1cddfef 100644
--- a/chrome/browser/printing/print_dialog_cloud_internal.h
+++ b/chrome/browser/printing/print_dialog_cloud_internal.h
@@ -65,8 +65,9 @@ class CloudPrintDataSender
public:
// The owner of this object is also expected to own and control the
// lifetime of the helper.
- explicit CloudPrintDataSender(CloudPrintDataSenderHelper* helper)
- : helper_(helper) {}
+ CloudPrintDataSender(CloudPrintDataSenderHelper* helper,
+ const string16& print_job_title)
+ : helper_(helper), print_job_title_(print_job_title) {}
// Calls to read in the PDF file (on the FILE thread) then send that
// information to the dialog renderer (on the IO thread). We know
@@ -86,6 +87,7 @@ class CloudPrintDataSender
Lock lock_;
CloudPrintDataSenderHelper* volatile helper_;
scoped_ptr<StringValue> print_data_;
+ string16 print_job_title_;
DISALLOW_COPY_AND_ASSIGN(CloudPrintDataSender);
};
@@ -102,8 +104,10 @@ class CloudPrintHtmlDialogDelegate;
class CloudPrintFlowHandler : public DOMMessageHandler,
public NotificationObserver {
public:
- explicit CloudPrintFlowHandler(const FilePath& path_to_pdf)
- : path_to_pdf_(path_to_pdf) {}
+ explicit CloudPrintFlowHandler(const FilePath& path_to_pdf,
+ const string16& print_job_title)
+ : path_to_pdf_(path_to_pdf),
+ print_job_title_(print_job_title) {}
virtual ~CloudPrintFlowHandler() {
// This will also cancel any task in flight.
CancelAnyRunningTask();
@@ -137,6 +141,7 @@ class CloudPrintFlowHandler : public DOMMessageHandler,
CloudPrintHtmlDialogDelegate* dialog_delegate_;
NotificationRegistrar registrar_;
FilePath path_to_pdf_;
+ string16 print_job_title_;
scoped_refptr<CloudPrintDataSender> print_data_sender_;
scoped_ptr<CloudPrintDataSenderHelper> print_data_helper_;
@@ -150,7 +155,8 @@ class CloudPrintHtmlDialogDelegate : public HtmlDialogUIDelegate {
public:
CloudPrintHtmlDialogDelegate(const FilePath& path_to_pdf,
int width, int height,
- const std::string& json_arguments);
+ const std::string& json_arguments,
+ const string16& print_job_title);
virtual ~CloudPrintHtmlDialogDelegate();
// HTMLDialogUIDelegate implementation:
diff --git a/chrome/browser/printing/print_dialog_cloud_unittest.cc b/chrome/browser/printing/print_dialog_cloud_unittest.cc
index 1cee8c3..8fb0aa5 100644
--- a/chrome/browser/printing/print_dialog_cloud_unittest.cc
+++ b/chrome/browser/printing/print_dialog_cloud_unittest.cc
@@ -64,8 +64,9 @@ class MockCloudPrintFlowHandler
: public CloudPrintFlowHandler,
public base::SupportsWeakPtr<MockCloudPrintFlowHandler> {
public:
- explicit MockCloudPrintFlowHandler(const FilePath& path)
- : CloudPrintFlowHandler(path) {};
+ explicit MockCloudPrintFlowHandler(const FilePath& path,
+ const string16& title)
+ : CloudPrintFlowHandler(path, title) {}
MOCK_METHOD0(DestructorCalled, void());
MOCK_METHOD0(RegisterMessages, void());
MOCK_METHOD3(Observe,
@@ -171,9 +172,10 @@ class CloudPrintDataSenderTest : public testing::Test {
protected:
virtual void SetUp() {
+ string16 mock_job_title;
mock_helper_.reset(new MockCloudPrintDataSenderHelper);
print_data_sender_ =
- new CloudPrintDataSender(mock_helper_.get());
+ new CloudPrintDataSender(mock_helper_.get(), mock_job_title);
}
scoped_refptr<CloudPrintDataSender> print_data_sender_;
@@ -245,8 +247,9 @@ class CloudPrintHtmlDialogDelegateTest : public testing::Test {
protected:
virtual void SetUp() {
FilePath mock_path;
+ string16 mock_string;
MockCloudPrintFlowHandler* handler =
- new MockCloudPrintFlowHandler(mock_path);
+ new MockCloudPrintFlowHandler(mock_path, mock_string);
mock_flow_handler_ = handler->AsWeakPtr();
EXPECT_CALL(*mock_flow_handler_.get(), SetDialogDelegate(_));
EXPECT_CALL(*mock_flow_handler_.get(), SetDialogDelegate(NULL));