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/singleton.h" | 10 #include "base/singleton.h" |
11 #include "base/string_piece.h" | 11 #include "base/string_piece.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/common/jstemplate_builder.h" | 14 #include "chrome/common/jstemplate_builder.h" |
15 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
16 #include "content/browser/browser_thread.h" | 16 #include "content/browser/browser_thread.h" |
17 #include "content/browser/tab_contents/tab_contents.h" | 17 #include "content/browser/tab_contents/tab_contents.h" |
18 #include "grit/browser_resources.h" | 18 #include "grit/browser_resources.h" |
19 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
20 | 20 |
21 /** | 21 /** |
22 * TextfieldsUIHTMLSource implementation. | 22 * TextfieldsUIHTMLSource implementation. |
23 */ | 23 */ |
24 TextfieldsUIHTMLSource::TextfieldsUIHTMLSource() | 24 TextfieldsUIHTMLSource::TextfieldsUIHTMLSource() |
25 : DataSource(chrome::kChromeUITextfieldsHost, MessageLoop::current()) { | 25 : DataSource(chrome::kChromeUITextfieldsHost, MessageLoop::current()) { |
26 } | 26 } |
27 | 27 |
28 void TextfieldsUIHTMLSource::StartDataRequest(const std::string& path, | 28 void TextfieldsUIHTMLSource::StartDataRequest(const std::string& path, |
29 bool is_off_the_record, | 29 bool is_incognito, |
30 int request_id) { | 30 int request_id) { |
31 const std::string full_html = ResourceBundle::GetSharedInstance() | 31 const std::string full_html = ResourceBundle::GetSharedInstance() |
32 .GetRawDataResource(IDR_TEXTFIELDS_HTML).as_string(); | 32 .GetRawDataResource(IDR_TEXTFIELDS_HTML).as_string(); |
33 | 33 |
34 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); | 34 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); |
35 html_bytes->data.resize(full_html.size()); | 35 html_bytes->data.resize(full_html.size()); |
36 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); | 36 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); |
37 | 37 |
38 SendResponse(request_id, html_bytes); | 38 SendResponse(request_id, html_bytes); |
39 } | 39 } |
(...skipping 26 matching lines...) Expand all Loading... |
66 TextfieldsUI::TextfieldsUI(TabContents* contents) : WebUI(contents) { | 66 TextfieldsUI::TextfieldsUI(TabContents* contents) : WebUI(contents) { |
67 TextfieldsDOMHandler* handler = new TextfieldsDOMHandler(); | 67 TextfieldsDOMHandler* handler = new TextfieldsDOMHandler(); |
68 AddMessageHandler(handler); | 68 AddMessageHandler(handler); |
69 handler->Attach(this); | 69 handler->Attach(this); |
70 | 70 |
71 TextfieldsUIHTMLSource* html_source = new TextfieldsUIHTMLSource(); | 71 TextfieldsUIHTMLSource* html_source = new TextfieldsUIHTMLSource(); |
72 | 72 |
73 // Set up the chrome://textfields/ source. | 73 // Set up the chrome://textfields/ source. |
74 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 74 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); |
75 } | 75 } |
OLD | NEW |