| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "chrome/common/notification_service.h" | 9 #include "chrome/common/notification_service.h" |
| 10 #include "chrome/common/notification_type.h" | 10 #include "chrome/common/notification_type.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) { | 141 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) { |
| 142 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 142 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 143 NewRunnableMethod(this, &UserStyleSheetWatcher::Init)); | 143 NewRunnableMethod(this, &UserStyleSheetWatcher::Init)); |
| 144 return; | 144 return; |
| 145 } | 145 } |
| 146 | 146 |
| 147 if (!file_watcher_.get()) { | 147 if (!file_watcher_.get()) { |
| 148 file_watcher_.reset(new FilePathWatcher); | 148 file_watcher_.reset(new FilePathWatcher); |
| 149 FilePath style_sheet_file = profile_path_.AppendASCII(kStyleSheetDir) | 149 FilePath style_sheet_file = profile_path_.AppendASCII(kStyleSheetDir) |
| 150 .AppendASCII(kUserStyleSheetFile); | 150 .AppendASCII(kUserStyleSheetFile); |
| 151 if (!file_watcher_->Watch(style_sheet_file, loader_.get())) | 151 if (!file_watcher_->Watch(style_sheet_file, loader_.get())) { |
| 152 LOG(ERROR) << "Failed to setup watch for " << style_sheet_file.value(); | 152 LOG(ERROR) << "Failed to setup watch for " << style_sheet_file.value(); |
| 153 } |
| 153 loader_->LoadStyleSheet(style_sheet_file); | 154 loader_->LoadStyleSheet(style_sheet_file); |
| 154 } | 155 } |
| 155 } | 156 } |
| 156 | 157 |
| 157 GURL UserStyleSheetWatcher::user_style_sheet() const { | 158 GURL UserStyleSheetWatcher::user_style_sheet() const { |
| 158 return loader_->user_style_sheet(); | 159 return loader_->user_style_sheet(); |
| 159 } | 160 } |
| 160 | 161 |
| 161 void UserStyleSheetWatcher::Observe(NotificationType type, | 162 void UserStyleSheetWatcher::Observe(NotificationType type, |
| 162 const NotificationSource& source, const NotificationDetails& details) { | 163 const NotificationSource& source, const NotificationDetails& details) { |
| 163 DCHECK(type == NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB); | 164 DCHECK(type == NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB); |
| 164 loader_->NotifyLoaded(); | 165 loader_->NotifyLoaded(); |
| 165 registrar_.RemoveAll(); | 166 registrar_.RemoveAll(); |
| 166 } | 167 } |
| OLD | NEW |