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/cloud_print/cloud_print_setup_source.h" | 5 #include "chrome/browser/printing/cloud_print/cloud_print_setup_source.h" |
6 | 6 |
7 #include <algorithm> | |
8 | |
9 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
10 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
11 #include "base/values.h" | 9 #include "base/values.h" |
12 #include "chrome/browser/google/google_util.h" | 10 #include "chrome/browser/google/google_util.h" |
13 #include "chrome/common/jstemplate_builder.h" | 11 #include "chrome/common/jstemplate_builder.h" |
14 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
15 #include "grit/browser_resources.h" | 13 #include "grit/browser_resources.h" |
16 #include "grit/chromium_strings.h" | 14 #include "grit/chromium_strings.h" |
17 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
18 #include "grit/locale_settings.h" | 16 #include "grit/locale_settings.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 static const base::StringPiece html(ResourceBundle::GetSharedInstance() | 110 static const base::StringPiece html(ResourceBundle::GetSharedInstance() |
113 .GetRawDataResource(IDR_CLOUD_PRINT_SETUP_DONE_HTML)); | 111 .GetRawDataResource(IDR_CLOUD_PRINT_SETUP_DONE_HTML)); |
114 SetFontAndTextDirection(dict); | 112 SetFontAndTextDirection(dict); |
115 response = jstemplate_builder::GetI18nTemplateHtml(html, dict); | 113 response = jstemplate_builder::GetI18nTemplateHtml(html, dict); |
116 } else if (path_raw == kCloudPrintSetupFlowPath) { | 114 } else if (path_raw == kCloudPrintSetupFlowPath) { |
117 static const base::StringPiece html( | 115 static const base::StringPiece html( |
118 ResourceBundle::GetSharedInstance() | 116 ResourceBundle::GetSharedInstance() |
119 .GetRawDataResource(IDR_CLOUD_PRINT_SETUP_FLOW_HTML)); | 117 .GetRawDataResource(IDR_CLOUD_PRINT_SETUP_FLOW_HTML)); |
120 response = html.as_string(); | 118 response = html.as_string(); |
121 } | 119 } |
122 // Send the response. | 120 |
123 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); | 121 SendResponse(request_id, base::RefCountedString::TakeString(&response)); |
124 html_bytes->data.resize(response.size()); | |
125 std::copy(response.begin(), response.end(), html_bytes->data.begin()); | |
126 SendResponse(request_id, html_bytes); | |
127 } | 122 } |
128 | 123 |
129 std::string CloudPrintSetupSource::GetMimeType(const std::string& path) const { | 124 std::string CloudPrintSetupSource::GetMimeType(const std::string& path) const { |
130 return "text/html"; | 125 return "text/html"; |
131 } | 126 } |
132 | 127 |
133 std::string CloudPrintSetupSource::GetLocalizedUrl( | 128 std::string CloudPrintSetupSource::GetLocalizedUrl( |
134 const std::string& url) const { | 129 const std::string& url) const { |
135 GURL original_url(url); | 130 GURL original_url(url); |
136 DCHECK(original_url.is_valid()); | 131 DCHECK(original_url.is_valid()); |
137 GURL localized_url = google_util::AppendGoogleLocaleParam(original_url); | 132 GURL localized_url = google_util::AppendGoogleLocaleParam(original_url); |
138 return localized_url.spec(); | 133 return localized_url.spec(); |
139 } | 134 } |
OLD | NEW |