OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer_host/chrome_render_view_host_observer.h" | 5 #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/dom_operation_notification_details.h" | 8 #include "chrome/browser/dom_operation_notification_details.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/net/predictor.h" | 10 #include "chrome/browser/net/predictor.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 SiteInstance* site_instance = render_view_host()->site_instance(); | 132 SiteInstance* site_instance = render_view_host()->site_instance(); |
133 const GURL& site = site_instance->site(); | 133 const GURL& site = site_instance->site(); |
134 | 134 |
135 if (!site.SchemeIs(chrome::kExtensionScheme)) | 135 if (!site.SchemeIs(chrome::kExtensionScheme)) |
136 return NULL; | 136 return NULL; |
137 | 137 |
138 ExtensionService* service = profile_->GetExtensionService(); | 138 ExtensionService* service = profile_->GetExtensionService(); |
139 if (!service) | 139 if (!service) |
140 return NULL; | 140 return NULL; |
141 | 141 |
142 // May be null if somebody typos a chrome-extension:// URL. | 142 // Reload the extension if it has crashed. |
| 143 // TODO(yoz): This reload doesn't happen synchronously for unpacked |
| 144 // extensions. It seems to be fast enough, but there is a race. |
| 145 // We should delay loading until the extension has reloaded. |
| 146 if (service->GetTerminatedExtension(site.host())) |
| 147 service->ReloadExtension(site.host()); |
| 148 |
| 149 // May be null if the extension doesn't exist, for example if somebody typos |
| 150 // a chrome-extension:// URL. |
143 return service->GetExtensionByURL(site); | 151 return service->GetExtensionByURL(site); |
144 } | 152 } |
145 | 153 |
146 void ChromeRenderViewHostObserver::RemoveRenderViewHostForExtensions( | 154 void ChromeRenderViewHostObserver::RemoveRenderViewHostForExtensions( |
147 RenderViewHost* rvh) { | 155 RenderViewHost* rvh) { |
148 ExtensionProcessManager* process_manager = | 156 ExtensionProcessManager* process_manager = |
149 profile_->GetExtensionProcessManager(); | 157 profile_->GetExtensionProcessManager(); |
150 if (process_manager) | 158 if (process_manager) |
151 process_manager->UnregisterRenderViewHost(rvh); | 159 process_manager->UnregisterRenderViewHost(rvh); |
152 } | 160 } |
153 | 161 |
154 void ChromeRenderViewHostObserver::OnDomOperationResponse( | 162 void ChromeRenderViewHostObserver::OnDomOperationResponse( |
155 const std::string& json_string, int automation_id) { | 163 const std::string& json_string, int automation_id) { |
156 DomOperationNotificationDetails details(json_string, automation_id); | 164 DomOperationNotificationDetails details(json_string, automation_id); |
157 content::NotificationService::current()->Notify( | 165 content::NotificationService::current()->Notify( |
158 chrome::NOTIFICATION_DOM_OPERATION_RESPONSE, | 166 chrome::NOTIFICATION_DOM_OPERATION_RESPONSE, |
159 content::Source<RenderViewHost>(render_view_host()), | 167 content::Source<RenderViewHost>(render_view_host()), |
160 content::Details<DomOperationNotificationDetails>(&details)); | 168 content::Details<DomOperationNotificationDetails>(&details)); |
161 } | 169 } |
162 | 170 |
163 void ChromeRenderViewHostObserver::OnFocusedEditableNodeTouched() { | 171 void ChromeRenderViewHostObserver::OnFocusedEditableNodeTouched() { |
164 content::NotificationService::current()->Notify( | 172 content::NotificationService::current()->Notify( |
165 chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED, | 173 chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED, |
166 content::Source<RenderViewHost>(render_view_host()), | 174 content::Source<RenderViewHost>(render_view_host()), |
167 content::NotificationService::NoDetails()); | 175 content::NotificationService::NoDetails()); |
168 } | 176 } |
OLD | NEW |