diff options
author | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-18 05:49:10 +0000 |
---|---|---|
committer | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-18 05:49:10 +0000 |
commit | 4ec2c7b57f4dfe89602a68a638b3141fbba15b95 (patch) | |
tree | 2c1f882f1f74cd5aea8b9feed25c6605d311d48f | |
parent | f4a619e037465df5456bb70926812e737c7e3b84 (diff) | |
download | chromium_src-4ec2c7b57f4dfe89602a68a638b3141fbba15b95.zip chromium_src-4ec2c7b57f4dfe89602a68a638b3141fbba15b95.tar.gz chromium_src-4ec2c7b57f4dfe89602a68a638b3141fbba15b95.tar.bz2 |
Print Preview: Populating print preview tab title earlier.
BUG=92428
TEST=See bug description.
Review URL: http://codereview.chromium.org/7669035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97284 0039d316-1c4b-4281-b951-d872f2087c98
5 files changed, 27 insertions, 22 deletions
diff --git a/chrome/browser/printing/print_preview_message_handler.cc b/chrome/browser/printing/print_preview_message_handler.cc index 6cc707a..acaecba 100644 --- a/chrome/browser/printing/print_preview_message_handler.cc +++ b/chrome/browser/printing/print_preview_message_handler.cc @@ -179,9 +179,7 @@ void PrintPreviewMessageHandler::OnPagesReadyForPreview( print_preview_ui->SetPrintPreviewDataForIndex(COMPLETE_PREVIEW_DOCUMENT_INDEX, data_bytes); print_preview_ui->OnPreviewDataIsAvailable( - params.expected_pages_count, - wrapper->print_view_manager()->RenderSourceName(), - params.preview_request_id); + params.expected_pages_count, params.preview_request_id); } void PrintPreviewMessageHandler::OnPrintPreviewFailed(int document_cookie) { diff --git a/chrome/browser/printing/print_preview_tab_controller.cc b/chrome/browser/printing/print_preview_tab_controller.cc index 12a56ac..365f51e 100644 --- a/chrome/browser/printing/print_preview_tab_controller.cc +++ b/chrome/browser/printing/print_preview_tab_controller.cc @@ -222,12 +222,16 @@ void PrintPreviewTabController::OnNavEntryCommitted( nav_type == NavigationType::NEW_PAGE && source_tab_is_preview_tab) { waiting_for_new_preview_page_ = false; - // Set the initiator tab url. + // Set the initiator tab url and title. TabContents* initiator_tab = GetInitiatorTab(tab); if (initiator_tab && preview_tab->web_ui()) { PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(preview_tab->web_ui()); - print_preview_ui->SetInitiatorTabURL(initiator_tab->GetURL().spec()); + TabContentsWrapper* wrapper = + TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab); + print_preview_ui->SetInitiatorTabURLAndTitle( + initiator_tab->GetURL().spec(), + wrapper->print_view_manager()->RenderSourceName()); } return; } diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js index f262ba4..ca49d74 100644 --- a/chrome/browser/resources/print_preview/print_preview.js +++ b/chrome/browser/resources/print_preview/print_preview.js @@ -817,12 +817,15 @@ function setPluginPreviewPageCount() { * modified. * @param {number} previewResponseId The preview request id that resulted in * this response. + * @param {string} jobTitle The print job title */ -function onDidGetPreviewPageCount(pageCount, isModifiable, previewResponseId) { +function onDidGetPreviewPageCount(pageCount, isModifiable, previewResponseId, + jobTitle) { if (!isExpectedPreviewResponse(previewResponseId)) return; pageSettings.updateState(pageCount); previewModifiable = isModifiable; + document.title = localStrings.getStringF('printPreviewTitleFormat', jobTitle); cr.dispatchSimpleEvent(document, 'updateSummary'); } @@ -877,21 +880,16 @@ function onDidPreviewPage(pageNumber, previewUid, previewResponseId) { * Update the print preview when new preview data is available. * Create the PDF plugin as needed. * Called from PrintPreviewUI::PreviewDataIsAvailable(). - * @param {string} jobTitle The print job title. * @param {boolean} modifiable If the preview is modifiable. * @param {string} previewUid Preview unique identifier. * @param {number} previewResponseId The preview request id that resulted in * this response. */ -function updatePrintPreview(jobTitle, - previewUid, - previewResponseId) { +function updatePrintPreview(previewUid, previewResponseId) { if (!isExpectedPreviewResponse(previewResponseId)) return; hasPendingPreviewRequest = false; - document.title = localStrings.getStringF('printPreviewTitleFormat', jobTitle); - if (!previewModifiable) { // If the preview is not modifiable the plugin has not been created yet. createPDFPlugin(previewUid); diff --git a/chrome/browser/ui/webui/print_preview_ui.cc b/chrome/browser/ui/webui/print_preview_ui.cc index f32668d..d8b4785 100644 --- a/chrome/browser/ui/webui/print_preview_ui.cc +++ b/chrome/browser/ui/webui/print_preview_ui.cc @@ -54,8 +54,11 @@ void PrintPreviewUI::ClearAllPreviewData() { print_preview_data_service()->RemoveEntry(preview_ui_addr_str_); } -void PrintPreviewUI::SetInitiatorTabURL(const std::string& initiator_url) { +void PrintPreviewUI::SetInitiatorTabURLAndTitle( + const std::string& initiator_url, + const string16& job_title) { initiator_url_ = initiator_url; + initiator_tab_title_ = job_title; } void PrintPreviewUI::OnInitiatorTabCrashed() { @@ -79,8 +82,9 @@ void PrintPreviewUI::OnDidGetPreviewPageCount( base::FundamentalValue count(params.page_count); base::FundamentalValue modifiable(params.is_modifiable); base::FundamentalValue request_id(params.preview_request_id); + StringValue title(initiator_tab_title_); CallJavascriptFunction("onDidGetPreviewPageCount", count, modifiable, - request_id); + request_id, title); } void PrintPreviewUI::OnDidPreviewPage(int page_number, @@ -102,7 +106,6 @@ void PrintPreviewUI::OnReusePreviewData(int preview_request_id) { } void PrintPreviewUI::OnPreviewDataIsAvailable(int expected_pages_count, - const string16& job_title, int preview_request_id) { VLOG(1) << "Print preview request finished with " << expected_pages_count << " pages"; @@ -115,10 +118,9 @@ void PrintPreviewUI::OnPreviewDataIsAvailable(int expected_pages_count, expected_pages_count); initial_preview_start_time_ = base::TimeTicks(); } - base::StringValue title(job_title); base::StringValue ui_identifier(preview_ui_addr_str_); base::FundamentalValue ui_preview_request_id(preview_request_id); - CallJavascriptFunction("updatePrintPreview", title, ui_identifier, + CallJavascriptFunction("updatePrintPreview", ui_identifier, ui_preview_request_id); } diff --git a/chrome/browser/ui/webui/print_preview_ui.h b/chrome/browser/ui/webui/print_preview_ui.h index 4f3176f..3530bf2 100644 --- a/chrome/browser/ui/webui/print_preview_ui.h +++ b/chrome/browser/ui/webui/print_preview_ui.h @@ -38,7 +38,8 @@ class PrintPreviewUI : public ChromeWebUI { void ClearAllPreviewData(); // Setters - void SetInitiatorTabURL(const std::string& initiator_url); + void SetInitiatorTabURLAndTitle(const std::string& initiator_url, + const string16& initiator_tab_title); // Notifies the Web UI that there is a print preview request. There should be // a matching call to OnPreviewDataIsAvailable() or OnPrintPreviewFailed(). @@ -53,11 +54,9 @@ class PrintPreviewUI : public ChromeWebUI { void OnDidPreviewPage(int page_number, int preview_request_id); // Notifies the Web UI renderer that preview data is available. - // |expected_pages_count| specifies the total number of pages. |job_title| is - // the title of the page being previewed. |preview_request_id| indicates which - // request resulted in this response. + // |expected_pages_count| specifies the total number of pages. + // |preview_request_id| indicates which request resulted in this response. void OnPreviewDataIsAvailable(int expected_pages_count, - const string16& job_title, int preview_request_id); void OnReusePreviewData(int preview_request_id); @@ -111,6 +110,10 @@ class PrintPreviewUI : public ChromeWebUI { // when the initiator tab is closed/crashed. std::string initiator_url_; + // Store the initiator tab title, used for populating the print preview tab + // title. + string16 initiator_tab_title_; + DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI); }; |