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

Side by Side Diff: chrome/browser/printing/print_preview_message_handler.cc

Issue 7313035: Print Preview: Associating preview requests and responses using an identifier (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing Created 9 years, 5 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/print_preview.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/printing/print_preview_message_handler.h" 5 #include "chrome/browser/printing/print_preview_message_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 TabContentsWrapper* wrapper = 112 TabContentsWrapper* wrapper =
113 TabContentsWrapper::GetCurrentWrapperForContents(print_preview_tab); 113 TabContentsWrapper::GetCurrentWrapperForContents(print_preview_tab);
114 114
115 if (params.reuse_existing_data) { 115 if (params.reuse_existing_data) {
116 // Need to match normal rendering where we are expected to send this. 116 // Need to match normal rendering where we are expected to send this.
117 print_preview_ui->OnDidGetPreviewPageCount(params.expected_pages_count); 117 print_preview_ui->OnDidGetPreviewPageCount(params.expected_pages_count);
118 118
119 print_preview_ui->OnPreviewDataIsAvailable( 119 print_preview_ui->OnPreviewDataIsAvailable(
120 params.expected_pages_count, 120 params.expected_pages_count,
121 wrapper->print_view_manager()->RenderSourceName(), 121 wrapper->print_view_manager()->RenderSourceName(),
122 params.modifiable); 122 params.modifiable,
123 params.preview_request_id);
123 return; 124 return;
124 } 125 }
125 126
126 base::SharedMemory* shared_buf = 127 base::SharedMemory* shared_buf =
127 new base::SharedMemory(params.metafile_data_handle, true); 128 new base::SharedMemory(params.metafile_data_handle, true);
128 if (!shared_buf->Map(params.data_size)) { 129 if (!shared_buf->Map(params.data_size)) {
129 NOTREACHED(); 130 NOTREACHED();
130 delete shared_buf; 131 delete shared_buf;
131 return; 132 return;
132 } 133 }
133 134
134 wrapper->print_view_manager()->OverrideTitle(tab_contents()); 135 wrapper->print_view_manager()->OverrideTitle(tab_contents());
135 136
136 char* preview_data = static_cast<char*>(shared_buf->memory()); 137 char* preview_data = static_cast<char*>(shared_buf->memory());
137 uint32 preview_data_size = params.data_size; 138 uint32 preview_data_size = params.data_size;
138 139
139 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); 140 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes);
140 html_bytes->data.resize(preview_data_size); 141 html_bytes->data.resize(preview_data_size);
141 std::vector<unsigned char>::iterator it = html_bytes->data.begin(); 142 std::vector<unsigned char>::iterator it = html_bytes->data.begin();
142 for (uint32 i = 0; i < preview_data_size; ++i, ++it) 143 for (uint32 i = 0; i < preview_data_size; ++i, ++it)
143 *it = *(preview_data + i); 144 *it = *(preview_data + i);
144 145
145 print_preview_ui->SetPrintPreviewData(html_bytes.get()); 146 print_preview_ui->SetPrintPreviewData(html_bytes.get());
146 print_preview_ui->OnPreviewDataIsAvailable( 147 print_preview_ui->OnPreviewDataIsAvailable(
147 params.expected_pages_count, 148 params.expected_pages_count,
148 wrapper->print_view_manager()->RenderSourceName(), 149 wrapper->print_view_manager()->RenderSourceName(),
149 params.modifiable); 150 params.modifiable,
151 params.preview_request_id);
150 } 152 }
151 153
152 void PrintPreviewMessageHandler::OnPrintPreviewFailed(int document_cookie) { 154 void PrintPreviewMessageHandler::OnPrintPreviewFailed(int document_cookie) {
153 // Always need to stop the worker. 155 // Always need to stop the worker.
154 StopWorker(document_cookie); 156 StopWorker(document_cookie);
155 157
156 // Inform the print preview tab of the failure. 158 // Inform the print preview tab of the failure.
157 TabContents* print_preview_tab = GetPrintPreviewTab(); 159 TabContents* print_preview_tab = GetPrintPreviewTab();
158 // User might have closed it already. 160 // User might have closed it already.
159 if (!print_preview_tab) 161 if (!print_preview_tab)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 } 210 }
209 211
210 void PrintPreviewMessageHandler::DidStartLoading() { 212 void PrintPreviewMessageHandler::DidStartLoading() {
211 if (tab_contents()->delegate() && 213 if (tab_contents()->delegate() &&
212 printing::PrintPreviewTabController::IsPrintPreviewTab(tab_contents())) { 214 printing::PrintPreviewTabController::IsPrintPreviewTab(tab_contents())) {
213 tab_contents()->SetContentRestrictions(CONTENT_RESTRICTION_PRINT); 215 tab_contents()->SetContentRestrictions(CONTENT_RESTRICTION_PRINT);
214 } 216 }
215 } 217 }
216 218
217 } // namespace printing 219 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/print_preview.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698