| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/signin/signin_manager_factory.h" | 10 #include "chrome/browser/signin/signin_manager_factory.h" |
| 11 #include "chrome/browser/ui/webui/browsing_history_handler.h" | 11 #include "chrome/browser/ui/webui/browsing_history_handler.h" |
| 12 #include "chrome/browser/ui/webui/foreign_session_handler.h" | 12 #include "chrome/browser/ui/webui/foreign_session_handler.h" |
| 13 #include "chrome/browser/ui/webui/history_login_handler.h" | 13 #include "chrome/browser/ui/webui/history_login_handler.h" |
| 14 #include "chrome/browser/ui/webui/metrics_handler.h" | 14 #include "chrome/browser/ui/webui/metrics_handler.h" |
| 15 #include "chrome/browser/ui/webui/settings/people_handler.h" | 15 #include "chrome/browser/ui/webui/settings/people_handler.h" |
| 16 #include "chrome/common/chrome_features.h" | 16 #include "chrome/common/chrome_features.h" |
| 17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 19 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 20 #include "chrome/grit/locale_settings.h" |
| 20 #include "components/prefs/pref_service.h" | 21 #include "components/prefs/pref_service.h" |
| 21 #include "components/search/search.h" | 22 #include "components/search/search.h" |
| 22 #include "components/signin/core/browser/signin_manager.h" | 23 #include "components/signin/core/browser/signin_manager.h" |
| 23 #include "content/public/browser/web_ui.h" | 24 #include "content/public/browser/web_ui.h" |
| 24 #include "content/public/browser/web_ui_data_source.h" | 25 #include "content/public/browser/web_ui_data_source.h" |
| 25 #include "grit/browser_resources.h" | 26 #include "grit/browser_resources.h" |
| 26 #include "grit/components_scaled_resources.h" | 27 #include "grit/components_scaled_resources.h" |
| 27 #include "grit/components_strings.h" | 28 #include "grit/components_strings.h" |
| 28 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 29 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
| 31 #include "ui/base/l10n/l10n_util.h" |
| 30 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
| 31 | 33 |
| 32 namespace { | 34 namespace { |
| 33 | 35 |
| 34 content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile) { | 36 content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile) { |
| 35 PrefService* prefs = profile->GetPrefs(); | 37 PrefService* prefs = profile->GetPrefs(); |
| 36 | 38 |
| 37 content::WebUIDataSource* source = | 39 content::WebUIDataSource* source = |
| 38 content::WebUIDataSource::Create(chrome::kChromeUIHistoryHost); | 40 content::WebUIDataSource::Create(chrome::kChromeUIHistoryHost); |
| 39 | 41 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 67 source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE); | 69 source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE); |
| 68 source->AddLocalizedString("searchPrompt", IDS_MD_HISTORY_SEARCH_PROMPT); | 70 source->AddLocalizedString("searchPrompt", IDS_MD_HISTORY_SEARCH_PROMPT); |
| 69 source->AddLocalizedString("searchResult", IDS_HISTORY_SEARCH_RESULT); | 71 source->AddLocalizedString("searchResult", IDS_HISTORY_SEARCH_RESULT); |
| 70 source->AddLocalizedString("searchResults", IDS_HISTORY_SEARCH_RESULTS); | 72 source->AddLocalizedString("searchResults", IDS_HISTORY_SEARCH_RESULTS); |
| 71 source->AddLocalizedString("signInButton", IDS_MD_HISTORY_SIGN_IN_BUTTON); | 73 source->AddLocalizedString("signInButton", IDS_MD_HISTORY_SIGN_IN_BUTTON); |
| 72 source->AddLocalizedString("signInPromo", IDS_MD_HISTORY_SIGN_IN_PROMO); | 74 source->AddLocalizedString("signInPromo", IDS_MD_HISTORY_SIGN_IN_PROMO); |
| 73 source->AddLocalizedString("signInPromoDesc", | 75 source->AddLocalizedString("signInPromoDesc", |
| 74 IDS_MD_HISTORY_SIGN_IN_PROMO_DESC); | 76 IDS_MD_HISTORY_SIGN_IN_PROMO_DESC); |
| 75 source->AddLocalizedString("title", IDS_HISTORY_TITLE); | 77 source->AddLocalizedString("title", IDS_HISTORY_TITLE); |
| 76 | 78 |
| 79 source->AddString( |
| 80 "footer", |
| 81 l10n_util::GetStringFUTF16( |
| 82 IDS_HISTORY_OTHER_FORMS_OF_HISTORY, |
| 83 l10n_util::GetStringUTF16( |
| 84 IDS_SETTINGS_CLEAR_DATA_WEB_HISTORY_URL_IN_HISTORY))); |
| 85 |
| 77 bool allow_deleting_history = | 86 bool allow_deleting_history = |
| 78 prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory); | 87 prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory); |
| 79 source->AddBoolean("allowDeletingHistory", allow_deleting_history); | 88 source->AddBoolean("allowDeletingHistory", allow_deleting_history); |
| 80 | 89 |
| 81 bool group_by_domain = base::CommandLine::ForCurrentProcess()->HasSwitch( | 90 bool group_by_domain = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 82 switches::kHistoryEnableGroupByDomain) || profile->IsSupervised(); | 91 switches::kHistoryEnableGroupByDomain) || profile->IsSupervised(); |
| 83 source->AddBoolean("groupByDomain", group_by_domain); | 92 source->AddBoolean("groupByDomain", group_by_domain); |
| 84 | 93 |
| 85 SigninManagerBase* signin_manager = | 94 SigninManagerBase* signin_manager = |
| 86 SigninManagerFactory::GetForProfile(profile); | 95 SigninManagerFactory::GetForProfile(profile); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 base::FeatureList::ClearInstanceForTesting(); | 183 base::FeatureList::ClearInstanceForTesting(); |
| 175 base::FeatureList::SetInstance(std::move(feature_list)); | 184 base::FeatureList::SetInstance(std::move(feature_list)); |
| 176 } | 185 } |
| 177 | 186 |
| 178 // static | 187 // static |
| 179 base::RefCountedMemory* MdHistoryUI::GetFaviconResourceBytes( | 188 base::RefCountedMemory* MdHistoryUI::GetFaviconResourceBytes( |
| 180 ui::ScaleFactor scale_factor) { | 189 ui::ScaleFactor scale_factor) { |
| 181 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( | 190 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( |
| 182 IDR_HISTORY_FAVICON, scale_factor); | 191 IDR_HISTORY_FAVICON, scale_factor); |
| 183 } | 192 } |
| OLD | NEW |