OLD | NEW |
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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 7 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
20 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
21 #include "chrome/browser/defaults.h" | |
22 #include "chrome/browser/extensions/app_launcher.h" | 21 #include "chrome/browser/extensions/app_launcher.h" |
23 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
24 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/sessions/session_types.h" | 24 #include "chrome/browser/sessions/session_types.h" |
26 #include "chrome/browser/sync/profile_sync_service.h" | 25 #include "chrome/browser/sync/profile_sync_service.h" |
27 #include "chrome/browser/themes/theme_service.h" | 26 #include "chrome/browser/themes/theme_service.h" |
28 #include "chrome/browser/themes/theme_service_factory.h" | 27 #include "chrome/browser/themes/theme_service_factory.h" |
29 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
30 #include "chrome/browser/ui/webui/metrics_handler.h" | 29 #include "chrome/browser/ui/webui/metrics_handler.h" |
31 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h" | 30 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 registrar_.Add( | 215 registrar_.Add( |
217 this, | 216 this, |
218 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE, | 217 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE, |
219 source); | 218 source); |
220 } | 219 } |
221 | 220 |
222 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kTimeoutMs), this, | 221 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kTimeoutMs), this, |
223 &NewTabUI::PaintTimeout); | 222 &NewTabUI::PaintTimeout); |
224 } | 223 } |
225 | 224 |
226 bool NewTabUI::CanShowBookmarkBar() const { | |
227 if (web_ui()->GetWebContents()->GetURL().SchemeIs(chrome::kViewSourceScheme)) | |
228 return false; | |
229 | |
230 PrefService* prefs = GetProfile()->GetPrefs(); | |
231 bool disabled_by_policy = | |
232 prefs->IsManagedPreference(prefs::kShowBookmarkBar) && | |
233 !prefs->GetBoolean(prefs::kShowBookmarkBar); | |
234 return browser_defaults::bookmarks_enabled && !disabled_by_policy; | |
235 } | |
236 | |
237 void NewTabUI::RenderViewCreated(RenderViewHost* render_view_host) { | 225 void NewTabUI::RenderViewCreated(RenderViewHost* render_view_host) { |
238 StartTimingPaint(render_view_host); | 226 StartTimingPaint(render_view_host); |
239 } | 227 } |
240 | 228 |
241 void NewTabUI::RenderViewReused(RenderViewHost* render_view_host) { | 229 void NewTabUI::RenderViewReused(RenderViewHost* render_view_host) { |
242 StartTimingPaint(render_view_host); | 230 StartTimingPaint(render_view_host); |
243 } | 231 } |
244 | 232 |
245 void NewTabUI::Observe(int type, | 233 void NewTabUI::Observe(int type, |
246 const content::NotificationSource& source, | 234 const content::NotificationSource& source, |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, | 415 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, |
428 const char* mime_type, | 416 const char* mime_type, |
429 int resource_id) { | 417 int resource_id) { |
430 DCHECK(resource); | 418 DCHECK(resource); |
431 DCHECK(mime_type); | 419 DCHECK(mime_type); |
432 resource_map_[std::string(resource)] = | 420 resource_map_[std::string(resource)] = |
433 std::make_pair(std::string(mime_type), resource_id); | 421 std::make_pair(std::string(mime_type), resource_id); |
434 } | 422 } |
435 | 423 |
436 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} | 424 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} |
OLD | NEW |