| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/print_preview/print_preview_ui.h" | 5 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/printing/background_printing_manager.h" | 16 #include "chrome/browser/printing/background_printing_manager.h" |
| 17 #include "chrome/browser/printing/print_preview_data_service.h" | 17 #include "chrome/browser/printing/print_preview_data_service.h" |
| 18 #include "chrome/browser/printing/print_preview_tab_controller.h" | 18 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 21 #include "chrome/browser/ui/webui/chrome_url_data_manager_factory.h" |
| 21 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 22 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
| 22 #include "chrome/browser/ui/webui/print_preview/print_preview_data_source.h" | 23 #include "chrome/browser/ui/webui/print_preview/print_preview_data_source.h" |
| 23 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h" | 24 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h" |
| 24 #include "chrome/common/print_messages.h" | 25 #include "chrome/common/print_messages.h" |
| 25 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 26 #include "printing/page_size_margins.h" | 27 #include "printing/page_size_margins.h" |
| 27 #include "printing/print_job_constants.h" | 28 #include "printing/print_job_constants.h" |
| 28 #include "ui/gfx/rect.h" | 29 #include "ui/gfx/rect.h" |
| 29 | 30 |
| 30 using content::WebContents; | 31 using content::WebContents; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 initial_preview_start_time_(base::TimeTicks::Now()), | 80 initial_preview_start_time_(base::TimeTicks::Now()), |
| 80 handler_(NULL), | 81 handler_(NULL), |
| 81 source_is_modifiable_(true), | 82 source_is_modifiable_(true), |
| 82 tab_closed_(false) { | 83 tab_closed_(false) { |
| 83 printing::PrintPreviewTabController* controller = | 84 printing::PrintPreviewTabController* controller = |
| 84 printing::PrintPreviewTabController::GetInstance(); | 85 printing::PrintPreviewTabController::GetInstance(); |
| 85 is_dummy_ = (!controller || !controller->is_creating_print_preview_tab()); | 86 is_dummy_ = (!controller || !controller->is_creating_print_preview_tab()); |
| 86 | 87 |
| 87 // Set up the chrome://print/ data source. | 88 // Set up the chrome://print/ data source. |
| 88 Profile* profile = Profile::FromWebUI(web_ui); | 89 Profile* profile = Profile::FromWebUI(web_ui); |
| 89 profile->GetChromeURLDataManager()->AddDataSource( | 90 ChromeURLDataManagerFactory::GetForProfile(profile)-> |
| 90 new PrintPreviewDataSource(is_dummy_)); | 91 AddDataSource(new PrintPreviewDataSource(is_dummy_)); |
| 91 if (is_dummy_) | 92 if (is_dummy_) |
| 92 return; | 93 return; |
| 93 | 94 |
| 94 // WebUI owns |handler_|. | 95 // WebUI owns |handler_|. |
| 95 handler_ = new PrintPreviewHandler(); | 96 handler_ = new PrintPreviewHandler(); |
| 96 web_ui->AddMessageHandler(handler_); | 97 web_ui->AddMessageHandler(handler_); |
| 97 | 98 |
| 98 preview_ui_addr_str_ = GetPrintPreviewUIAddress(); | 99 preview_ui_addr_str_ = GetPrintPreviewUIAddress(); |
| 99 g_print_preview_request_id_map.Get().Set(preview_ui_addr_str_, -1); | 100 g_print_preview_request_id_map.Get().Set(preview_ui_addr_str_, -1); |
| 100 } | 101 } |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); | 323 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); |
| 323 if (!delegate) | 324 if (!delegate) |
| 324 return; | 325 return; |
| 325 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(""); | 326 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(""); |
| 326 delegate->OnDialogCloseFromWebUI(); | 327 delegate->OnDialogCloseFromWebUI(); |
| 327 } | 328 } |
| 328 | 329 |
| 329 void PrintPreviewUI::OnReloadPrintersList() { | 330 void PrintPreviewUI::OnReloadPrintersList() { |
| 330 web_ui()->CallJavascriptFunction("reloadPrintersList"); | 331 web_ui()->CallJavascriptFunction("reloadPrintersList"); |
| 331 } | 332 } |
| OLD | NEW |