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