Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2886)

Unified Diff: chrome/browser/render_process_host.cc

Issue 8908: Make it so that you can refresh and see changes in Greasemonkey... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/render_process_host.cc
===================================================================
--- chrome/browser/render_process_host.cc (revision 4208)
+++ chrome/browser/render_process_host.cc (working copy)
@@ -166,6 +166,10 @@
widget_helper_->set_block_popups(
profile->GetPrefs()->GetBoolean(prefs::kBlockPopups));
+ NotificationService::current()->AddObserver(this,
+ NOTIFY_NEW_USER_SCRIPTS,
+ NotificationService::AllSources());
+
// Note: When we create the RenderProcessHost, it's technically backgrounded,
// because it has no visible listeners. But the process doesn't
// actually exist yet, so we'll Background it later, after creation.
@@ -185,6 +189,10 @@
}
profile_->GetPrefs()->RemovePrefObserver(prefs::kBlockPopups, this);
+
+ NotificationService::current()->RemoveObserver(this,
+ NOTIFY_NEW_USER_SCRIPTS,
+ NotificationService::AllSources());
}
void RenderProcessHost::Unregister() {
@@ -426,38 +434,41 @@
// Now that the process is created, set it's backgrounding accordingly.
SetBackgrounded(backgrounded_);
- // Send the process its initial VisitedLink and Greasemonkey data.
- HANDLE target_process = process_.handle();
- if (!target_process) {
- // Target process can be null if it's started with the --single-process
- // flag.
- target_process = GetCurrentProcess();
- }
+ InitVisitedLinks();
+ InitGreasemonkeyScripts();
- InitVisitedLinks(target_process);
- InitGreasemonkeyScripts(target_process);
-
if (max_page_id_ != -1)
channel_->Send(new ViewMsg_SetNextPageID(max_page_id_ + 1));
return true;
}
-void RenderProcessHost::InitVisitedLinks(HANDLE target_process) {
+HANDLE RenderProcessHost::GetRendererProcessHandle() {
+ HANDLE result = process_.handle();
+ if (!result) {
+ // Renderer process can be null if it's started with the --single-process
+ // flag.
+ result = GetCurrentProcess();
+ }
+ return result;
+}
+
+void RenderProcessHost::InitVisitedLinks() {
VisitedLinkMaster* visitedlink_master = profile_->GetVisitedLinkMaster();
if (!visitedlink_master) {
return;
}
SharedMemoryHandle handle_for_process = NULL;
- visitedlink_master->ShareToProcess(target_process, &handle_for_process);
+ visitedlink_master->ShareToProcess(GetRendererProcessHandle(),
+ &handle_for_process);
DCHECK(handle_for_process);
if (handle_for_process) {
channel_->Send(new ViewMsg_VisitedLink_NewTable(handle_for_process));
}
}
-void RenderProcessHost::InitGreasemonkeyScripts(HANDLE target_process) {
+void RenderProcessHost::InitGreasemonkeyScripts() {
CommandLine command_line;
if (!command_line.HasSwitch(switches::kEnableGreasemonkey)) {
return;
@@ -479,8 +490,15 @@
return;
}
+ // Update the renderer process with the current scripts.
+ SendGreasemonkeyScriptsUpdate(greasemonkey_master->GetSharedMemory());
+}
+
+void RenderProcessHost::SendGreasemonkeyScriptsUpdate(
+ SharedMemory *shared_memory) {
SharedMemoryHandle handle_for_process = NULL;
- greasemonkey_master->ShareToProcess(target_process, &handle_for_process);
+ shared_memory->ShareToProcess(GetRendererProcessHandle(),
+ &handle_for_process);
DCHECK(handle_for_process);
if (handle_for_process) {
channel_->Send(new ViewMsg_Greasemonkey_NewScripts(handle_for_process));
@@ -802,6 +820,14 @@
}
break;
}
+ case NOTIFY_NEW_USER_SCRIPTS: {
+ SharedMemory* shared_memory = Details<SharedMemory>(details).ptr();
+ DCHECK(shared_memory);
+ if (shared_memory) {
+ SendGreasemonkeyScriptsUpdate(shared_memory);
+ }
+ break;
+ }
default: {
NOTREACHED();
break;
« chrome/browser/render_process_host.h ('K') | « chrome/browser/render_process_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698