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

Unified Diff: chrome/browser/extensions/active_tab_permission_granter.cc

Issue 890083002: [Extensions] Propagate activeTab hosts to extension background pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
Index: chrome/browser/extensions/active_tab_permission_granter.cc
diff --git a/chrome/browser/extensions/active_tab_permission_granter.cc b/chrome/browser/extensions/active_tab_permission_granter.cc
index 4e7383864a1e63706427d5b868767a1dc8504a9e..f9385232a1889b99020d612c6b039b4d6d3440f0 100644
--- a/chrome/browser/extensions/active_tab_permission_granter.cc
+++ b/chrome/browser/extensions/active_tab_permission_granter.cc
@@ -8,9 +8,12 @@
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
+#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_registry.h"
+#include "extensions/browser/process_manager.h"
#include "extensions/common/extension_messages.h"
#include "extensions/common/feature_switch.h"
#include "extensions/common/permissions/permission_set.h"
@@ -66,13 +69,24 @@ void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) {
const content::NavigationEntry* navigation_entry =
web_contents()->GetController().GetVisibleEntry();
if (navigation_entry) {
- content::RenderViewHost* render_view_host =
- web_contents()->GetRenderViewHost();
- render_view_host->Send(new ExtensionMsg_UpdateTabSpecificPermissions(
- render_view_host->GetRoutingID(),
- navigation_entry->GetURL(),
- extension->id(),
- new_hosts));
+ std::set<content::RenderProcessHost*> hosts;
+ // We update the tabs renderer, as well as the extension's background page
+ // if one exists.
+ hosts.insert(web_contents()->GetRenderProcessHost());
+ ExtensionHost* background_page =
+ ProcessManager::Get(web_contents()->GetBrowserContext())->
+ GetBackgroundHostForExtension(extension->id());
not at google - send to devlin 2015/02/03 19:29:12 What about if the event page hasn't started yet? F
Devlin 2015/02/04 22:26:02 Good point. Done.
+ if (background_page)
+ hosts.insert(background_page->render_process_host());
+
+ for (content::RenderProcessHost* host : hosts) {
+ host->Send(new ExtensionMsg_UpdateTabSpecificPermissions(
+ navigation_entry->GetURL(),
+ extension->id(),
+ new_hosts,
+ tab_id_));
+ }
+
// If more things ever need to know about this, we should consider making
// an observer class.
// It's important that this comes after the IPC is sent to the renderer,
@@ -129,17 +143,26 @@ void ActiveTabPermissionGranter::ClearActiveExtensionsAndNotify() {
return;
std::vector<std::string> extension_ids;
+ std::set<content::RenderProcessHost*> hosts;
+ hosts.insert(web_contents()->GetRenderProcessHost());
+ ProcessManager* process_manager =
+ ProcessManager::Get(web_contents()->GetBrowserContext());
for (ExtensionSet::const_iterator it = granted_extensions_.begin();
it != granted_extensions_.end(); ++it) {
it->get()->permissions_data()->ClearTabSpecificPermissions(tab_id_);
extension_ids.push_back((*it)->id());
+ ExtensionHost* background_page =
+ process_manager->GetBackgroundHostForExtension(it->get()->id());
+ if (background_page)
+ hosts.insert(background_page->render_process_host());
}
- content::RenderViewHost* render_view_host =
- web_contents()->GetRenderViewHost();
- render_view_host->Send(new ExtensionMsg_ClearTabSpecificPermissions(
- render_view_host->GetRoutingID(), extension_ids));
+ // Notify the tab and any extension background pages.
+ for (content::RenderProcessHost* host : hosts) {
+ host->Send(new ExtensionMsg_ClearTabSpecificPermissions(
+ extension_ids, tab_id_));
+ }
granted_extensions_.Clear();
}
« no previous file with comments | « no previous file | chrome/chrome_renderer.gypi » ('j') | chrome/test/data/extensions/api_test/active_tab/background.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698