From b61236c6679615af0811d59d130c91397d8c6be7 Mon Sep 17 00:00:00 2001 From: "tim@chromium.org" Date: Thu, 9 Apr 2009 22:43:55 +0000 Subject: The profile Source parameter of a BookmarkModelLoaded event can be null during testing. MetricsService and WebContents weren't handling this case properly. Review URL: http://codereview.chromium.org/66007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13475 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/metrics/metrics_service.cc | 8 +++++--- chrome/browser/tab_contents/web_contents.cc | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index 5fcdb3a..8e94e98 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -534,10 +534,12 @@ void MetricsService::Observe(NotificationType type, *Details(details).ptr()); break; - case NotificationType::BOOKMARK_MODEL_LOADED: - LogBookmarks(Source(source)->GetBookmarkModel()); + case NotificationType::BOOKMARK_MODEL_LOADED: { + Profile* p = Source(source).ptr(); + if (p) + LogBookmarks(p->GetBookmarkModel()); break; - + } default: NOTREACHED(); break; diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc index dbe335b..eaf181e 100644 --- a/chrome/browser/tab_contents/web_contents.cc +++ b/chrome/browser/tab_contents/web_contents.cc @@ -1637,7 +1637,7 @@ void WebContents::Observe(NotificationType type, // Somewhere, a URL has been starred. // Ignore notifications for profiles other than our current one. Profile* source_profile = Source(source).ptr(); - if (!source_profile->IsSameProfile(profile())) + if (!source_profile || !source_profile->IsSameProfile(profile())) return; UpdateStarredStateForCurrentURL(); -- cgit v1.1