| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // Example: | 117 // Example: |
| 118 // chrome://print/123/10/print.pdf | 118 // chrome://print/123/10/print.pdf |
| 119 // | 119 // |
| 120 // Requests to chrome://print with paths not ending in /print.pdf are used | 120 // Requests to chrome://print with paths not ending in /print.pdf are used |
| 121 // to return the markup or other resources for the print preview page itself. | 121 // to return the markup or other resources for the print preview page itself. |
| 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", true)) | 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; |
| 133 base::SplitString(path, '/', &url_substr); | 133 base::SplitString(path, '/', &url_substr); |
| 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), |
| (...skipping 516 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 |