OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/options/options_ui.h" | 5 #include "chrome/browser/dom_ui/options/options_ui.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // OptionsUIHTMLSource | 78 // OptionsUIHTMLSource |
79 // | 79 // |
80 //////////////////////////////////////////////////////////////////////////////// | 80 //////////////////////////////////////////////////////////////////////////////// |
81 | 81 |
82 OptionsUIHTMLSource::OptionsUIHTMLSource(DictionaryValue* localized_strings) | 82 OptionsUIHTMLSource::OptionsUIHTMLSource(DictionaryValue* localized_strings) |
83 : DataSource(chrome::kChromeUISettingsHost, MessageLoop::current()) { | 83 : DataSource(chrome::kChromeUISettingsHost, MessageLoop::current()) { |
84 DCHECK(localized_strings); | 84 DCHECK(localized_strings); |
85 localized_strings_.reset(localized_strings); | 85 localized_strings_.reset(localized_strings); |
86 } | 86 } |
87 | 87 |
| 88 OptionsUIHTMLSource::~OptionsUIHTMLSource() {} |
| 89 |
88 void OptionsUIHTMLSource::StartDataRequest(const std::string& path, | 90 void OptionsUIHTMLSource::StartDataRequest(const std::string& path, |
89 bool is_off_the_record, | 91 bool is_off_the_record, |
90 int request_id) { | 92 int request_id) { |
91 SetFontAndTextDirection(localized_strings_.get()); | 93 SetFontAndTextDirection(localized_strings_.get()); |
92 | 94 |
93 static const base::StringPiece options_html( | 95 static const base::StringPiece options_html( |
94 ResourceBundle::GetSharedInstance().GetRawDataResource( | 96 ResourceBundle::GetSharedInstance().GetRawDataResource( |
95 IDR_OPTIONS_HTML)); | 97 IDR_OPTIONS_HTML)); |
96 const std::string full_html = jstemplate_builder::GetI18nTemplateHtml( | 98 const std::string full_html = jstemplate_builder::GetI18nTemplateHtml( |
97 options_html, localized_strings_.get()); | 99 options_html, localized_strings_.get()); |
98 | 100 |
99 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); | 101 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); |
100 html_bytes->data.resize(full_html.size()); | 102 html_bytes->data.resize(full_html.size()); |
101 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); | 103 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); |
102 | 104 |
103 SendResponse(request_id, html_bytes); | 105 SendResponse(request_id, html_bytes); |
104 } | 106 } |
105 | 107 |
| 108 std::string OptionsUIHTMLSource::GetMimeType(const std::string&) const { |
| 109 return "text/html"; |
| 110 } |
| 111 |
106 //////////////////////////////////////////////////////////////////////////////// | 112 //////////////////////////////////////////////////////////////////////////////// |
107 // | 113 // |
108 // OptionsPageUIHandler | 114 // OptionsPageUIHandler |
109 // | 115 // |
110 //////////////////////////////////////////////////////////////////////////////// | 116 //////////////////////////////////////////////////////////////////////////////// |
111 | 117 |
112 OptionsPageUIHandler::OptionsPageUIHandler() { | 118 OptionsPageUIHandler::OptionsPageUIHandler() { |
113 } | 119 } |
114 | 120 |
115 OptionsPageUIHandler::~OptionsPageUIHandler() { | 121 OptionsPageUIHandler::~OptionsPageUIHandler() { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 OptionsPageUIHandler* handler_raw) { | 248 OptionsPageUIHandler* handler_raw) { |
243 scoped_ptr<OptionsPageUIHandler> handler(handler_raw); | 249 scoped_ptr<OptionsPageUIHandler> handler(handler_raw); |
244 DCHECK(handler.get()); | 250 DCHECK(handler.get()); |
245 // Add only if handler's service is enabled. | 251 // Add only if handler's service is enabled. |
246 if (handler->IsEnabled()) { | 252 if (handler->IsEnabled()) { |
247 handler->GetLocalizedValues(localized_strings); | 253 handler->GetLocalizedValues(localized_strings); |
248 // Add handler to the list and also pass the ownership. | 254 // Add handler to the list and also pass the ownership. |
249 AddMessageHandler(handler.release()->Attach(this)); | 255 AddMessageHandler(handler.release()->Attach(this)); |
250 } | 256 } |
251 } | 257 } |
OLD | NEW |