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 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 // Some more paints must've occurred since we set the timeout. | 198 // Some more paints must've occurred since we set the timeout. |
199 // Wait some more. | 199 // Wait some more. |
200 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kTimeoutMs), this, | 200 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kTimeoutMs), this, |
201 &NewTabUI::PaintTimeout); | 201 &NewTabUI::PaintTimeout); |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
205 void NewTabUI::StartTimingPaint(RenderViewHost* render_view_host) { | 205 void NewTabUI::StartTimingPaint(RenderViewHost* render_view_host) { |
206 start_ = base::TimeTicks::Now(); | 206 start_ = base::TimeTicks::Now(); |
207 last_paint_ = start_; | 207 last_paint_ = start_; |
208 registrar_.Add(this, content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT, | 208 |
209 content::Source<content::RenderWidgetHost>(render_view_host)); | 209 content::NotificationSource source = |
| 210 content::Source<content::RenderWidgetHost>(render_view_host); |
| 211 if (!registrar_.IsRegistered(this, |
| 212 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT, |
| 213 source)) { |
| 214 registrar_.Add(this, content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT, |
| 215 source); |
| 216 } |
| 217 |
210 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kTimeoutMs), this, | 218 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kTimeoutMs), this, |
211 &NewTabUI::PaintTimeout); | 219 &NewTabUI::PaintTimeout); |
212 | |
213 } | 220 } |
214 | 221 |
215 bool NewTabUI::CanShowBookmarkBar() const { | 222 bool NewTabUI::CanShowBookmarkBar() const { |
216 PrefService* prefs = GetProfile()->GetPrefs(); | 223 PrefService* prefs = GetProfile()->GetPrefs(); |
217 bool disabled_by_policy = | 224 bool disabled_by_policy = |
218 prefs->IsManagedPreference(prefs::kShowBookmarkBar) && | 225 prefs->IsManagedPreference(prefs::kShowBookmarkBar) && |
219 !prefs->GetBoolean(prefs::kShowBookmarkBar); | 226 !prefs->GetBoolean(prefs::kShowBookmarkBar); |
220 return browser_defaults::bookmarks_enabled && !disabled_by_policy; | 227 return browser_defaults::bookmarks_enabled && !disabled_by_policy; |
221 } | 228 } |
222 | 229 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 } | 430 } |
424 | 431 |
425 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, | 432 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, |
426 const char* mime_type, | 433 const char* mime_type, |
427 int resource_id) { | 434 int resource_id) { |
428 DCHECK(resource); | 435 DCHECK(resource); |
429 DCHECK(mime_type); | 436 DCHECK(mime_type); |
430 resource_map_[std::string(resource)] = | 437 resource_map_[std::string(resource)] = |
431 std::make_pair(std::string(mime_type), resource_id); | 438 std::make_pair(std::string(mime_type), resource_id); |
432 } | 439 } |
OLD | NEW |