| 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 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/id_map.h" | 10 #include "base/id_map.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 bool HandleRequestCallback( | 122 bool HandleRequestCallback( |
| 123 const std::string& path, | 123 const std::string& path, |
| 124 const content::WebUIDataSource::GotDataCallback& callback) { | 124 const content::WebUIDataSource::GotDataCallback& callback) { |
| 125 // ChromeWebUIDataSource handles most requests except for the print preview | 125 // ChromeWebUIDataSource handles most requests except for the print preview |
| 126 // data. | 126 // data. |
| 127 if (!base::EndsWith(path, "/print.pdf", base::CompareCase::SENSITIVE)) | 127 if (!base::EndsWith(path, "/print.pdf", base::CompareCase::SENSITIVE)) |
| 128 return false; | 128 return false; |
| 129 | 129 |
| 130 // Print Preview data. | 130 // Print Preview data. |
| 131 scoped_refptr<base::RefCountedBytes> data; | 131 scoped_refptr<base::RefCountedBytes> data; |
| 132 std::vector<std::string> url_substr; | 132 std::vector<std::string> url_substr = base::SplitString( |
| 133 base::SplitString(path, '/', &url_substr); | 133 path, "/", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 134 int preview_ui_id = -1; | 134 int preview_ui_id = -1; |
| 135 int page_index = 0; | 135 int page_index = 0; |
| 136 if (url_substr.size() == 3 && | 136 if (url_substr.size() == 3 && |
| 137 base::StringToInt(url_substr[0], &preview_ui_id), | 137 base::StringToInt(url_substr[0], &preview_ui_id), |
| 138 base::StringToInt(url_substr[1], &page_index) && | 138 base::StringToInt(url_substr[1], &page_index) && |
| 139 preview_ui_id >= 0) { | 139 preview_ui_id >= 0) { |
| 140 PrintPreviewDataService::GetInstance()->GetDataEntry( | 140 PrintPreviewDataService::GetInstance()->GetDataEntry( |
| 141 preview_ui_id, page_index, &data); | 141 preview_ui_id, page_index, &data); |
| 142 } | 142 } |
| 143 if (data.get()) { | 143 if (data.get()) { |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 } | 654 } |
| 655 | 655 |
| 656 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { | 656 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { |
| 657 handler_->FileSelected(path, 0, NULL); | 657 handler_->FileSelected(path, 0, NULL); |
| 658 } | 658 } |
| 659 | 659 |
| 660 void PrintPreviewUI::SetPdfSavedClosureForTesting( | 660 void PrintPreviewUI::SetPdfSavedClosureForTesting( |
| 661 const base::Closure& closure) { | 661 const base::Closure& closure) { |
| 662 handler_->SetPdfSavedClosureForTesting(closure); | 662 handler_->SetPdfSavedClosureForTesting(closure); |
| 663 } | 663 } |
| OLD | NEW |