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

Side by Side Diff: chrome/browser/renderer_host/chrome_render_view_host_observer.cc

Issue 10113005: Remove EPM:all_hosts_ and use all_extension_views_ instead. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: interactive_ui_tests Created 8 years, 8 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 unified diff | Download patch
OLDNEW
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"
11 #include "chrome/common/chrome_notification_types.h" 11 #include "chrome/common/chrome_notification_types.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/extensions/extension_messages.h" 13 #include "chrome/common/extensions/extension_messages.h"
14 #include "chrome/common/render_messages.h" 14 #include "chrome/common/render_messages.h"
15 #include "chrome/common/url_constants.h" 15 #include "chrome/common/url_constants.h"
16 #include "content/public/browser/child_process_security_policy.h" 16 #include "content/public/browser/child_process_security_policy.h"
17 #include "content/public/browser/notification_service.h" 17 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/render_process_host.h" 18 #include "content/public/browser/render_process_host.h"
19 #include "content/public/browser/render_view_host.h" 19 #include "content/public/browser/render_view_host.h"
20 #include "content/public/browser/render_view_host_delegate.h" 20 #include "content/public/browser/render_view_host_delegate.h"
21 #include "content/public/browser/site_instance.h" 21 #include "content/public/browser/site_instance.h"
22 #include "content/public/browser/web_contents.h"
23 #include "content/browser/web_contents/web_contents_impl.h"
benwells 2012/04/19 11:34:02 This causes a build error due to an illegal depend
22 24
23 using content::ChildProcessSecurityPolicy; 25 using content::ChildProcessSecurityPolicy;
24 using content::RenderViewHost; 26 using content::RenderViewHost;
25 using content::SiteInstance; 27 using content::SiteInstance;
26 28
27 ChromeRenderViewHostObserver::ChromeRenderViewHostObserver( 29 ChromeRenderViewHostObserver::ChromeRenderViewHostObserver(
28 RenderViewHost* render_view_host, chrome_browser_net::Predictor* predictor) 30 RenderViewHost* render_view_host, chrome_browser_net::Predictor* predictor)
29 : content::RenderViewHostObserver(render_view_host), 31 : content::RenderViewHostObserver(render_view_host),
30 predictor_(predictor) { 32 predictor_(predictor) {
31 SiteInstance* site_instance = render_view_host->GetSiteInstance(); 33 SiteInstance* site_instance = render_view_host->GetSiteInstance();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 void ChromeRenderViewHostObserver::InitRenderViewHostForExtensions() { 80 void ChromeRenderViewHostObserver::InitRenderViewHostForExtensions() {
79 const Extension* extension = GetExtension(); 81 const Extension* extension = GetExtension();
80 if (!extension) 82 if (!extension)
81 return; 83 return;
82 84
83 ExtensionProcessManager* process_manager = 85 ExtensionProcessManager* process_manager =
84 profile_->GetExtensionProcessManager(); 86 profile_->GetExtensionProcessManager();
85 CHECK(process_manager); 87 CHECK(process_manager);
86 88
87 // TODO(creis): Use this to replace SetInstalledAppForRenderer. 89 // TODO(creis): Use this to replace SetInstalledAppForRenderer.
88 process_manager->RegisterRenderViewHost(render_view_host(), extension); 90 content::WebContents* contents = GetWebContents(render_view_host());
91 if (contents)
92 process_manager->RegisterWebContents(contents, extension);
89 93
90 if (extension->is_app()) { 94 if (extension->is_app()) {
91 // Record which, if any, installed app is associated with this process. 95 // Record which, if any, installed app is associated with this process.
92 // TODO(aa): Totally lame to store this state in a global map in extension 96 // TODO(aa): Totally lame to store this state in a global map in extension
93 // service. Can we get it from EPM instead? 97 // service. Can we get it from EPM instead?
94 profile_->GetExtensionService()->SetInstalledAppForRenderer( 98 profile_->GetExtensionService()->SetInstalledAppForRenderer(
95 render_view_host()->GetProcess()->GetID(), extension); 99 render_view_host()->GetProcess()->GetID(), extension);
96 } 100 }
97 } 101 }
98 102
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 if (service->GetTerminatedExtension(site.host())) 166 if (service->GetTerminatedExtension(site.host()))
163 service->ReloadExtension(site.host()); 167 service->ReloadExtension(site.host());
164 168
165 // May be null if the extension doesn't exist, for example if somebody typos 169 // May be null if the extension doesn't exist, for example if somebody typos
166 // a chrome-extension:// URL. 170 // a chrome-extension:// URL.
167 return service->extensions()->GetByID(site.host()); 171 return service->extensions()->GetByID(site.host());
168 } 172 }
169 173
170 void ChromeRenderViewHostObserver::RemoveRenderViewHostForExtensions( 174 void ChromeRenderViewHostObserver::RemoveRenderViewHostForExtensions(
171 RenderViewHost* rvh) { 175 RenderViewHost* rvh) {
176 content::WebContents* contents = GetWebContents(rvh);
177 if (!contents)
178 return;
179
172 ExtensionProcessManager* process_manager = 180 ExtensionProcessManager* process_manager =
173 profile_->GetExtensionProcessManager(); 181 profile_->GetExtensionProcessManager();
174 if (process_manager) 182 if (process_manager)
175 process_manager->UnregisterRenderViewHost(rvh); 183 process_manager->UnregisterWebContents(contents);
Charlie Reis 2012/04/19 21:42:10 I don't think this will get called if you navigate
184 }
185
186 content::WebContents* ChromeRenderViewHostObserver::GetWebContents(
187 RenderViewHost* rvh) {
188 // TODO(benwells): Remove this hack. Instead registration should
189 // be made by the view owning the WebContents (e.g. ShellWindow),
190 // or we go back to registering RenderViewHosts and expose their
191 // is_loading field.
192 content::ViewType view_type = rvh->GetDelegate()->GetRenderViewType();
193 if (view_type == content::VIEW_TYPE_WEB_CONTENTS)
194 return static_cast<WebContentsImpl*>(rvh->GetDelegate());
benwells 2012/04/19 11:34:02 How should I do this correctly? If I use reinterp
Matt Perry 2012/04/19 20:53:19 You're having trouble here because you're trying t
195 return NULL;
176 } 196 }
177 197
178 void ChromeRenderViewHostObserver::OnFocusedEditableNodeTouched() { 198 void ChromeRenderViewHostObserver::OnFocusedEditableNodeTouched() {
179 content::NotificationService::current()->Notify( 199 content::NotificationService::current()->Notify(
180 chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED, 200 chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED,
181 content::Source<RenderViewHost>(render_view_host()), 201 content::Source<RenderViewHost>(render_view_host()),
182 content::NotificationService::NoDetails()); 202 content::NotificationService::NoDetails());
183 } 203 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698