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

Unified Diff: extensions/browser/web_ui_user_script_loader.cc

Issue 2892353002: WebUI: Fix crash while loading scripts for webview.[add/remove]ContentScripts API. (Closed)
Patch Set: Remove test and add TODO Created 3 years, 7 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
« no previous file with comments | « extensions/browser/user_script_loader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/web_ui_user_script_loader.cc
diff --git a/extensions/browser/web_ui_user_script_loader.cc b/extensions/browser/web_ui_user_script_loader.cc
index facbadb0ee2ed8f91890418bdd723eb0550b02aa..1ef9b755c79727b0577a0274de43032d72118daf 100644
--- a/extensions/browser/web_ui_user_script_loader.cc
+++ b/extensions/browser/web_ui_user_script_loader.cc
@@ -86,14 +86,22 @@ void WebUIUserScriptLoader::LoadScripts(
int render_process_id = iter->second.render_process_id;
int render_frame_id = iter->second.render_frame_id;
- content::BrowserContext* browser_context =
- content::RenderProcessHost::FromID(render_process_id)
- ->GetBrowserContext();
-
- CreateWebUIURLFetchers(script->js_scripts(), browser_context,
- render_process_id, render_frame_id);
- CreateWebUIURLFetchers(script->css_scripts(), browser_context,
- render_process_id, render_frame_id);
+ content::RenderProcessHost* render_process_host =
+ content::RenderProcessHost::FromID(render_process_id);
+
+ // LoadScripts may not be synchronous with AddScripts. Hence the
+ // |render_process_host| may no longer be alive. This should fix
+ // crbug.com/720331. TODO(karandeepb): Investigate if there are any side
+ // effects of the render process host no longer being alive and add a test.
+ if (render_process_host) {
+ content::BrowserContext* browser_context =
+ render_process_host->GetBrowserContext();
+
+ CreateWebUIURLFetchers(script->js_scripts(), browser_context,
+ render_process_id, render_frame_id);
+ CreateWebUIURLFetchers(script->css_scripts(), browser_context,
+ render_process_id, render_frame_id);
+ }
script_render_info_map_.erase(script->id());
}
« no previous file with comments | « extensions/browser/user_script_loader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698