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> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/sync/glue/session_model_associator.h" | 13 #include "chrome/browser/sync/glue/session_model_associator.h" |
14 #include "chrome/browser/sync/glue/synced_session.h" | 14 #include "chrome/browser/sync/glue/synced_session.h" |
15 #include "chrome/browser/sync/profile_sync_service.h" | 15 #include "chrome/browser/sync/profile_sync_service.h" |
16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
17 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 17 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
18 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 18 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
19 #include "chrome/common/chrome_version_info.h" | 19 #include "chrome/common/chrome_version_info.h" |
20 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
21 #include "content/browser/tab_contents/tab_contents.h" | |
22 #include "content/browser/webui/web_ui.h" | 21 #include "content/browser/webui/web_ui.h" |
| 22 #include "content/public/browser/web_contents.h" |
23 #include "grit/browser_resources.h" | 23 #include "grit/browser_resources.h" |
24 #include "grit/chromium_strings.h" | 24 #include "grit/chromium_strings.h" |
25 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
26 #include "grit/theme_resources.h" | 26 #include "grit/theme_resources.h" |
27 #include "grit/theme_resources_standard.h" | 27 #include "grit/theme_resources_standard.h" |
28 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
29 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
30 | 30 |
| 31 using content::WebContents; |
| 32 |
31 namespace { | 33 namespace { |
32 | 34 |
33 ChromeWebUIDataSource* CreateSessionsUIHTMLSource() { | 35 ChromeWebUIDataSource* CreateSessionsUIHTMLSource() { |
34 ChromeWebUIDataSource* source = | 36 ChromeWebUIDataSource* source = |
35 new ChromeWebUIDataSource(chrome::kChromeUISessionsHost); | 37 new ChromeWebUIDataSource(chrome::kChromeUISessionsHost); |
36 | 38 |
37 source->AddLocalizedString("sessionsTitle", IDS_SESSIONS_TITLE); | 39 source->AddLocalizedString("sessionsTitle", IDS_SESSIONS_TITLE); |
38 source->AddLocalizedString("sessionsCountFormat", | 40 source->AddLocalizedString("sessionsCountFormat", |
39 IDS_SESSIONS_SESSION_COUNT_BANNER_FORMAT); | 41 IDS_SESSIONS_SESSION_COUNT_BANNER_FORMAT); |
40 source->AddLocalizedString("noSessionsMessage", | 42 source->AddLocalizedString("noSessionsMessage", |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 } | 248 } |
247 | 249 |
248 } // namespace | 250 } // namespace |
249 | 251 |
250 /////////////////////////////////////////////////////////////////////////////// | 252 /////////////////////////////////////////////////////////////////////////////// |
251 // | 253 // |
252 // SessionsUI | 254 // SessionsUI |
253 // | 255 // |
254 /////////////////////////////////////////////////////////////////////////////// | 256 /////////////////////////////////////////////////////////////////////////////// |
255 | 257 |
256 SessionsUI::SessionsUI(TabContents* contents) : ChromeWebUI(contents) { | 258 SessionsUI::SessionsUI(WebContents* contents) : ChromeWebUI(contents) { |
257 AddMessageHandler(new SessionsDOMHandler()); | 259 AddMessageHandler(new SessionsDOMHandler()); |
258 | 260 |
259 // Set up the chrome://sessions/ source. | 261 // Set up the chrome://sessions/ source. |
260 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); | 262 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); |
261 profile->GetChromeURLDataManager()->AddDataSource( | 263 profile->GetChromeURLDataManager()->AddDataSource( |
262 CreateSessionsUIHTMLSource()); | 264 CreateSessionsUIHTMLSource()); |
263 } | 265 } |
264 | 266 |
265 // static | 267 // static |
266 RefCountedMemory* SessionsUI::GetFaviconResourceBytes() { | 268 RefCountedMemory* SessionsUI::GetFaviconResourceBytes() { |
267 return ResourceBundle::GetSharedInstance(). | 269 return ResourceBundle::GetSharedInstance(). |
268 LoadDataResourceBytes(IDR_HISTORY_FAVICON); | 270 LoadDataResourceBytes(IDR_HISTORY_FAVICON); |
269 } | 271 } |
OLD | NEW |