Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Side by Side Diff: chrome/browser/ui/webui/md_history_ui.cc

Issue 2751653004: MD History: re-use history host constant from content/ instead of duplicating to chrome/ (Closed)
Patch Set: merge Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/grit/locale_settings.h" 23 #include "chrome/grit/locale_settings.h"
24 #include "chrome/grit/theme_resources.h" 24 #include "chrome/grit/theme_resources.h"
25 #include "components/grit/components_scaled_resources.h" 25 #include "components/grit/components_scaled_resources.h"
26 #include "components/pref_registry/pref_registry_syncable.h" 26 #include "components/pref_registry/pref_registry_syncable.h"
27 #include "components/prefs/pref_service.h" 27 #include "components/prefs/pref_service.h"
28 #include "components/search/search.h" 28 #include "components/search/search.h"
29 #include "components/signin/core/browser/signin_manager.h" 29 #include "components/signin/core/browser/signin_manager.h"
30 #include "components/strings/grit/components_strings.h" 30 #include "components/strings/grit/components_strings.h"
31 #include "content/public/browser/web_ui.h" 31 #include "content/public/browser/web_ui.h"
32 #include "content/public/browser/web_ui_data_source.h" 32 #include "content/public/browser/web_ui_data_source.h"
33 #include "content/public/common/url_constants.h"
33 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
34 #include "ui/base/resource/resource_bundle.h" 35 #include "ui/base/resource/resource_bundle.h"
35 36
36 namespace { 37 namespace {
37 38
38 constexpr char kIsUserSignedInKey[] = "isUserSignedIn"; 39 constexpr char kIsUserSignedInKey[] = "isUserSignedIn";
39 constexpr char kShowMenuPromoKey[] = "showMenuPromo"; 40 constexpr char kShowMenuPromoKey[] = "showMenuPromo";
40 41
41 bool IsUserSignedIn(Profile* profile) { 42 bool IsUserSignedIn(Profile* profile) {
42 SigninManagerBase* signin_manager = 43 SigninManagerBase* signin_manager =
43 SigninManagerFactory::GetForProfile(profile); 44 SigninManagerFactory::GetForProfile(profile);
44 return signin_manager && signin_manager->IsAuthenticated(); 45 return signin_manager && signin_manager->IsAuthenticated();
45 } 46 }
46 47
47 bool MenuPromoShown(Profile* profile) { 48 bool MenuPromoShown(Profile* profile) {
48 return profile->GetPrefs()->GetBoolean(prefs::kMdHistoryMenuPromoShown); 49 return profile->GetPrefs()->GetBoolean(prefs::kMdHistoryMenuPromoShown);
49 } 50 }
50 51
51 content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile, 52 content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile,
52 bool use_test_title) { 53 bool use_test_title) {
53 content::WebUIDataSource* source = 54 content::WebUIDataSource* source =
54 content::WebUIDataSource::Create(chrome::kChromeUIHistoryHost); 55 content::WebUIDataSource::Create(content::kChromeUIHistoryHost);
55 56
56 // Localized strings (alphabetical order). 57 // Localized strings (alphabetical order).
57 source->AddLocalizedString("bookmarked", IDS_HISTORY_ENTRY_BOOKMARKED); 58 source->AddLocalizedString("bookmarked", IDS_HISTORY_ENTRY_BOOKMARKED);
58 source->AddLocalizedString("cancel", IDS_CANCEL); 59 source->AddLocalizedString("cancel", IDS_CANCEL);
59 source->AddLocalizedString("clearBrowsingData", 60 source->AddLocalizedString("clearBrowsingData",
60 IDS_CLEAR_BROWSING_DATA_TITLE); 61 IDS_CLEAR_BROWSING_DATA_TITLE);
61 source->AddLocalizedString("clearSearch", IDS_MD_HISTORY_CLEAR_SEARCH); 62 source->AddLocalizedString("clearSearch", IDS_MD_HISTORY_CLEAR_SEARCH);
62 source->AddLocalizedString("closeMenuPromo", IDS_MD_HISTORY_CLOSE_MENU_PROMO); 63 source->AddLocalizedString("closeMenuPromo", IDS_MD_HISTORY_CLOSE_MENU_PROMO);
63 source->AddLocalizedString("collapseSessionButton", 64 source->AddLocalizedString("collapseSessionButton",
64 IDS_HISTORY_OTHER_SESSIONS_COLLAPSE_SESSION); 65 IDS_HISTORY_OTHER_SESSIONS_COLLAPSE_SESSION);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 243
243 void MdHistoryUI::UpdateDataSource() { 244 void MdHistoryUI::UpdateDataSource() {
244 CHECK(web_ui()); 245 CHECK(web_ui());
245 246
246 Profile* profile = Profile::FromWebUI(web_ui()); 247 Profile* profile = Profile::FromWebUI(web_ui());
247 248
248 std::unique_ptr<base::DictionaryValue> update(new base::DictionaryValue); 249 std::unique_ptr<base::DictionaryValue> update(new base::DictionaryValue);
249 update->SetBoolean(kIsUserSignedInKey, IsUserSignedIn(profile)); 250 update->SetBoolean(kIsUserSignedInKey, IsUserSignedIn(profile));
250 update->SetBoolean(kShowMenuPromoKey, !MenuPromoShown(profile)); 251 update->SetBoolean(kShowMenuPromoKey, !MenuPromoShown(profile));
251 252
252 content::WebUIDataSource::Update(profile, chrome::kChromeUIHistoryHost, 253 content::WebUIDataSource::Update(profile, content::kChromeUIHistoryHost,
253 std::move(update)); 254 std::move(update));
254 } 255 }
255 256
256 void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) { 257 void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) {
257 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( 258 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean(
258 prefs::kMdHistoryMenuPromoShown, true); 259 prefs::kMdHistoryMenuPromoShown, true);
259 UpdateDataSource(); 260 UpdateDataSource();
260 } 261 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc ('k') | chrome/browser/ui/webui/uber/uber_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698