OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/about_ui.h" | 5 #include "chrome/browser/ui/webui/about_ui.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "base/strings/stringprintf.h" | 31 #include "base/strings/stringprintf.h" |
32 #include "base/strings/utf_string_conversions.h" | 32 #include "base/strings/utf_string_conversions.h" |
33 #include "base/sys_info.h" | 33 #include "base/sys_info.h" |
34 #include "base/task_scheduler/post_task.h" | 34 #include "base/task_scheduler/post_task.h" |
35 #include "base/threading/thread.h" | 35 #include "base/threading/thread.h" |
36 #include "base/values.h" | 36 #include "base/values.h" |
37 #include "build/build_config.h" | 37 #include "build/build_config.h" |
38 #include "chrome/browser/about_flags.h" | 38 #include "chrome/browser/about_flags.h" |
39 #include "chrome/browser/browser_process.h" | 39 #include "chrome/browser/browser_process.h" |
40 #include "chrome/browser/defaults.h" | 40 #include "chrome/browser/defaults.h" |
41 #include "chrome/browser/memory/tab_manager.h" | |
42 #include "chrome/browser/memory/tab_stats.h" | |
43 #include "chrome/browser/net/predictor.h" | 41 #include "chrome/browser/net/predictor.h" |
44 #include "chrome/browser/profiles/profile.h" | 42 #include "chrome/browser/profiles/profile.h" |
45 #include "chrome/browser/profiles/profile_manager.h" | 43 #include "chrome/browser/profiles/profile_manager.h" |
| 44 #include "chrome/browser/resource_coordinator/tab_manager.h" |
| 45 #include "chrome/browser/resource_coordinator/tab_stats.h" |
46 #include "chrome/browser/ui/browser_dialogs.h" | 46 #include "chrome/browser/ui/browser_dialogs.h" |
47 #include "chrome/common/chrome_paths.h" | 47 #include "chrome/common/chrome_paths.h" |
48 #include "chrome/common/url_constants.h" | 48 #include "chrome/common/url_constants.h" |
49 #include "chrome/grit/browser_resources.h" | 49 #include "chrome/grit/browser_resources.h" |
50 #include "chrome/grit/chromium_strings.h" | 50 #include "chrome/grit/chromium_strings.h" |
51 #include "chrome/grit/generated_resources.h" | 51 #include "chrome/grit/generated_resources.h" |
52 #include "chrome/grit/locale_settings.h" | 52 #include "chrome/grit/locale_settings.h" |
53 #include "components/grit/components_resources.h" | 53 #include "components/grit/components_resources.h" |
54 #include "components/strings/grit/components_locale_settings.h" | 54 #include "components/strings/grit/components_locale_settings.h" |
55 #include "content/public/browser/browser_thread.h" | 55 #include "content/public/browser/browser_thread.h" |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 AppendHeader(&output, 0, "About discards"); | 459 AppendHeader(&output, 0, "About discards"); |
460 output.append(base::StringPrintf("<meta http-equiv='refresh' content='2;%s'>", | 460 output.append(base::StringPrintf("<meta http-equiv='refresh' content='2;%s'>", |
461 chrome::kChromeUIDiscardsURL)); | 461 chrome::kChromeUIDiscardsURL)); |
462 AddContentSecurityPolicy(&output); | 462 AddContentSecurityPolicy(&output); |
463 output.append(WrapWithTag("p", "Discarding a tab...")); | 463 output.append(WrapWithTag("p", "Discarding a tab...")); |
464 AppendFooter(&output); | 464 AppendFooter(&output); |
465 return output; | 465 return output; |
466 } | 466 } |
467 | 467 |
468 std::vector<std::string> GetHtmlTabDescriptorsForDiscardPage() { | 468 std::vector<std::string> GetHtmlTabDescriptorsForDiscardPage() { |
469 memory::TabManager* tab_manager = g_browser_process->GetTabManager(); | 469 resource_coordinator::TabManager* tab_manager = |
470 memory::TabStatsList stats = tab_manager->GetTabStats(); | 470 g_browser_process->GetTabManager(); |
| 471 resource_coordinator::TabStatsList stats = tab_manager->GetTabStats(); |
471 std::vector<std::string> titles; | 472 std::vector<std::string> titles; |
472 titles.reserve(stats.size()); | 473 titles.reserve(stats.size()); |
473 for (memory::TabStatsList::iterator it = stats.begin(); it != stats.end(); | 474 for (resource_coordinator::TabStatsList::iterator it = stats.begin(); |
474 ++it) { | 475 it != stats.end(); ++it) { |
475 std::string str; | 476 std::string str; |
476 str.reserve(4096); | 477 str.reserve(4096); |
477 str += "<b>"; | 478 str += "<b>"; |
478 str += it->is_app ? "[App] " : ""; | 479 str += it->is_app ? "[App] " : ""; |
479 str += it->is_internal_page ? "[Internal] " : ""; | 480 str += it->is_internal_page ? "[Internal] " : ""; |
480 str += it->is_media ? "[Media] " : ""; | 481 str += it->is_media ? "[Media] " : ""; |
481 str += it->is_pinned ? "[Pinned] " : ""; | 482 str += it->is_pinned ? "[Pinned] " : ""; |
482 str += it->is_discarded ? "[Discarded] " : ""; | 483 str += it->is_discarded ? "[Discarded] " : ""; |
483 str += "</b>"; | 484 str += "</b>"; |
484 str += net::EscapeForHTML(base::UTF16ToUTF8(it->title)); | 485 str += net::EscapeForHTML(base::UTF16ToUTF8(it->title)); |
485 #if defined(OS_CHROMEOS) | 486 #if defined(OS_CHROMEOS) |
486 str += base::StringPrintf(" (%d) ", it->oom_score); | 487 str += base::StringPrintf(" (%d) ", it->oom_score); |
487 #endif | 488 #endif |
488 if (!it->is_discarded) { | 489 if (!it->is_discarded) { |
489 str += base::StringPrintf(" <a href='%s%s/%" PRId64 "'>Discard</a>", | 490 str += base::StringPrintf(" <a href='%s%s/%" PRId64 "'>Discard</a>", |
490 chrome::kChromeUIDiscardsURL, | 491 chrome::kChromeUIDiscardsURL, |
491 kAboutDiscardsRunCommand, it->tab_contents_id); | 492 kAboutDiscardsRunCommand, it->tab_contents_id); |
492 } | 493 } |
493 str += base::StringPrintf(" (%d discards this session)", | 494 str += base::StringPrintf(" (%d discards this session)", |
494 it->discard_count); | 495 it->discard_count); |
495 titles.push_back(str); | 496 titles.push_back(str); |
496 } | 497 } |
497 return titles; | 498 return titles; |
498 } | 499 } |
499 | 500 |
500 std::string AboutDiscards(const std::string& path) { | 501 std::string AboutDiscards(const std::string& path) { |
501 std::string output; | 502 std::string output; |
502 int64_t web_content_id; | 503 int64_t web_content_id; |
503 memory::TabManager* tab_manager = g_browser_process->GetTabManager(); | 504 resource_coordinator::TabManager* tab_manager = |
| 505 g_browser_process->GetTabManager(); |
504 | 506 |
505 std::vector<std::string> path_split = base::SplitString( | 507 std::vector<std::string> path_split = base::SplitString( |
506 path, "/", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 508 path, "/", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
507 if (path_split.size() == 2 && path_split[0] == kAboutDiscardsRunCommand && | 509 if (path_split.size() == 2 && path_split[0] == kAboutDiscardsRunCommand && |
508 base::StringToInt64(path_split[1], &web_content_id)) { | 510 base::StringToInt64(path_split[1], &web_content_id)) { |
509 tab_manager->DiscardTabById(web_content_id); | 511 tab_manager->DiscardTabById(web_content_id); |
510 return BuildAboutDiscardsRunPage(); | 512 return BuildAboutDiscardsRunPage(); |
511 } else if (path_split.size() == 1 && | 513 } else if (path_split.size() == 1 && |
512 path_split[0] == kAboutDiscardsRunCommand) { | 514 path_split[0] == kAboutDiscardsRunCommand) { |
513 tab_manager->DiscardTab(); | 515 tab_manager->DiscardTab(); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 Profile* profile = Profile::FromWebUI(web_ui); | 790 Profile* profile = Profile::FromWebUI(web_ui); |
789 | 791 |
790 #if !defined(OS_ANDROID) | 792 #if !defined(OS_ANDROID) |
791 // Set up the chrome://theme/ source. | 793 // Set up the chrome://theme/ source. |
792 ThemeSource* theme = new ThemeSource(profile); | 794 ThemeSource* theme = new ThemeSource(profile); |
793 content::URLDataSource::Add(profile, theme); | 795 content::URLDataSource::Add(profile, theme); |
794 #endif | 796 #endif |
795 | 797 |
796 content::URLDataSource::Add(profile, new AboutUIHTMLSource(name, profile)); | 798 content::URLDataSource::Add(profile, new AboutUIHTMLSource(name, profile)); |
797 } | 799 } |
OLD | NEW |