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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 SET_LOCALIZED_STRING(localized_strings, SQLITE_MEMORY_USED_COLUMN); | 78 SET_LOCALIZED_STRING(localized_strings, SQLITE_MEMORY_USED_COLUMN); |
79 SET_LOCALIZED_STRING(localized_strings, JAVASCRIPT_MEMORY_ALLOCATED_COLUMN); | 79 SET_LOCALIZED_STRING(localized_strings, JAVASCRIPT_MEMORY_ALLOCATED_COLUMN); |
80 | 80 |
81 #undef SET_LOCALIZED_STRING | 81 #undef SET_LOCALIZED_STRING |
82 | 82 |
83 SetFontAndTextDirection(&localized_strings); | 83 SetFontAndTextDirection(&localized_strings); |
84 | 84 |
85 static const base::StringPiece task_manager_html( | 85 static const base::StringPiece task_manager_html( |
86 ResourceBundle::GetSharedInstance().GetRawDataResource( | 86 ResourceBundle::GetSharedInstance().GetRawDataResource( |
87 IDR_TASK_MANAGER_HTML)); | 87 IDR_TASK_MANAGER_HTML)); |
88 const std::string full_html = jstemplate_builder::GetI18nTemplateHtml( | 88 std::string full_html = jstemplate_builder::GetI18nTemplateHtml( |
89 task_manager_html, &localized_strings); | 89 task_manager_html, &localized_strings); |
90 | 90 |
91 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); | 91 SendResponse(request_id, base::RefCountedString::TakeString(&full_html)); |
92 html_bytes->data.resize(full_html.size()); | |
93 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); | |
94 | |
95 SendResponse(request_id, html_bytes); | |
96 } | 92 } |
97 | 93 |
98 } // namespace | 94 } // namespace |
99 | 95 |
100 /////////////////////////////////////////////////////////////////////////////// | 96 /////////////////////////////////////////////////////////////////////////////// |
101 // | 97 // |
102 // TaskManagerUI | 98 // TaskManagerUI |
103 // | 99 // |
104 /////////////////////////////////////////////////////////////////////////////// | 100 /////////////////////////////////////////////////////////////////////////////// |
105 | 101 |
106 TaskManagerUI::TaskManagerUI(TabContents* contents) : ChromeWebUI(contents) { | 102 TaskManagerUI::TaskManagerUI(TabContents* contents) : ChromeWebUI(contents) { |
107 TaskManagerHandler* handler = | 103 TaskManagerHandler* handler = |
108 new TaskManagerHandler(TaskManager::GetInstance()); | 104 new TaskManagerHandler(TaskManager::GetInstance()); |
109 | 105 |
110 handler->Attach(this); | 106 handler->Attach(this); |
111 handler->Init(); | 107 handler->Init(); |
112 AddMessageHandler(handler); | 108 AddMessageHandler(handler); |
113 | 109 |
114 TaskManagerUIHTMLSource* html_source = new TaskManagerUIHTMLSource(); | 110 TaskManagerUIHTMLSource* html_source = new TaskManagerUIHTMLSource(); |
115 | 111 |
116 // Set up the chrome://taskmanager/ source. | 112 // Set up the chrome://taskmanager/ source. |
117 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 113 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); |
118 } | 114 } |
119 | 115 |
OLD | NEW |