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/id_map.h" | 9 #include "base/id_map.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 int preview_ui_id = -1; | 132 int preview_ui_id = -1; |
133 int page_index = 0; | 133 int page_index = 0; |
134 if (url_substr.size() == 3 && | 134 if (url_substr.size() == 3 && |
135 base::StringToInt(url_substr[0], &preview_ui_id), | 135 base::StringToInt(url_substr[0], &preview_ui_id), |
136 base::StringToInt(url_substr[1], &page_index) && | 136 base::StringToInt(url_substr[1], &page_index) && |
137 preview_ui_id >= 0) { | 137 preview_ui_id >= 0) { |
138 PrintPreviewDataService::GetInstance()->GetDataEntry( | 138 PrintPreviewDataService::GetInstance()->GetDataEntry( |
139 preview_ui_id, page_index, &data); | 139 preview_ui_id, page_index, &data); |
140 } | 140 } |
141 if (data.get()) { | 141 if (data.get()) { |
142 callback.Run(data); | 142 callback.Run(data.get()); |
143 return true; | 143 return true; |
144 } | 144 } |
145 // Invalid request. | 145 // Invalid request. |
146 scoped_refptr<base::RefCountedBytes> empty_bytes(new base::RefCountedBytes); | 146 scoped_refptr<base::RefCountedBytes> empty_bytes(new base::RefCountedBytes); |
147 callback.Run(empty_bytes); | 147 callback.Run(empty_bytes.get()); |
148 return true; | 148 return true; |
149 } | 149 } |
150 | 150 |
151 content::WebUIDataSource* CreatePrintPreviewUISource() { | 151 content::WebUIDataSource* CreatePrintPreviewUISource() { |
152 content::WebUIDataSource* source = | 152 content::WebUIDataSource* source = |
153 content::WebUIDataSource::Create(chrome::kChromeUIPrintHost); | 153 content::WebUIDataSource::Create(chrome::kChromeUIPrintHost); |
154 #if defined(OS_CHROMEOS) | 154 #if defined(OS_CHROMEOS) |
155 source->AddLocalizedString("title", | 155 source->AddLocalizedString("title", |
156 IDS_PRINT_PREVIEW_GOOGLE_CLOUD_PRINT_TITLE); | 156 IDS_PRINT_PREVIEW_GOOGLE_CLOUD_PRINT_TITLE); |
157 #else | 157 #else |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 delegate->OnDialogCloseFromWebUI(); | 575 delegate->OnDialogCloseFromWebUI(); |
576 } | 576 } |
577 | 577 |
578 void PrintPreviewUI::OnReloadPrintersList() { | 578 void PrintPreviewUI::OnReloadPrintersList() { |
579 web_ui()->CallJavascriptFunction("reloadPrintersList"); | 579 web_ui()->CallJavascriptFunction("reloadPrintersList"); |
580 } | 580 } |
581 | 581 |
582 void PrintPreviewUI::OnPrintPreviewScalingDisabled() { | 582 void PrintPreviewUI::OnPrintPreviewScalingDisabled() { |
583 web_ui()->CallJavascriptFunction("printScalingDisabledForSourcePDF"); | 583 web_ui()->CallJavascriptFunction("printScalingDisabledForSourcePDF"); |
584 } | 584 } |
OLD | NEW |