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

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

Issue 8136027: Print Preview: Make print preview tab modal. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase, more fixes Created 9 years, 2 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
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 "base/memory/ref_counted_memory.h" 10 #include "base/memory/ref_counted_memory.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 PrintHostMsg_DidGetPreviewPageCount_Params temp_params; 164 PrintHostMsg_DidGetPreviewPageCount_Params temp_params;
165 temp_params.page_count = params.expected_pages_count; 165 temp_params.page_count = params.expected_pages_count;
166 temp_params.document_cookie = params.document_cookie; 166 temp_params.document_cookie = params.document_cookie;
167 temp_params.is_modifiable = params.modifiable; 167 temp_params.is_modifiable = params.modifiable;
168 temp_params.preview_request_id = params.preview_request_id; 168 temp_params.preview_request_id = params.preview_request_id;
169 print_preview_ui->OnDidGetPreviewPageCount(temp_params); 169 print_preview_ui->OnDidGetPreviewPageCount(temp_params);
170 print_preview_ui->OnReusePreviewData(params.preview_request_id); 170 print_preview_ui->OnReusePreviewData(params.preview_request_id);
171 return; 171 return;
172 } 172 }
173 173
174 print_preview_tab->print_view_manager()->OverrideTitle(tab_contents());
175
176 // TODO(joth): This seems like a good match for using RefCountedStaticMemory 174 // TODO(joth): This seems like a good match for using RefCountedStaticMemory
177 // to avoid the memory copy, but the SetPrintPreviewData call chain below 175 // to avoid the memory copy, but the SetPrintPreviewData call chain below
178 // needs updating to accept the RefCountedMemory* base class. 176 // needs updating to accept the RefCountedMemory* base class.
179 RefCountedBytes* data_bytes = 177 RefCountedBytes* data_bytes =
180 GetDataFromHandle(params.metafile_data_handle, params.data_size); 178 GetDataFromHandle(params.metafile_data_handle, params.data_size);
181 if (!data_bytes) 179 if (!data_bytes)
182 return; 180 return;
183 181
184 print_preview_ui->SetPrintPreviewDataForIndex(COMPLETE_PREVIEW_DOCUMENT_INDEX, 182 print_preview_ui->SetPrintPreviewDataForIndex(COMPLETE_PREVIEW_DOCUMENT_INDEX,
185 data_bytes); 183 data_bytes);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 OnInvalidPrinterSettings) 237 OnInvalidPrinterSettings)
240 IPC_MESSAGE_UNHANDLED(handled = false) 238 IPC_MESSAGE_UNHANDLED(handled = false)
241 IPC_END_MESSAGE_MAP() 239 IPC_END_MESSAGE_MAP()
242 return handled; 240 return handled;
243 } 241 }
244 242
245 void PrintPreviewMessageHandler::DidStartLoading() { 243 void PrintPreviewMessageHandler::DidStartLoading() {
246 if (tab_contents()->delegate() && 244 if (tab_contents()->delegate() &&
247 PrintPreviewTabController::IsPrintPreviewTab(tab_contents_wrapper())) { 245 PrintPreviewTabController::IsPrintPreviewTab(tab_contents_wrapper())) {
248 tab_contents()->SetContentRestrictions(CONTENT_RESTRICTION_PRINT); 246 tab_contents()->SetContentRestrictions(CONTENT_RESTRICTION_PRINT);
247
248 // Need to get the initiator tab to enabled advanced printing.
249 PrintPreviewTabController* tab_controller =
250 PrintPreviewTabController::GetInstance();
251 if (tab_controller) {
252 TabContentsWrapper* initiator_tab =
253 tab_controller->GetInitiatorTab(tab_contents_wrapper());
kmadhusu 2011/10/13 18:52:18 Store the tab_contents_wrapper() in a local variab
Lei Zhang 2011/10/13 21:12:12 Done.
254 if (initiator_tab) {
255 TabContents* contents = initiator_tab->tab_contents();
256 contents->SetContentRestrictions(contents->content_restrictions());
257 }
258 }
249 } 259 }
250 } 260 }
251 261
262 void PrintPreviewMessageHandler::NavigateToPendingEntry(
263 const GURL& url,
264 NavigationController::ReloadType reload_type) {
kmadhusu 2011/10/13 18:52:18 Do you need to call StopWorker() here?
Lei Zhang 2011/10/13 21:12:12 I don't think so. Why do you say that?
265 TabContentsWrapper* tab = tab_contents_wrapper();
266 TabContentsWrapper* preview_tab = GetPrintPreviewTab();
267 if (tab == preview_tab) {
268 NOTREACHED();
269 return;
270 }
271 if (preview_tab)
272 tab->print_view_manager()->PrintPreviewDone();
273 }
274
252 } // namespace printing 275 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698