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/task_manager_ui.h" | 5 #include "chrome/browser/ui/webui/task_manager_ui.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/task_manager/task_manager.h" | 9 #include "chrome/browser/task_manager/task_manager.h" |
10 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 10 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 localized_strings.SetString("cpu_column", | 71 localized_strings.SetString("cpu_column", |
72 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_CPU_COLUMN)); | 72 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_CPU_COLUMN)); |
73 localized_strings.SetString("private_memory_column", | 73 localized_strings.SetString("private_memory_column", |
74 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN)); | 74 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN)); |
75 | 75 |
76 SetFontAndTextDirection(&localized_strings); | 76 SetFontAndTextDirection(&localized_strings); |
77 | 77 |
78 static const base::StringPiece task_manager_html( | 78 static const base::StringPiece task_manager_html( |
79 ResourceBundle::GetSharedInstance().GetRawDataResource( | 79 ResourceBundle::GetSharedInstance().GetRawDataResource( |
80 IDR_TASK_MANAGER_HTML)); | 80 IDR_TASK_MANAGER_HTML)); |
81 const std::string full_html = jstemplate_builder::GetI18nTemplateHtml( | 81 std::string full_html = jstemplate_builder::GetI18nTemplateHtml( |
82 task_manager_html, &localized_strings); | 82 task_manager_html, &localized_strings); |
83 | 83 |
84 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); | 84 SendResponse(request_id, base::RefCountedString::TakeString(&full_html)); |
85 html_bytes->data.resize(full_html.size()); | |
86 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); | |
87 | |
88 SendResponse(request_id, html_bytes); | |
89 } | 85 } |
90 | 86 |
91 } // namespace | 87 } // namespace |
92 | 88 |
93 /////////////////////////////////////////////////////////////////////////////// | 89 /////////////////////////////////////////////////////////////////////////////// |
94 // | 90 // |
95 // TaskManagerUI | 91 // TaskManagerUI |
96 // | 92 // |
97 /////////////////////////////////////////////////////////////////////////////// | 93 /////////////////////////////////////////////////////////////////////////////// |
98 | 94 |
99 TaskManagerUI::TaskManagerUI(TabContents* contents) : ChromeWebUI(contents) { | 95 TaskManagerUI::TaskManagerUI(TabContents* contents) : ChromeWebUI(contents) { |
100 TaskManagerHandler* handler = | 96 TaskManagerHandler* handler = |
101 new TaskManagerHandler(TaskManager::GetInstance()); | 97 new TaskManagerHandler(TaskManager::GetInstance()); |
102 | 98 |
103 handler->Attach(this); | 99 handler->Attach(this); |
104 handler->Init(); | 100 handler->Init(); |
105 AddMessageHandler(handler); | 101 AddMessageHandler(handler); |
106 | 102 |
107 TaskManagerUIHTMLSource* html_source = new TaskManagerUIHTMLSource(); | 103 TaskManagerUIHTMLSource* html_source = new TaskManagerUIHTMLSource(); |
108 | 104 |
109 // Set up the chrome://taskmanager/ source. | 105 // Set up the chrome://taskmanager/ source. |
110 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 106 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); |
111 } | 107 } |
112 | 108 |
OLD | NEW |