Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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/extensions/user_script_master.h" | 5 #include "chrome/browser/extensions/user_script_master.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/pickle.h" | 12 #include "base/pickle.h" |
| 13 #include "base/stl_util-inl.h" | 13 #include "base/stl_util-inl.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/thread.h" | |
| 16 #include "chrome/browser/browser_process.h" | |
| 15 #include "chrome/common/notification_service.h" | 17 #include "chrome/common/notification_service.h" |
| 16 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 17 #include "net/base/net_util.h" | 19 #include "net/base/net_util.h" |
| 18 | 20 |
| 19 | 21 |
| 20 // Helper function to parse greasesmonkey headers | 22 // Helper function to parse greasesmonkey headers |
| 21 static bool GetDeclarationValue(const StringPiece& line, | 23 static bool GetDeclarationValue(const StringPiece& line, |
| 22 const StringPiece& prefix, | 24 const StringPiece& prefix, |
| 23 std::string* value) { | 25 std::string* value) { |
| 24 if (!line.starts_with(prefix)) | 26 if (!line.starts_with(prefix)) |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 if (script_reloader_) | 263 if (script_reloader_) |
| 262 script_reloader_->DisownMaster(); | 264 script_reloader_->DisownMaster(); |
| 263 | 265 |
| 264 // TODO(aa): Enable this when DirectoryWatcher is implemented for linux. | 266 // TODO(aa): Enable this when DirectoryWatcher is implemented for linux. |
| 265 #if defined(OS_WIN) || defined(OS_MACOSX) | 267 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 266 STLDeleteElements(&dir_watchers_); | 268 STLDeleteElements(&dir_watchers_); |
| 267 #endif | 269 #endif |
| 268 } | 270 } |
| 269 | 271 |
| 270 void UserScriptMaster::AddWatchedPath(const FilePath& path) { | 272 void UserScriptMaster::AddWatchedPath(const FilePath& path) { |
| 271 // TODO(aa): Enable this when DirectoryWatcher is implemented for linux. | 273 // TODO(aa): Enable this when DirectoryWatcher is implemented for linux. |
|
Evan Martin
2009/05/14 17:48:28
I guess this TODO can be fixed now! Maybe in a di
| |
| 272 #if defined(OS_WIN) || defined(OS_MACOSX) | 274 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 273 DirectoryWatcher* watcher = new DirectoryWatcher(); | 275 DirectoryWatcher* watcher = new DirectoryWatcher(); |
| 274 watcher->Watch(path, this, true); | 276 base::Thread* file_thread = g_browser_process->file_thread(); |
| 277 watcher->Watch(path, this, file_thread ? file_thread->message_loop() : NULL, | |
| 278 true); | |
| 275 dir_watchers_.push_back(watcher); | 279 dir_watchers_.push_back(watcher); |
| 276 #endif | 280 #endif |
| 277 } | 281 } |
| 278 | 282 |
| 279 void UserScriptMaster::NewScriptsAvailable(base::SharedMemory* handle) { | 283 void UserScriptMaster::NewScriptsAvailable(base::SharedMemory* handle) { |
| 280 // Ensure handle is deleted or released. | 284 // Ensure handle is deleted or released. |
| 281 scoped_ptr<base::SharedMemory> handle_deleter(handle); | 285 scoped_ptr<base::SharedMemory> handle_deleter(handle); |
| 282 | 286 |
| 283 if (pending_scan_) { | 287 if (pending_scan_) { |
| 284 // While we were scanning, there were further changes. Don't bother | 288 // While we were scanning, there were further changes. Don't bother |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 308 | 312 |
| 309 StartScan(); | 313 StartScan(); |
| 310 } | 314 } |
| 311 | 315 |
| 312 void UserScriptMaster::StartScan() { | 316 void UserScriptMaster::StartScan() { |
| 313 if (!script_reloader_) | 317 if (!script_reloader_) |
| 314 script_reloader_ = new ScriptReloader(this); | 318 script_reloader_ = new ScriptReloader(this); |
| 315 | 319 |
| 316 script_reloader_->StartScan(worker_loop_, user_script_dir_, lone_scripts_); | 320 script_reloader_->StartScan(worker_loop_, user_script_dir_, lone_scripts_); |
| 317 } | 321 } |
| OLD | NEW |