diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-09 20:37:35 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-09 20:37:35 +0000 |
commit | 0938d3cb82dfd2424117f73573e757424ebede00 (patch) | |
tree | f1d0503af86c6c8bf6be409c1744437384d7cb86 /chrome/browser | |
parent | 4f2321dbb2e034601fed172d222a90009e4674a0 (diff) | |
download | chromium_src-0938d3cb82dfd2424117f73573e757424ebede00.zip chromium_src-0938d3cb82dfd2424117f73573e757424ebede00.tar.gz chromium_src-0938d3cb82dfd2424117f73573e757424ebede00.tar.bz2 |
This is a rename of the term 'Greasemonkey' to 'user script' in Chromium.
I'm doing this to avoid confusion with the Firefox version of Greasemonkey and
also because 'user script' is really the correct generic term.
At the same time, I also moved user_script_master* into extensions/ because I want these two pieces to get closer and closer such that standalone user scripts are just a very small extension. Also extensions will be relying on most of the user script code.
Review URL: http://codereview.chromium.org/17281
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7827 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser.scons | 2 | ||||
-rw-r--r-- | chrome/browser/browser.vcproj | 16 | ||||
-rw-r--r-- | chrome/browser/extensions/user_script_master.cc (renamed from chrome/browser/greasemonkey_master.cc) | 34 | ||||
-rw-r--r-- | chrome/browser/extensions/user_script_master.h (renamed from chrome/browser/greasemonkey_master.h) | 20 | ||||
-rw-r--r-- | chrome/browser/extensions/user_script_master_unittest.cc (renamed from chrome/browser/greasemonkey_master_unittest.cc) | 34 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.cc | 4 | ||||
-rw-r--r-- | chrome/browser/profile.cc | 18 | ||||
-rw-r--r-- | chrome/browser/profile.h | 12 | ||||
-rw-r--r-- | chrome/browser/render_process_host.cc | 32 | ||||
-rw-r--r-- | chrome/browser/render_process_host.h | 10 |
10 files changed, 90 insertions, 92 deletions
diff --git a/chrome/browser/browser.scons b/chrome/browser/browser.scons index 3cebdb8..e531153 100644 --- a/chrome/browser/browser.scons +++ b/chrome/browser/browser.scons @@ -60,9 +60,9 @@ if not env.Bit('mac'): 'download/save_file.cc', 'extensions/extension.cc', 'extensions/extensions_service.cc', + 'extensions/user_script_master.cc', 'google_url_tracker.cc', 'google_util.cc', - 'greasemonkey_master.cc', 'history/archived_database.cc', 'history/download_database.cc', 'history/expire_history_backend.cc', diff --git a/chrome/browser/browser.vcproj b/chrome/browser/browser.vcproj index 644f7b0..a8cab66 100644 --- a/chrome/browser/browser.vcproj +++ b/chrome/browser/browser.vcproj @@ -2261,6 +2261,14 @@ RelativePath=".\extensions\extensions_service.h" > </File> + <File + RelativePath=".\extensions\user_script_master.cc" + > + </File> + <File + RelativePath=".\extensions\user_script_master.h" + > + </File> </Filter> <Filter Name="Renderer Host" @@ -2421,14 +2429,6 @@ > </File> <File - RelativePath=".\greasemonkey_master.cc" - > - </File> - <File - RelativePath=".\greasemonkey_master.h" - > - </File> - <File RelativePath=".\interstitial_page.cc" > </File> diff --git a/chrome/browser/greasemonkey_master.cc b/chrome/browser/extensions/user_script_master.cc index 715da54..dcd912a 100644 --- a/chrome/browser/greasemonkey_master.cc +++ b/chrome/browser/extensions/user_script_master.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/greasemonkey_master.h" +#include "chrome/browser/extensions/user_script_master.h" #include <vector> @@ -25,10 +25,10 @@ // on the file thread. // It must be created on, and its public API must only be called from, // the master's thread. -class GreasemonkeyMaster::ScriptReloader - : public base::RefCounted<GreasemonkeyMaster::ScriptReloader> { +class UserScriptMaster::ScriptReloader + : public base::RefCounted<UserScriptMaster::ScriptReloader> { public: - ScriptReloader(GreasemonkeyMaster* master) + ScriptReloader(UserScriptMaster* master) : master_(master), master_message_loop_(MessageLoop::current()) {} // Start a scan for scripts. @@ -64,7 +64,7 @@ class GreasemonkeyMaster::ScriptReloader // A pointer back to our master. // May be NULL if DisownMaster() is called. - GreasemonkeyMaster* master_; + UserScriptMaster* master_; // The message loop to call our master back on. // Expected to always outlive us. @@ -73,7 +73,7 @@ class GreasemonkeyMaster::ScriptReloader DISALLOW_COPY_AND_ASSIGN(ScriptReloader); }; -void GreasemonkeyMaster::ScriptReloader::StartScan( +void UserScriptMaster::ScriptReloader::StartScan( MessageLoop* work_loop, const FilePath& script_dir) { // Add a reference to ourselves to keep ourselves alive while we're running. @@ -81,11 +81,11 @@ void GreasemonkeyMaster::ScriptReloader::StartScan( AddRef(); work_loop->PostTask(FROM_HERE, NewRunnableMethod(this, - &GreasemonkeyMaster::ScriptReloader::RunScan, + &UserScriptMaster::ScriptReloader::RunScan, script_dir)); } -void GreasemonkeyMaster::ScriptReloader::NotifyMaster( +void UserScriptMaster::ScriptReloader::NotifyMaster( base::SharedMemory* memory) { if (!master_) { // The master went away, so these new scripts aren't useful anymore. @@ -99,17 +99,17 @@ void GreasemonkeyMaster::ScriptReloader::NotifyMaster( Release(); } -void GreasemonkeyMaster::ScriptReloader::RunScan(const FilePath script_dir) { +void UserScriptMaster::ScriptReloader::RunScan(const FilePath script_dir) { base::SharedMemory* shared_memory = GetNewScripts(script_dir); // Post the new scripts back to the master's message loop. master_message_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, - &GreasemonkeyMaster::ScriptReloader::NotifyMaster, + &UserScriptMaster::ScriptReloader::NotifyMaster, shared_memory)); } -base::SharedMemory* GreasemonkeyMaster::ScriptReloader::GetNewScripts( +base::SharedMemory* UserScriptMaster::ScriptReloader::GetNewScripts( const FilePath& script_dir) { std::vector<std::wstring> scripts; @@ -161,7 +161,7 @@ base::SharedMemory* GreasemonkeyMaster::ScriptReloader::GetNewScripts( } -GreasemonkeyMaster::GreasemonkeyMaster(MessageLoop* worker_loop, +UserScriptMaster::UserScriptMaster(MessageLoop* worker_loop, const FilePath& script_dir) : user_script_dir_(new FilePath(script_dir)), dir_watcher_(new DirectoryWatcher), @@ -174,12 +174,12 @@ GreasemonkeyMaster::GreasemonkeyMaster(MessageLoop* worker_loop, } } -GreasemonkeyMaster::~GreasemonkeyMaster() { +UserScriptMaster::~UserScriptMaster() { if (script_reloader_) script_reloader_->DisownMaster(); } -void GreasemonkeyMaster::NewScriptsAvailable(base::SharedMemory* handle) { +void UserScriptMaster::NewScriptsAvailable(base::SharedMemory* handle) { // Ensure handle is deleted or released. scoped_ptr<base::SharedMemory> handle_deleter(handle); @@ -194,13 +194,13 @@ void GreasemonkeyMaster::NewScriptsAvailable(base::SharedMemory* handle) { // We've got scripts ready to go. shared_memory_.swap(handle_deleter); - NotificationService::current()->Notify(NOTIFY_GREASEMONKEY_SCRIPTS_LOADED, + NotificationService::current()->Notify(NOTIFY_USER_SCRIPTS_LOADED, NotificationService::AllSources(), Details<base::SharedMemory>(handle)); } } -void GreasemonkeyMaster::OnDirectoryChanged(const FilePath& path) { +void UserScriptMaster::OnDirectoryChanged(const FilePath& path) { if (script_reloader_.get()) { // We're already scanning for scripts. We note that we should rescan when // we get the chance. @@ -211,7 +211,7 @@ void GreasemonkeyMaster::OnDirectoryChanged(const FilePath& path) { StartScan(); } -void GreasemonkeyMaster::StartScan() { +void UserScriptMaster::StartScan() { if (!script_reloader_) script_reloader_ = new ScriptReloader(this); diff --git a/chrome/browser/greasemonkey_master.h b/chrome/browser/extensions/user_script_master.h index 34121dd..4798bb2 100644 --- a/chrome/browser/greasemonkey_master.h +++ b/chrome/browser/extensions/user_script_master.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_GREASEMONKEY_MASTER_H_ -#define CHROME_BROWSER_GREASEMONKEY_MASTER_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ +#define CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ #include "base/directory_watcher.h" #include "base/file_path.h" @@ -13,16 +13,16 @@ class MessageLoop; -// Manages a segment of shared memory that contains the Greasemonkey scripts the -// user has installed. Lives on the UI thread. -class GreasemonkeyMaster : public base::RefCounted<GreasemonkeyMaster>, - public DirectoryWatcher::Delegate { +// Manages a segment of shared memory that contains the user scripts the user +// has installed. Lives on the UI thread. +class UserScriptMaster : public base::RefCounted<UserScriptMaster>, + public DirectoryWatcher::Delegate { public: // For testability, the constructor takes the MessageLoop to run the // script-reloading worker on as well as the path the scripts live in. // These are normally the file thread and a directory inside the profile. - GreasemonkeyMaster(MessageLoop* worker, const FilePath& script_dir); - ~GreasemonkeyMaster(); + UserScriptMaster(MessageLoop* worker, const FilePath& script_dir); + ~UserScriptMaster(); // Gets the segment of shared memory for the scripts. base::SharedMemory* GetSharedMemory() const { @@ -70,7 +70,7 @@ class GreasemonkeyMaster : public base::RefCounted<GreasemonkeyMaster>, // finishes. This boolean tracks whether another scan is pending. bool pending_scan_; - DISALLOW_COPY_AND_ASSIGN(GreasemonkeyMaster); + DISALLOW_COPY_AND_ASSIGN(UserScriptMaster); }; -#endif // CHROME_BROWSER_GREASEMONKEY_MASTER_H_ +#endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ diff --git a/chrome/browser/greasemonkey_master_unittest.cc b/chrome/browser/extensions/user_script_master_unittest.cc index 4ce63a0..c630bbd 100644 --- a/chrome/browser/greasemonkey_master_unittest.cc +++ b/chrome/browser/extensions/user_script_master_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/greasemonkey_master.h" +#include "chrome/browser/extensions/user_script_master.h" #include <fstream> @@ -16,17 +16,17 @@ // Test bringing up a master on a specific directory, putting a script in there, etc. -class GreasemonkeyMasterTest : public testing::Test, - public NotificationObserver { +class UserScriptMasterTest : public testing::Test, + public NotificationObserver { public: - GreasemonkeyMasterTest() : shared_memory_(NULL) {} + UserScriptMasterTest() : shared_memory_(NULL) {} virtual void SetUp() { // Name a subdirectory of the temp directory. std::wstring path_str; ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &path_str)); script_dir_ = FilePath(path_str).Append( - FILE_PATH_LITERAL("GreasemonkeyTest")); + FILE_PATH_LITERAL("UserScriptTest")); // Create a fresh, empty copy of this directory. file_util::Delete(script_dir_.value(), true); @@ -34,13 +34,13 @@ class GreasemonkeyMasterTest : public testing::Test, // Register for all user script notifications. NotificationService::current()->AddObserver(this, - NOTIFY_GREASEMONKEY_SCRIPTS_LOADED, + NOTIFY_USER_SCRIPTS_LOADED, NotificationService::AllSources()); } virtual void TearDown() { NotificationService::current()->RemoveObserver(this, - NOTIFY_GREASEMONKEY_SCRIPTS_LOADED, + NOTIFY_USER_SCRIPTS_LOADED, NotificationService::AllSources()); // Clean up test directory. @@ -51,7 +51,7 @@ class GreasemonkeyMasterTest : public testing::Test, virtual void Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { - DCHECK(type == NOTIFY_GREASEMONKEY_SCRIPTS_LOADED); + DCHECK(type == NOTIFY_USER_SCRIPTS_LOADED); shared_memory_ = Details<base::SharedMemory>(details).ptr(); if (MessageLoop::current() == &message_loop_) @@ -69,12 +69,12 @@ class GreasemonkeyMasterTest : public testing::Test, }; // Test that we *don't* get spurious notifications. -TEST_F(GreasemonkeyMasterTest, NoScripts) { +TEST_F(UserScriptMasterTest, NoScripts) { // Set shared_memory_ to something non-NULL, so we can check it became NULL. shared_memory_ = reinterpret_cast<base::SharedMemory*>(1); - scoped_refptr<GreasemonkeyMaster> master( - new GreasemonkeyMaster(MessageLoop::current(), script_dir_)); + scoped_refptr<UserScriptMaster> master( + new UserScriptMaster(MessageLoop::current(), script_dir_)); message_loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask); message_loop_.Run(); @@ -84,9 +84,9 @@ TEST_F(GreasemonkeyMasterTest, NoScripts) { } // Test that we get notified about new scripts after they're added. -TEST_F(GreasemonkeyMasterTest, NewScripts) { - scoped_refptr<GreasemonkeyMaster> master( - new GreasemonkeyMaster(MessageLoop::current(), script_dir_)); +TEST_F(UserScriptMasterTest, NewScripts) { + scoped_refptr<UserScriptMaster> master( + new UserScriptMaster(MessageLoop::current(), script_dir_)); FilePath path = script_dir_.Append(FILE_PATH_LITERAL("script.user.js")); @@ -101,15 +101,15 @@ TEST_F(GreasemonkeyMasterTest, NewScripts) { } // Test that we get notified about scripts if they're already in the test dir. -TEST_F(GreasemonkeyMasterTest, ExistingScripts) { +TEST_F(UserScriptMasterTest, ExistingScripts) { FilePath path = script_dir_.Append(FILE_PATH_LITERAL("script.user.js")); std::ofstream file; file.open(WideToUTF8(path.value()).c_str()); file << "some content"; file.close(); - scoped_refptr<GreasemonkeyMaster> master( - new GreasemonkeyMaster(MessageLoop::current(), script_dir_)); + scoped_refptr<UserScriptMaster> master( + new UserScriptMaster(MessageLoop::current(), script_dir_)); message_loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask); message_loop_.Run(); diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index 2603b296..5ba3f63 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -9,7 +9,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/extensions/extensions_service.h" -#include "chrome/browser/greasemonkey_master.h" +#include "chrome/browser/extensions/user_script_master.h" #include "chrome/browser/profile.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" @@ -112,7 +112,7 @@ ChromeURLRequestContext::ChromeURLRequestContext(Profile* profile) extension_paths_[(*iter)->id()] = (*iter)->path(); } - user_script_dir_path_ = profile->GetGreasemonkeyMaster()->user_script_dir(); + user_script_dir_path_ = profile->GetUserScriptMaster()->user_script_dir(); prefs_->AddPrefObserver(prefs::kAcceptLanguages, this); prefs_->AddPrefObserver(prefs::kCookieBehavior, this); diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc index 6168275..b1762f0 100644 --- a/chrome/browser/profile.cc +++ b/chrome/browser/profile.cc @@ -18,7 +18,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/download/download_manager.h" #include "chrome/browser/extensions/extensions_service.h" -#include "chrome/browser/greasemonkey_master.h" +#include "chrome/browser/extensions/user_script_master.h" #include "chrome/browser/history/history.h" #include "chrome/browser/navigation_controller.h" #include "chrome/browser/net/chrome_url_request_context.h" @@ -134,8 +134,8 @@ class OffTheRecordProfileImpl : public Profile, return profile_->GetExtensionsService(); } - virtual GreasemonkeyMaster* GetGreasemonkeyMaster() { - return profile_->GetGreasemonkeyMaster(); + virtual UserScriptMaster* GetUserScriptMaster() { + return profile_->GetUserScriptMaster(); } virtual HistoryService* GetHistoryService(ServiceAccessType sat) { @@ -448,16 +448,16 @@ ExtensionsService* ProfileImpl::GetExtensionsService() { return extensions_service_.get(); } -GreasemonkeyMaster* ProfileImpl::GetGreasemonkeyMaster() { - if (!greasemonkey_master_.get()) { +UserScriptMaster* ProfileImpl::GetUserScriptMaster() { + if (!user_script_master_.get()) { std::wstring script_dir = GetPath(); file_util::AppendToPath(&script_dir, chrome::kUserScriptsDirname); - greasemonkey_master_ = - new GreasemonkeyMaster(g_browser_process->file_thread()->message_loop(), - FilePath(script_dir)); + user_script_master_ = + new UserScriptMaster(g_browser_process->file_thread()->message_loop(), + FilePath(script_dir)); } - return greasemonkey_master_.get(); + return user_script_master_.get(); } PrefService* ProfileImpl::GetPrefs() { diff --git a/chrome/browser/profile.h b/chrome/browser/profile.h index 16455c1..f5e0866 100644 --- a/chrome/browser/profile.h +++ b/chrome/browser/profile.h @@ -26,7 +26,6 @@ class BookmarkModel; class ChromeURLRequestContext; class DownloadManager; class ExtensionsService; -class GreasemonkeyMaster; class HistoryService; class NavigationController; class PrefService; @@ -36,6 +35,7 @@ class TabRestoreService; class TemplateURLFetcher; class TemplateURLModel; class URLRequestContext; +class UserScriptMaster; class VisitedLinkMaster; class WebDataService; @@ -109,10 +109,10 @@ class Profile { // profile. The ExtensionsService is created at startup. virtual ExtensionsService* GetExtensionsService() = 0; - // Retrieves a pointer to the GreasemonkeyMaster associated with this - // profile. The GreasemonkeyMaster is lazily created the first time + // Retrieves a pointer to the UserScriptMaster associated with this + // profile. The UserScriptMaster is lazily created the first time // that this method is called. - virtual GreasemonkeyMaster* GetGreasemonkeyMaster() = 0; + virtual UserScriptMaster* GetUserScriptMaster() = 0; // Retrieves a pointer to the HistoryService associated with this // profile. The HistoryService is lazily created the first time @@ -260,7 +260,7 @@ class ProfileImpl : public Profile, virtual Profile* GetOffTheRecordProfile(); virtual Profile* GetOriginalProfile(); virtual VisitedLinkMaster* GetVisitedLinkMaster(); - virtual GreasemonkeyMaster* GetGreasemonkeyMaster(); + virtual UserScriptMaster* GetUserScriptMaster(); virtual ExtensionsService* GetExtensionsService(); virtual HistoryService* GetHistoryService(ServiceAccessType sat); virtual WebDataService* GetWebDataService(ServiceAccessType sat); @@ -321,7 +321,7 @@ class ProfileImpl : public Profile, bool off_the_record_; scoped_ptr<VisitedLinkMaster> visited_link_master_; scoped_refptr<ExtensionsService> extensions_service_; - scoped_refptr<GreasemonkeyMaster> greasemonkey_master_; + scoped_refptr<UserScriptMaster> user_script_master_; scoped_ptr<PrefService> prefs_; scoped_ptr<TemplateURLFetcher> template_url_fetcher_; scoped_ptr<TemplateURLModel> template_url_model_; diff --git a/chrome/browser/render_process_host.cc b/chrome/browser/render_process_host.cc index 1efcd58d..f3a2e88 100644 --- a/chrome/browser/render_process_host.cc +++ b/chrome/browser/render_process_host.cc @@ -30,6 +30,7 @@ #include "chrome/browser/browser.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/cache_manager_host.h" +#include "chrome/browser/extensions/user_script_master.h" #include "chrome/browser/history/history.h" #include "chrome/browser/plugin_service.h" #include "chrome/browser/render_widget_helper.h" @@ -39,7 +40,6 @@ #include "chrome/browser/sandbox_policy.h" #include "chrome/browser/spellchecker.h" #include "chrome/browser/visitedlink_master.h" -#include "chrome/browser/greasemonkey_master.h" #include "chrome/browser/web_contents.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" @@ -167,8 +167,7 @@ RenderProcessHost::RenderProcessHost(Profile* profile) profile->GetPrefs()->GetBoolean(prefs::kBlockPopups)); NotificationService::current()->AddObserver(this, - NOTIFY_GREASEMONKEY_SCRIPTS_LOADED, - NotificationService::AllSources()); + NOTIFY_USER_SCRIPTS_LOADED, NotificationService::AllSources()); // Note: When we create the RenderProcessHost, it's technically backgrounded, // because it has no visible listeners. But the process doesn't @@ -191,8 +190,7 @@ RenderProcessHost::~RenderProcessHost() { profile_->GetPrefs()->RemovePrefObserver(prefs::kBlockPopups, this); NotificationService::current()->RemoveObserver(this, - NOTIFY_GREASEMONKEY_SCRIPTS_LOADED, - NotificationService::AllSources()); + NOTIFY_USER_SCRIPTS_LOADED, NotificationService::AllSources()); } void RenderProcessHost::Unregister() { @@ -278,7 +276,7 @@ bool RenderProcessHost::Init() { switches::kDisablePopupBlocking, switches::kUseLowFragHeapCrt, switches::kGearsInRenderer, - switches::kEnableGreasemonkey, + switches::kEnableUserScripts, switches::kEnableVideo, }; @@ -436,7 +434,7 @@ bool RenderProcessHost::Init() { SetBackgrounded(backgrounded_); InitVisitedLinks(); - InitGreasemonkeyScripts(); + InitUserScripts(); if (max_page_id_ != -1) channel_->Send(new ViewMsg_SetNextPageID(max_page_id_ + 1)); @@ -465,9 +463,9 @@ void RenderProcessHost::InitVisitedLinks() { } } -void RenderProcessHost::InitGreasemonkeyScripts() { +void RenderProcessHost::InitUserScripts() { CommandLine command_line; - if (!command_line.HasSwitch(switches::kEnableGreasemonkey)) { + if (!command_line.HasSwitch(switches::kEnableUserScripts)) { return; } @@ -477,28 +475,28 @@ void RenderProcessHost::InitGreasemonkeyScripts() { // - File IO should be asynchronous (see VisitedLinkMaster), but how do we // get scripts to the first renderer without blocking startup? Should we // cache some information across restarts? - GreasemonkeyMaster* greasemonkey_master = profile_->GetGreasemonkeyMaster(); - if (!greasemonkey_master) { + UserScriptMaster* user_script_master = profile_->GetUserScriptMaster(); + if (!user_script_master) { return; } - if (!greasemonkey_master->ScriptsReady()) { + if (!user_script_master->ScriptsReady()) { // No scripts ready. :( return; } // Update the renderer process with the current scripts. - SendGreasemonkeyScriptsUpdate(greasemonkey_master->GetSharedMemory()); + SendUserScriptsUpdate(user_script_master->GetSharedMemory()); } -void RenderProcessHost::SendGreasemonkeyScriptsUpdate( +void RenderProcessHost::SendUserScriptsUpdate( base::SharedMemory *shared_memory) { base::SharedMemoryHandle handle_for_process = NULL; shared_memory->ShareToProcess(GetRendererProcessHandle(), &handle_for_process); DCHECK(handle_for_process); if (handle_for_process) { - channel_->Send(new ViewMsg_Greasemonkey_NewScripts(handle_for_process)); + channel_->Send(new ViewMsg_UserScripts_NewScripts(handle_for_process)); } } @@ -819,12 +817,12 @@ void RenderProcessHost::Observe(NotificationType type, } break; } - case NOTIFY_GREASEMONKEY_SCRIPTS_LOADED: { + case NOTIFY_USER_SCRIPTS_LOADED: { base::SharedMemory* shared_memory = Details<base::SharedMemory>(details).ptr(); DCHECK(shared_memory); if (shared_memory) { - SendGreasemonkeyScriptsUpdate(shared_memory); + SendUserScriptsUpdate(shared_memory); } break; } diff --git a/chrome/browser/render_process_host.h b/chrome/browser/render_process_host.h index 597cc2b3..e4fea50 100644 --- a/chrome/browser/render_process_host.h +++ b/chrome/browser/render_process_host.h @@ -205,12 +205,12 @@ class RenderProcessHost : public IPC::Channel::Listener, // set of visited links. void InitVisitedLinks(); - // Initialize support for Greasemonkey scripts. Send the renderer process its - // initial set of scripts and listen for updates to scripts. - void InitGreasemonkeyScripts(); + // Initialize support for user scripts. Send the renderer process its initial + // set of scripts and listen for updates to scripts. + void InitUserScripts(); - // Sends the renderer process a new set of Greasemonkey scripts. - void SendGreasemonkeyScriptsUpdate(base::SharedMemory* shared_memory); + // Sends the renderer process a new set of user scripts. + void SendUserScriptsUpdate(base::SharedMemory* shared_memory); // Gets a handle to the renderer process, normalizing the case where we were // started with --single-process. |