| 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 "chrome/browser/user_style_sheet_watcher.h" | 5 #include "chrome/browser/user_style_sheet_watcher.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 void UserStyleSheetLoader::SetStyleSheet(const GURL& url) { | 132 void UserStyleSheetLoader::SetStyleSheet(const GURL& url) { |
| 133 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 133 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 134 | 134 |
| 135 has_loaded_ = true; | 135 has_loaded_ = true; |
| 136 user_style_sheet_ = url; | 136 user_style_sheet_ = url; |
| 137 NotifyLoaded(); | 137 NotifyLoaded(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 UserStyleSheetWatcher::UserStyleSheetWatcher(Profile* profile, | 140 UserStyleSheetWatcher::UserStyleSheetWatcher(Profile* profile, |
| 141 const base::FilePath& profile_path) | 141 const base::FilePath& profile_path) |
| 142 : RefcountedProfileKeyedService(content::BrowserThread::UI), | 142 : RefcountedBrowserContextKeyedService(content::BrowserThread::UI), |
| 143 profile_(profile), | 143 profile_(profile), |
| 144 profile_path_(profile_path), | 144 profile_path_(profile_path), |
| 145 loader_(new UserStyleSheetLoader) { | 145 loader_(new UserStyleSheetLoader) { |
| 146 // Listen for when the first render view host is created. If we load | 146 // Listen for when the first render view host is created. If we load |
| 147 // too fast, the first tab won't hear the notification and won't get | 147 // too fast, the first tab won't hear the notification and won't get |
| 148 // the user style sheet. | 148 // the user style sheet. |
| 149 registrar_.Add(this, | 149 registrar_.Add(this, |
| 150 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, | 150 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, |
| 151 content::NotificationService::AllBrowserContextsAndSources()); | 151 content::NotificationService::AllBrowserContextsAndSources()); |
| 152 } | 152 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 if (profile_->IsSameProfile(Profile::FromBrowserContext( | 189 if (profile_->IsSameProfile(Profile::FromBrowserContext( |
| 190 content::Source<WebContents>(source)->GetBrowserContext()))) { | 190 content::Source<WebContents>(source)->GetBrowserContext()))) { |
| 191 loader_->NotifyLoaded(); | 191 loader_->NotifyLoaded(); |
| 192 registrar_.RemoveAll(); | 192 registrar_.RemoveAll(); |
| 193 } | 193 } |
| 194 } | 194 } |
| 195 | 195 |
| 196 void UserStyleSheetWatcher::ShutdownOnUIThread() { | 196 void UserStyleSheetWatcher::ShutdownOnUIThread() { |
| 197 registrar_.RemoveAll(); | 197 registrar_.RemoveAll(); |
| 198 } | 198 } |
| OLD | NEW |