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

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

Issue 2905433002: Refresh the Incognito NTP layout on default font size change (Closed)
Patch Set: s/tooWide/too-wide/ Created 3 years, 7 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
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_ui.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/new_tab_ui.h" 5 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/memory/ref_counted_memory.h" 12 #include "base/memory/ref_counted_memory.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" 16 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
17 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" 17 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h"
18 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" 18 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h"
19 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h" 19 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h"
20 #include "chrome/browser/ui/webui/theme_handler.h" 20 #include "chrome/browser/ui/webui/theme_handler.h"
21 #include "chrome/common/pref_names.h"
21 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
22 #include "components/bookmarks/common/bookmark_pref_names.h" 23 #include "components/bookmarks/common/bookmark_pref_names.h"
23 #include "components/prefs/pref_service.h" 24 #include "components/prefs/pref_service.h"
24 #include "components/strings/grit/components_strings.h" 25 #include "components/strings/grit/components_strings.h"
25 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
26 #include "content/public/browser/render_process_host.h" 27 #include "content/public/browser/render_process_host.h"
27 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
28 #include "content/public/browser/web_ui.h" 29 #include "content/public/browser/web_ui.h"
29 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
30 #include "url/gurl.h" 31 #include "url/gurl.h"
(...skipping 26 matching lines...) Expand all
57 web_ui->AddMessageHandler(base::MakeUnique<ThemeHandler>()); 58 web_ui->AddMessageHandler(base::MakeUnique<ThemeHandler>());
58 59
59 // content::URLDataSource assumes the ownership of the html source. 60 // content::URLDataSource assumes the ownership of the html source.
60 content::URLDataSource::Add( 61 content::URLDataSource::Add(
61 profile, new NewTabHTMLSource(profile->GetOriginalProfile())); 62 profile, new NewTabHTMLSource(profile->GetOriginalProfile()));
62 63
63 pref_change_registrar_.Init(profile->GetPrefs()); 64 pref_change_registrar_.Init(profile->GetPrefs());
64 pref_change_registrar_.Add(bookmarks::prefs::kShowBookmarkBar, 65 pref_change_registrar_.Add(bookmarks::prefs::kShowBookmarkBar,
65 base::Bind(&NewTabUI::OnShowBookmarkBarChanged, 66 base::Bind(&NewTabUI::OnShowBookmarkBarChanged,
66 base::Unretained(this))); 67 base::Unretained(this)));
68 pref_change_registrar_.Add(
69 prefs::kWebKitDefaultFontSize,
70 base::Bind(&NewTabUI::OnDefaultFontSizeChanged, base::Unretained(this)));
67 } 71 }
68 72
69 NewTabUI::~NewTabUI() {} 73 NewTabUI::~NewTabUI() {}
70 74
71 void NewTabUI::OnShowBookmarkBarChanged() { 75 void NewTabUI::OnShowBookmarkBarChanged() {
72 base::Value attached( 76 base::Value attached(
73 GetProfile()->GetPrefs()->GetBoolean(bookmarks::prefs::kShowBookmarkBar) 77 GetProfile()->GetPrefs()->GetBoolean(bookmarks::prefs::kShowBookmarkBar)
74 ? "true" 78 ? "true"
75 : "false"); 79 : "false");
76 web_ui()->CallJavascriptFunctionUnsafe("ntp.setBookmarkBarAttached", 80 web_ui()->CallJavascriptFunctionUnsafe("ntp.setBookmarkBarAttached",
77 attached); 81 attached);
78 } 82 }
79 83
84 void NewTabUI::OnDefaultFontSizeChanged() {
85 web_ui()->CallJavascriptFunctionUnsafe("ntp.defaultFontSizeChanged");
86 }
87
80 // static 88 // static
81 void NewTabUI::RegisterProfilePrefs( 89 void NewTabUI::RegisterProfilePrefs(
82 user_prefs::PrefRegistrySyncable* registry) { 90 user_prefs::PrefRegistrySyncable* registry) {
83 CoreAppLauncherHandler::RegisterProfilePrefs(registry); 91 CoreAppLauncherHandler::RegisterProfilePrefs(registry);
84 AppLauncherHandler::RegisterProfilePrefs(registry); 92 AppLauncherHandler::RegisterProfilePrefs(registry);
85 } 93 }
86 94
87 // static 95 // static
88 bool NewTabUI::IsNewTab(const GURL& url) { 96 bool NewTabUI::IsNewTab(const GURL& url) {
89 return url.GetOrigin() == GURL(chrome::kChromeUINewTabURL).GetOrigin(); 97 return url.GetOrigin() == GURL(chrome::kChromeUINewTabURL).GetOrigin();
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 return "img-src chrome-search://thumb chrome-search://thumb2 " 205 return "img-src chrome-search://thumb chrome-search://thumb2 "
198 "chrome-search://theme chrome://theme data:;"; 206 "chrome-search://theme chrome://theme data:;";
199 } 207 }
200 208
201 std::string NewTabUI::NewTabHTMLSource::GetContentSecurityPolicyChildSrc() 209 std::string NewTabUI::NewTabHTMLSource::GetContentSecurityPolicyChildSrc()
202 const { 210 const {
203 return "child-src chrome-search://most-visited;"; 211 return "child-src chrome-search://most-visited;";
204 } 212 }
205 213
206 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} 214 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {}
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698