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/ui/webui/textfields_ui.h" | 5 #include "chrome/browser/ui/webui/textfields_ui.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 /** | 22 /** |
23 * TextfieldsUIHTMLSource implementation. | 23 * TextfieldsUIHTMLSource implementation. |
24 */ | 24 */ |
25 TextfieldsUIHTMLSource::TextfieldsUIHTMLSource() | 25 TextfieldsUIHTMLSource::TextfieldsUIHTMLSource() |
26 : DataSource(chrome::kChromeUITextfieldsHost, MessageLoop::current()) { | 26 : DataSource(chrome::kChromeUITextfieldsHost, MessageLoop::current()) { |
27 } | 27 } |
28 | 28 |
29 void TextfieldsUIHTMLSource::StartDataRequest(const std::string& path, | 29 void TextfieldsUIHTMLSource::StartDataRequest(const std::string& path, |
30 bool is_incognito, | 30 bool is_incognito, |
31 int request_id) { | 31 int request_id) { |
32 const std::string full_html = ResourceBundle::GetSharedInstance() | 32 std::string full_html = ResourceBundle::GetSharedInstance() |
33 .GetRawDataResource(IDR_TEXTFIELDS_HTML).as_string(); | 33 .GetRawDataResource(IDR_TEXTFIELDS_HTML).as_string(); |
bulach
2011/07/22 11:16:54
use LoadDataResourceBytes as options_ui.cc instead
| |
34 | 34 |
35 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); | 35 SendResponse(request_id, base::RefCountedString::TakeString(&full_html)); |
36 html_bytes->data.resize(full_html.size()); | |
37 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); | |
38 | |
39 SendResponse(request_id, html_bytes); | |
40 } | 36 } |
41 | 37 |
42 std::string TextfieldsUIHTMLSource::GetMimeType( | 38 std::string TextfieldsUIHTMLSource::GetMimeType( |
43 const std::string& /* path */) const { | 39 const std::string& /* path */) const { |
44 return "text/html"; | 40 return "text/html"; |
45 } | 41 } |
46 | 42 |
47 TextfieldsUIHTMLSource::~TextfieldsUIHTMLSource() {} | 43 TextfieldsUIHTMLSource::~TextfieldsUIHTMLSource() {} |
48 | 44 |
49 /** | 45 /** |
(...skipping 17 matching lines...) Expand all Loading... | |
67 TextfieldsUI::TextfieldsUI(TabContents* contents) : ChromeWebUI(contents) { | 63 TextfieldsUI::TextfieldsUI(TabContents* contents) : ChromeWebUI(contents) { |
68 TextfieldsDOMHandler* handler = new TextfieldsDOMHandler(); | 64 TextfieldsDOMHandler* handler = new TextfieldsDOMHandler(); |
69 AddMessageHandler(handler); | 65 AddMessageHandler(handler); |
70 handler->Attach(this); | 66 handler->Attach(this); |
71 | 67 |
72 TextfieldsUIHTMLSource* html_source = new TextfieldsUIHTMLSource(); | 68 TextfieldsUIHTMLSource* html_source = new TextfieldsUIHTMLSource(); |
73 | 69 |
74 // Set up the chrome://textfields/ source. | 70 // Set up the chrome://textfields/ source. |
75 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 71 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); |
76 } | 72 } |
OLD | NEW |