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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 // Some more paints must've occurred since we set the timeout. | 196 // Some more paints must've occurred since we set the timeout. |
197 // Wait some more. | 197 // Wait some more. |
198 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kTimeoutMs), this, | 198 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kTimeoutMs), this, |
199 &NewTabUI::PaintTimeout); | 199 &NewTabUI::PaintTimeout); |
200 } | 200 } |
201 } | 201 } |
202 | 202 |
203 void NewTabUI::StartTimingPaint(RenderViewHost* render_view_host) { | 203 void NewTabUI::StartTimingPaint(RenderViewHost* render_view_host) { |
204 start_ = base::TimeTicks::Now(); | 204 start_ = base::TimeTicks::Now(); |
205 last_paint_ = start_; | 205 last_paint_ = start_; |
206 registrar_.Add(this, content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT, | 206 |
207 content::Source<content::RenderWidgetHost>(render_view_host)); | 207 content::NotificationSource source = |
208 content::Source<content::RenderWidgetHost>(render_view_host); | |
209 if (!registrar_.IsRegistered(this, | |
210 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT, | |
211 source)) { | |
212 registrar_.Add(this, content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT, | |
213 source); | |
214 } | |
215 | |
208 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kTimeoutMs), this, | 216 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kTimeoutMs), this, |
209 &NewTabUI::PaintTimeout); | 217 &NewTabUI::PaintTimeout); |
stuartmorgan
2012/04/24 09:12:20
Is doing all this timer stuff a second time okay?
Evan Stade
2012/04/24 17:52:40
as far as calling start more than once, yea it's o
| |
210 | |
211 } | 218 } |
212 | 219 |
213 bool NewTabUI::CanShowBookmarkBar() const { | 220 bool NewTabUI::CanShowBookmarkBar() const { |
214 PrefService* prefs = GetProfile()->GetPrefs(); | 221 PrefService* prefs = GetProfile()->GetPrefs(); |
215 bool disabled_by_policy = | 222 bool disabled_by_policy = |
216 prefs->IsManagedPreference(prefs::kShowBookmarkBar) && | 223 prefs->IsManagedPreference(prefs::kShowBookmarkBar) && |
217 !prefs->GetBoolean(prefs::kShowBookmarkBar); | 224 !prefs->GetBoolean(prefs::kShowBookmarkBar); |
218 return browser_defaults::bookmarks_enabled && !disabled_by_policy; | 225 return browser_defaults::bookmarks_enabled && !disabled_by_policy; |
219 } | 226 } |
220 | 227 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 } | 428 } |
422 | 429 |
423 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, | 430 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, |
424 const char* mime_type, | 431 const char* mime_type, |
425 int resource_id) { | 432 int resource_id) { |
426 DCHECK(resource); | 433 DCHECK(resource); |
427 DCHECK(mime_type); | 434 DCHECK(mime_type); |
428 resource_map_[std::string(resource)] = | 435 resource_map_[std::string(resource)] = |
429 std::make_pair(std::string(mime_type), resource_id); | 436 std::make_pair(std::string(mime_type), resource_id); |
430 } | 437 } |
OLD | NEW |