| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/md_history_ui.h" | 5 #include "chrome/browser/ui/webui/md_history_ui.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/webui/browsing_history_handler.h" | 9 #include "chrome/browser/ui/webui/browsing_history_handler.h" |
| 10 #include "chrome/browser/ui/webui/metrics_handler.h" | 10 #include "chrome/browser/ui/webui/metrics_handler.h" |
| 11 #include "chrome/common/pref_names.h" |
| 11 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
| 13 #include "components/prefs/pref_service.h" |
| 12 #include "components/search/search.h" | 14 #include "components/search/search.h" |
| 13 #include "content/public/browser/web_ui.h" | 15 #include "content/public/browser/web_ui.h" |
| 14 #include "content/public/browser/web_ui_data_source.h" | 16 #include "content/public/browser/web_ui_data_source.h" |
| 15 #include "grit/browser_resources.h" | 17 #include "grit/browser_resources.h" |
| 16 #include "grit/components_scaled_resources.h" | 18 #include "grit/components_scaled_resources.h" |
| 17 #include "grit/components_strings.h" | 19 #include "grit/components_strings.h" |
| 18 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
| 19 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
| 21 | 23 |
| 22 #if !defined(OS_ANDROID) | 24 #if !defined(OS_ANDROID) |
| 23 #include "chrome/browser/ui/webui/foreign_session_handler.h" | 25 #include "chrome/browser/ui/webui/foreign_session_handler.h" |
| 24 #include "chrome/browser/ui/webui/history_login_handler.h" | 26 #include "chrome/browser/ui/webui/history_login_handler.h" |
| 25 #endif | 27 #endif |
| 26 | 28 |
| 27 namespace { | 29 namespace { |
| 28 | 30 |
| 29 content::WebUIDataSource* CreateMdHistoryUIHTMLSource() { | 31 content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile) { |
| 32 PrefService* prefs = profile->GetPrefs(); |
| 33 |
| 30 content::WebUIDataSource* source = | 34 content::WebUIDataSource* source = |
| 31 content::WebUIDataSource::Create(chrome::kChromeUIHistoryHost); | 35 content::WebUIDataSource::Create(chrome::kChromeUIHistoryHost); |
| 32 | 36 |
| 33 // Localized strings (alphabetical order). | 37 // Localized strings (alphabetical order). |
| 34 source->AddLocalizedString("clearSearch", IDS_MD_HISTORY_CLEAR_SEARCH); | 38 source->AddLocalizedString("clearSearch", IDS_MD_HISTORY_CLEAR_SEARCH); |
| 35 source->AddLocalizedString("cancel", IDS_CANCEL); | 39 source->AddLocalizedString("cancel", IDS_CANCEL); |
| 36 source->AddLocalizedString("delete", IDS_MD_HISTORY_DELETE); | 40 source->AddLocalizedString("delete", IDS_MD_HISTORY_DELETE); |
| 37 source->AddLocalizedString("itemsSelected", IDS_MD_HISTORY_ITEMS_SELECTED); | 41 source->AddLocalizedString("itemsSelected", IDS_MD_HISTORY_ITEMS_SELECTED); |
| 38 source->AddLocalizedString("moreFromSite", IDS_HISTORY_MORE_FROM_SITE); | 42 source->AddLocalizedString("moreFromSite", IDS_HISTORY_MORE_FROM_SITE); |
| 39 source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE); | 43 source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE); |
| 40 source->AddLocalizedString("search", IDS_MD_HISTORY_SEARCH); | 44 source->AddLocalizedString("search", IDS_MD_HISTORY_SEARCH); |
| 41 source->AddLocalizedString("title", IDS_HISTORY_TITLE); | 45 source->AddLocalizedString("title", IDS_HISTORY_TITLE); |
| 42 | 46 |
| 47 bool allow_deleting_history = |
| 48 prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory); |
| 49 source->AddBoolean("allowDeletingHistory", allow_deleting_history); |
| 50 |
| 43 source->AddResourcePath("history_card.html", | 51 source->AddResourcePath("history_card.html", |
| 44 IDR_MD_HISTORY_HISTORY_CARD_HTML); | 52 IDR_MD_HISTORY_HISTORY_CARD_HTML); |
| 45 source->AddResourcePath("history_card.js", IDR_MD_HISTORY_HISTORY_CARD_JS); | 53 source->AddResourcePath("history_card.js", IDR_MD_HISTORY_HISTORY_CARD_JS); |
| 46 source->AddResourcePath("history_card_manager.html", | 54 source->AddResourcePath("history_card_manager.html", |
| 47 IDR_MD_HISTORY_HISTORY_CARD_MANAGER_HTML); | 55 IDR_MD_HISTORY_HISTORY_CARD_MANAGER_HTML); |
| 48 source->AddResourcePath("history_card_manager.js", | 56 source->AddResourcePath("history_card_manager.js", |
| 49 IDR_MD_HISTORY_HISTORY_CARD_MANAGER_JS); | 57 IDR_MD_HISTORY_HISTORY_CARD_MANAGER_JS); |
| 50 source->AddResourcePath("history_item.html", | 58 source->AddResourcePath("history_item.html", |
| 51 IDR_MD_HISTORY_HISTORY_ITEM_HTML); | 59 IDR_MD_HISTORY_HISTORY_ITEM_HTML); |
| 52 source->AddResourcePath("history_item.js", IDR_MD_HISTORY_HISTORY_ITEM_JS); | 60 source->AddResourcePath("history_item.js", IDR_MD_HISTORY_HISTORY_ITEM_JS); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 70 | 78 |
| 71 // On mobile we deal with foreign sessions differently. | 79 // On mobile we deal with foreign sessions differently. |
| 72 #if !defined(OS_ANDROID) | 80 #if !defined(OS_ANDROID) |
| 73 if (search::IsInstantExtendedAPIEnabled()) { | 81 if (search::IsInstantExtendedAPIEnabled()) { |
| 74 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); | 82 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); |
| 75 web_ui->AddMessageHandler(new HistoryLoginHandler()); | 83 web_ui->AddMessageHandler(new HistoryLoginHandler()); |
| 76 } | 84 } |
| 77 #endif | 85 #endif |
| 78 | 86 |
| 79 Profile* profile = Profile::FromWebUI(web_ui); | 87 Profile* profile = Profile::FromWebUI(web_ui); |
| 80 content::WebUIDataSource::Add(profile, CreateMdHistoryUIHTMLSource()); | 88 content::WebUIDataSource::Add(profile, CreateMdHistoryUIHTMLSource(profile)); |
| 81 } | 89 } |
| 82 | 90 |
| 83 MdHistoryUI::~MdHistoryUI() {} | 91 MdHistoryUI::~MdHistoryUI() {} |
| 84 | 92 |
| 85 base::RefCountedMemory* MdHistoryUI::GetFaviconResourceBytes( | 93 base::RefCountedMemory* MdHistoryUI::GetFaviconResourceBytes( |
| 86 ui::ScaleFactor scale_factor) { | 94 ui::ScaleFactor scale_factor) { |
| 87 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( | 95 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( |
| 88 IDR_HISTORY_FAVICON, scale_factor); | 96 IDR_HISTORY_FAVICON, scale_factor); |
| 89 } | 97 } |
| OLD | NEW |