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/sessions_ui.h" | 5 #include "chrome/browser/ui/webui/sessions_ui.h" |
6 | 6 |
| 7 #include <algorithm> |
| 8 |
7 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/sync/engine/syncapi.h" | 10 #include "chrome/browser/sync/engine/syncapi.h" |
9 #include "chrome/browser/sync/glue/session_model_associator.h" | 11 #include "chrome/browser/sync/glue/session_model_associator.h" |
10 #include "chrome/browser/sync/profile_sync_service.h" | 12 #include "chrome/browser/sync/profile_sync_service.h" |
11 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
12 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 14 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
13 #include "chrome/common/chrome_version_info.h" | 15 #include "chrome/common/chrome_version_info.h" |
14 #include "chrome/common/jstemplate_builder.h" | 16 #include "chrome/common/jstemplate_builder.h" |
15 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
16 #include "content/browser/webui/web_ui.h" | 18 #include "content/browser/webui/web_ui.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings); | 72 ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings); |
71 | 73 |
72 static const base::StringPiece sessions_html( | 74 static const base::StringPiece sessions_html( |
73 ResourceBundle::GetSharedInstance(). | 75 ResourceBundle::GetSharedInstance(). |
74 GetRawDataResource(IDR_SESSIONS_HTML)); | 76 GetRawDataResource(IDR_SESSIONS_HTML)); |
75 std::string full_html = | 77 std::string full_html = |
76 jstemplate_builder::GetI18nTemplateHtml(sessions_html, | 78 jstemplate_builder::GetI18nTemplateHtml(sessions_html, |
77 &localized_strings); | 79 &localized_strings); |
78 jstemplate_builder::AppendJsTemplateSourceHtml(&full_html); | 80 jstemplate_builder::AppendJsTemplateSourceHtml(&full_html); |
79 | 81 |
80 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); | 82 SendResponse(request_id, base::RefCountedString::TakeString(&full_html)); |
81 html_bytes->data.resize(full_html.size()); | |
82 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); | |
83 | |
84 SendResponse(request_id, html_bytes); | |
85 } | 83 } |
86 | 84 |
87 //////////////////////////////////////////////////////////////////////////////// | 85 //////////////////////////////////////////////////////////////////////////////// |
88 // | 86 // |
89 // SessionsDOMHandler | 87 // SessionsDOMHandler |
90 // | 88 // |
91 //////////////////////////////////////////////////////////////////////////////// | 89 //////////////////////////////////////////////////////////////////////////////// |
92 | 90 |
93 // The handler for Javascript messages for the chrome://sessions/ page. | 91 // The handler for Javascript messages for the chrome://sessions/ page. |
94 class SessionsDOMHandler : public WebUIMessageHandler { | 92 class SessionsDOMHandler : public WebUIMessageHandler { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 | 287 |
290 // Set up the chrome://sessions/ source. | 288 // Set up the chrome://sessions/ source. |
291 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 289 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); |
292 } | 290 } |
293 | 291 |
294 // static | 292 // static |
295 RefCountedMemory* SessionsUI::GetFaviconResourceBytes() { | 293 RefCountedMemory* SessionsUI::GetFaviconResourceBytes() { |
296 return ResourceBundle::GetSharedInstance(). | 294 return ResourceBundle::GetSharedInstance(). |
297 LoadDataResourceBytes(IDR_HISTORY_FAVICON); | 295 LoadDataResourceBytes(IDR_HISTORY_FAVICON); |
298 } | 296 } |
OLD | NEW |