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