OLD | NEW |
---|---|
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" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewCancelled, | 234 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewCancelled, |
237 OnPrintPreviewCancelled) | 235 OnPrintPreviewCancelled) |
238 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewInvalidPrinterSettings, | 236 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewInvalidPrinterSettings, |
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 TabContentsWrapper* tab_wrapper = tab_contents_wrapper(); |
247 PrintPreviewTabController::IsPrintPreviewTab(tab_contents_wrapper())) { | 245 TabContents* tab = tab_contents(); |
248 tab_contents()->SetContentRestrictions(content::CONTENT_RESTRICTION_PRINT); | 246 if (tab->delegate() && |
247 PrintPreviewTabController::IsPrintPreviewTab(tab_wrapper)) { | |
248 tab->SetContentRestrictions(content::CONTENT_RESTRICTION_PRINT); | |
249 | |
250 // Need to get the initiator tab to enabled advanced printing. | |
251 PrintPreviewTabController* tab_controller = | |
252 PrintPreviewTabController::GetInstance(); | |
253 if (tab_controller) { | |
254 TabContentsWrapper* initiator_tab_wrapper = | |
255 tab_controller->GetInitiatorTab(tab_wrapper); | |
256 if (initiator_tab_wrapper) { | |
257 TabContents* initiator_tab = initiator_tab_wrapper->tab_contents(); | |
258 initiator_tab->SetContentRestrictions( | |
259 initiator_tab->content_restrictions()); | |
260 } | |
261 } | |
vandebo (ex-Chrome)
2011/11/02 20:50:30
What should happen if either of these fail?
Lei Zhang
2011/11/02 22:50:03
Kausalya was wondering where we unset this, and it
| |
262 } | |
263 } | |
264 | |
265 void PrintPreviewMessageHandler::NavigateToPendingEntry( | |
266 const GURL& url, | |
267 NavigationController::ReloadType reload_type) { | |
268 TabContentsWrapper* tab = tab_contents_wrapper(); | |
269 TabContentsWrapper* preview_tab = GetPrintPreviewTab(); | |
270 if (tab == preview_tab) { | |
271 // Cloud print sign-in reloads the page. | |
272 DCHECK(PrintPreviewTabController::IsPrintPreviewURL(url)); | |
273 DCHECK_EQ(NavigationController::RELOAD, reload_type); | |
274 return; | |
249 } | 275 } |
250 } | 276 } |
251 | 277 |
252 } // namespace printing | 278 } // namespace printing |
OLD | NEW |