| 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/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" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/common/extensions/extension_messages.h" | 14 #include "chrome/common/extensions/extension_messages.h" |
| 15 #include "chrome/common/render_messages.h" | 15 #include "chrome/common/render_messages.h" |
| 16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 17 #include "content/browser/child_process_security_policy.h" | 17 #include "content/browser/child_process_security_policy.h" |
| 18 #include "content/browser/renderer_host/render_view_host.h" | 18 #include "content/browser/renderer_host/render_view_host.h" |
| 19 #include "content/browser/site_instance.h" | |
| 20 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
| 21 #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" |
| 22 | 22 |
| 23 ChromeRenderViewHostObserver::ChromeRenderViewHostObserver( | 23 ChromeRenderViewHostObserver::ChromeRenderViewHostObserver( |
| 24 RenderViewHost* render_view_host, chrome_browser_net::Predictor* predictor) | 24 RenderViewHost* render_view_host, chrome_browser_net::Predictor* predictor) |
| 25 : content::RenderViewHostObserver(render_view_host), | 25 : content::RenderViewHostObserver(render_view_host), |
| 26 predictor_(predictor) { | 26 predictor_(predictor) { |
| 27 SiteInstance* site_instance = render_view_host->site_instance(); | 27 content::SiteInstance* site_instance = render_view_host->site_instance(); |
| 28 profile_ = Profile::FromBrowserContext( | 28 profile_ = Profile::FromBrowserContext( |
| 29 site_instance->GetBrowserContext()); | 29 site_instance->GetBrowserContext()); |
| 30 | 30 |
| 31 InitRenderViewHostForExtensions(); | 31 InitRenderViewHostForExtensions(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 ChromeRenderViewHostObserver::~ChromeRenderViewHostObserver() { | 34 ChromeRenderViewHostObserver::~ChromeRenderViewHostObserver() { |
| 35 RemoveRenderViewHostForExtensions(render_view_host()); | 35 RemoveRenderViewHostForExtensions(render_view_host()); |
| 36 } | 36 } |
| 37 | 37 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 (type == Extension::TYPE_HOSTED_APP && | 125 (type == Extension::TYPE_HOSTED_APP && |
| 126 extension->location() == Extension::COMPONENT)) { | 126 extension->location() == Extension::COMPONENT)) { |
| 127 Send(new ExtensionMsg_ActivateExtension(extension->id())); | 127 Send(new ExtensionMsg_ActivateExtension(extension->id())); |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| 131 const Extension* ChromeRenderViewHostObserver::GetExtension() { | 131 const Extension* ChromeRenderViewHostObserver::GetExtension() { |
| 132 // Note that due to ChromeContentBrowserClient::GetEffectiveURL(), hosted apps | 132 // Note that due to ChromeContentBrowserClient::GetEffectiveURL(), hosted apps |
| 133 // (excluding bookmark apps) will have a chrome-extension:// URL for their | 133 // (excluding bookmark apps) will have a chrome-extension:// URL for their |
| 134 // site, so we can ignore that wrinkle here. | 134 // site, so we can ignore that wrinkle here. |
| 135 SiteInstance* site_instance = render_view_host()->site_instance(); | 135 content::SiteInstance* site_instance = render_view_host()->site_instance(); |
| 136 const GURL& site = site_instance->site(); | 136 const GURL& site = site_instance->GetSite(); |
| 137 | 137 |
| 138 if (!site.SchemeIs(chrome::kExtensionScheme)) | 138 if (!site.SchemeIs(chrome::kExtensionScheme)) |
| 139 return NULL; | 139 return NULL; |
| 140 | 140 |
| 141 ExtensionService* service = profile_->GetExtensionService(); | 141 ExtensionService* service = profile_->GetExtensionService(); |
| 142 if (!service) | 142 if (!service) |
| 143 return NULL; | 143 return NULL; |
| 144 | 144 |
| 145 // Reload the extension if it has crashed. | 145 // Reload the extension if it has crashed. |
| 146 // TODO(yoz): This reload doesn't happen synchronously for unpacked | 146 // TODO(yoz): This reload doesn't happen synchronously for unpacked |
| (...skipping 23 matching lines...) Expand all Loading... |
| 170 content::Source<RenderViewHost>(render_view_host()), | 170 content::Source<RenderViewHost>(render_view_host()), |
| 171 content::Details<DomOperationNotificationDetails>(&details)); | 171 content::Details<DomOperationNotificationDetails>(&details)); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void ChromeRenderViewHostObserver::OnFocusedEditableNodeTouched() { | 174 void ChromeRenderViewHostObserver::OnFocusedEditableNodeTouched() { |
| 175 content::NotificationService::current()->Notify( | 175 content::NotificationService::current()->Notify( |
| 176 chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED, | 176 chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED, |
| 177 content::Source<RenderViewHost>(render_view_host()), | 177 content::Source<RenderViewHost>(render_view_host()), |
| 178 content::NotificationService::NoDetails()); | 178 content::NotificationService::NoDetails()); |
| 179 } | 179 } |
| OLD | NEW |