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

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

Issue 8564044: Revert 110056 - Print Preview: Make print preview tab modal. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 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/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/ref_counted_memory.h" 11 #include "base/memory/ref_counted_memory.h"
12 #include "base/shared_memory.h" 12 #include "base/shared_memory.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/printing/print_job_manager.h" 14 #include "chrome/browser/printing/print_job_manager.h"
15 #include "chrome/browser/printing/print_preview_tab_controller.h" 15 #include "chrome/browser/printing/print_preview_tab_controller.h"
16 #include "chrome/browser/printing/print_view_manager.h"
16 #include "chrome/browser/printing/printer_query.h" 17 #include "chrome/browser/printing/printer_query.h"
17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
19 #include "chrome/browser/ui/webui/print_preview_handler.h"
18 #include "chrome/browser/ui/webui/print_preview_ui.h" 20 #include "chrome/browser/ui/webui/print_preview_ui.h"
19 #include "chrome/common/print_messages.h" 21 #include "chrome/common/print_messages.h"
20 #include "content/browser/renderer_host/render_view_host.h" 22 #include "content/browser/renderer_host/render_view_host.h"
21 #include "content/browser/tab_contents/tab_contents.h" 23 #include "content/browser/tab_contents/tab_contents.h"
22 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
25 #include "content/public/common/content_restriction.h"
23 #include "printing/page_size_margins.h" 26 #include "printing/page_size_margins.h"
24 #include "printing/print_job_constants.h" 27 #include "printing/print_job_constants.h"
25 28
26 using content::BrowserThread; 29 using content::BrowserThread;
27 30
28 namespace { 31 namespace {
29 32
30 void StopWorker(int document_cookie) { 33 void StopWorker(int document_cookie) {
31 if (document_cookie <= 0) 34 if (document_cookie <= 0)
32 return; 35 return;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 PrintHostMsg_DidGetPreviewPageCount_Params temp_params; 174 PrintHostMsg_DidGetPreviewPageCount_Params temp_params;
172 temp_params.page_count = params.expected_pages_count; 175 temp_params.page_count = params.expected_pages_count;
173 temp_params.document_cookie = params.document_cookie; 176 temp_params.document_cookie = params.document_cookie;
174 temp_params.is_modifiable = params.modifiable; 177 temp_params.is_modifiable = params.modifiable;
175 temp_params.preview_request_id = params.preview_request_id; 178 temp_params.preview_request_id = params.preview_request_id;
176 print_preview_ui->OnDidGetPreviewPageCount(temp_params); 179 print_preview_ui->OnDidGetPreviewPageCount(temp_params);
177 print_preview_ui->OnReusePreviewData(params.preview_request_id); 180 print_preview_ui->OnReusePreviewData(params.preview_request_id);
178 return; 181 return;
179 } 182 }
180 183
184 print_preview_tab->print_view_manager()->OverrideTitle(tab_contents());
185
181 // TODO(joth): This seems like a good match for using RefCountedStaticMemory 186 // TODO(joth): This seems like a good match for using RefCountedStaticMemory
182 // to avoid the memory copy, but the SetPrintPreviewData call chain below 187 // to avoid the memory copy, but the SetPrintPreviewData call chain below
183 // needs updating to accept the RefCountedMemory* base class. 188 // needs updating to accept the RefCountedMemory* base class.
184 RefCountedBytes* data_bytes = 189 RefCountedBytes* data_bytes =
185 GetDataFromHandle(params.metafile_data_handle, params.data_size); 190 GetDataFromHandle(params.metafile_data_handle, params.data_size);
186 if (!data_bytes) 191 if (!data_bytes)
187 return; 192 return;
188 193
189 print_preview_ui->SetPrintPreviewDataForIndex(COMPLETE_PREVIEW_DOCUMENT_INDEX, 194 print_preview_ui->SetPrintPreviewDataForIndex(COMPLETE_PREVIEW_DOCUMENT_INDEX,
190 data_bytes); 195 data_bytes);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 OnDidGetDefaultPageLayout) 245 OnDidGetDefaultPageLayout)
241 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewCancelled, 246 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewCancelled,
242 OnPrintPreviewCancelled) 247 OnPrintPreviewCancelled)
243 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewInvalidPrinterSettings, 248 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewInvalidPrinterSettings,
244 OnInvalidPrinterSettings) 249 OnInvalidPrinterSettings)
245 IPC_MESSAGE_UNHANDLED(handled = false) 250 IPC_MESSAGE_UNHANDLED(handled = false)
246 IPC_END_MESSAGE_MAP() 251 IPC_END_MESSAGE_MAP()
247 return handled; 252 return handled;
248 } 253 }
249 254
250 void PrintPreviewMessageHandler::NavigateToPendingEntry( 255 void PrintPreviewMessageHandler::DidStartLoading() {
251 const GURL& url, 256 if (tab_contents()->delegate() &&
252 NavigationController::ReloadType reload_type) { 257 PrintPreviewTabController::IsPrintPreviewTab(tab_contents_wrapper())) {
253 TabContentsWrapper* tab = tab_contents_wrapper(); 258 tab_contents()->SetContentRestrictions(content::CONTENT_RESTRICTION_PRINT);
254 TabContentsWrapper* preview_tab = GetPrintPreviewTab();
255 if (tab == preview_tab) {
256 // Cloud print sign-in reloads the page.
257 DCHECK(PrintPreviewTabController::IsPrintPreviewURL(url));
258 DCHECK_EQ(NavigationController::RELOAD, reload_type);
259 return;
260 } 259 }
261 } 260 }
262 261
263 } // namespace printing 262 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_preview_message_handler.h ('k') | chrome/browser/printing/print_preview_tab_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698