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

Side by Side Diff: chrome/browser/ui/webui/ntp/ntp_resource_cache.cc

Issue 763673002: Replace direct access to kGoogleServicesUsername with calls to SigninManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nullptr Created 6 years 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 (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/ntp/ntp_resource_cache.h" 5 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/memory/ref_counted_memory.h" 11 #include "base/memory/ref_counted_memory.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/chrome_notification_types.h" 19 #include "chrome/browser/chrome_notification_types.h"
20 #include "chrome/browser/extensions/extension_util.h" 20 #include "chrome/browser/extensions/extension_util.h"
21 #include "chrome/browser/first_run/first_run.h" 21 #include "chrome/browser/first_run/first_run.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/search/search.h" 23 #include "chrome/browser/search/search.h"
24 #include "chrome/browser/signin/signin_manager_factory.h"
24 #include "chrome/browser/sync/profile_sync_service.h" 25 #include "chrome/browser/sync/profile_sync_service.h"
25 #include "chrome/browser/sync/profile_sync_service_factory.h" 26 #include "chrome/browser/sync/profile_sync_service_factory.h"
26 #include "chrome/browser/themes/theme_properties.h" 27 #include "chrome/browser/themes/theme_properties.h"
27 #include "chrome/browser/themes/theme_service.h" 28 #include "chrome/browser/themes/theme_service.h"
28 #include "chrome/browser/themes/theme_service_factory.h" 29 #include "chrome/browser/themes/theme_service_factory.h"
29 #include "chrome/browser/ui/app_list/app_list_util.h" 30 #include "chrome/browser/ui/app_list/app_list_util.h"
30 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" 31 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h"
31 #include "chrome/browser/ui/sync/sync_promo_ui.h" 32 #include "chrome/browser/ui/sync/sync_promo_ui.h"
32 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h" 33 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h"
33 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 34 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
34 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" 35 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h"
35 #include "chrome/browser/web_resource/notification_promo.h" 36 #include "chrome/browser/web_resource/notification_promo.h"
36 #include "chrome/common/chrome_switches.h" 37 #include "chrome/common/chrome_switches.h"
37 #include "chrome/common/pref_names.h" 38 #include "chrome/common/pref_names.h"
38 #include "chrome/common/url_constants.h" 39 #include "chrome/common/url_constants.h"
39 #include "chrome/grit/chromium_strings.h" 40 #include "chrome/grit/chromium_strings.h"
40 #include "chrome/grit/generated_resources.h" 41 #include "chrome/grit/generated_resources.h"
41 #include "chrome/grit/locale_settings.h" 42 #include "chrome/grit/locale_settings.h"
42 #include "components/google/core/browser/google_util.h" 43 #include "components/google/core/browser/google_util.h"
44 #include "components/signin/core/browser/signin_manager.h"
43 #include "content/public/browser/browser_thread.h" 45 #include "content/public/browser/browser_thread.h"
44 #include "content/public/browser/notification_service.h" 46 #include "content/public/browser/notification_service.h"
45 #include "content/public/browser/render_process_host.h" 47 #include "content/public/browser/render_process_host.h"
46 #include "extensions/common/extension.h" 48 #include "extensions/common/extension.h"
47 #include "extensions/common/extension_urls.h" 49 #include "extensions/common/extension_urls.h"
48 #include "grit/browser_resources.h" 50 #include "grit/browser_resources.h"
49 #include "grit/components_strings.h" 51 #include "grit/components_strings.h"
50 #include "grit/theme_resources.h" 52 #include "grit/theme_resources.h"
51 #include "ui/base/l10n/l10n_util.h" 53 #include "ui/base/l10n/l10n_util.h"
52 #include "ui/base/resource/resource_bundle.h" 54 #include "ui/base/resource/resource_bundle.h"
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 bubble_promo.promo_text()); 548 bubble_promo.promo_text());
547 DVLOG(1) << "Bubble promo:" << bubble_promo.promo_text(); 549 DVLOG(1) << "Bubble promo:" << bubble_promo.promo_text();
548 } 550 }
549 } 551 }
550 552
551 // Determine whether to show the menu for accessing tabs on other devices. 553 // Determine whether to show the menu for accessing tabs on other devices.
552 bool show_other_sessions_menu = should_show_other_devices_menu_ && 554 bool show_other_sessions_menu = should_show_other_devices_menu_ &&
553 !CommandLine::ForCurrentProcess()->HasSwitch( 555 !CommandLine::ForCurrentProcess()->HasSwitch(
554 switches::kDisableNTPOtherSessionsMenu); 556 switches::kDisableNTPOtherSessionsMenu);
555 load_time_data.SetBoolean("showOtherSessionsMenu", show_other_sessions_menu); 557 load_time_data.SetBoolean("showOtherSessionsMenu", show_other_sessions_menu);
556 load_time_data.SetBoolean("isUserSignedIn", 558 load_time_data.SetBoolean(
557 !prefs->GetString(prefs::kGoogleServicesUsername).empty()); 559 "isUserSignedIn",
560 SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated());
558 561
559 // Load the new tab page appropriate for this build. 562 // Load the new tab page appropriate for this build.
560 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). 563 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance().
561 GetRawDataResource(IDR_NEW_TAB_4_HTML)); 564 GetRawDataResource(IDR_NEW_TAB_4_HTML));
562 std::string full_html = 565 std::string full_html =
563 webui::GetI18nTemplateHtml(new_tab_html, &load_time_data); 566 webui::GetI18nTemplateHtml(new_tab_html, &load_time_data);
564 new_tab_html_ = base::RefCountedString::TakeString(&full_html); 567 new_tab_html_ = base::RefCountedString::TakeString(&full_html);
565 } 568 }
566 569
567 void NTPResourceCache::CreateNewTabIncognitoCSS() { 570 void NTPResourceCache::CreateNewTabIncognitoCSS() {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 // Get our template. 719 // Get our template.
717 static const base::StringPiece new_tab_theme_css( 720 static const base::StringPiece new_tab_theme_css(
718 ResourceBundle::GetSharedInstance().GetRawDataResource( 721 ResourceBundle::GetSharedInstance().GetRawDataResource(
719 IDR_NEW_TAB_4_THEME_CSS)); 722 IDR_NEW_TAB_4_THEME_CSS));
720 723
721 // Create the string from our template and the replacements. 724 // Create the string from our template and the replacements.
722 std::string css_string; 725 std::string css_string;
723 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); 726 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL);
724 new_tab_css_ = base::RefCountedString::TakeString(&css_string); 727 new_tab_css_ = base::RefCountedString::TakeString(&css_string);
725 } 728 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_login_handler.cc ('k') | chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698