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

Unified Diff: extensions/renderer/extension_helper.cc

Issue 708713003: Don't crash when granting permissions to active tab. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change for with iterators to a foreach. Created 6 years, 1 month 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
« no previous file with comments | « extensions/renderer/extension_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/extension_helper.cc
diff --git a/extensions/renderer/extension_helper.cc b/extensions/renderer/extension_helper.cc
index fef086948a3e113184db846b7f40a7f2e82e0f33..d6f5cb81dbb8ae43b5ac692e1fa4f751ba9355af 100644
--- a/extensions/renderer/extension_helper.cc
+++ b/extensions/renderer/extension_helper.cc
@@ -9,6 +9,8 @@
#include "extensions/common/api/messaging/message.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_messages.h"
+#include "extensions/common/permissions/permissions_data.h"
+#include "extensions/common/url_pattern_set.h"
#include "extensions/renderer/api/automation/automation_api_helper.h"
#include "extensions/renderer/console.h"
#include "extensions/renderer/dispatcher.h"
@@ -150,6 +152,10 @@ bool ExtensionHelper::OnMessageReceived(const IPC::Message& message) {
OnAddMessageToConsole)
IPC_MESSAGE_HANDLER(ExtensionMsg_AppWindowClosed,
OnAppWindowClosed)
+ IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateTabSpecificPermissions,
+ OnUpdateTabSpecificPermissions)
+ IPC_MESSAGE_HANDLER(ExtensionMsg_ClearTabSpecificPermissions,
+ OnClearTabSpecificPermissions)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -265,4 +271,35 @@ void ExtensionHelper::OnAppWindowClosed() {
"onAppWindowClosed");
}
+void ExtensionHelper::OnUpdateTabSpecificPermissions(
+ const GURL& url,
+ const std::string& extension_id,
+ const extensions::URLPatternSet& origin_set) {
+ // Check against the URL to avoid races.
+ GURL active_url(render_view()->GetWebView()->mainFrame()->document().url());
+ if (active_url != url)
+ return;
+
+ const Extension* extension = dispatcher_->extensions()->GetByID(extension_id);
+ if (!extension)
+ return;
+
+ extension->permissions_data()->UpdateTabSpecificPermissions(
+ tab_id_,
+ new extensions::PermissionSet(extensions::APIPermissionSet(),
+ extensions::ManifestPermissionSet(),
+ origin_set,
+ extensions::URLPatternSet()));
+}
+
+void ExtensionHelper::OnClearTabSpecificPermissions(
+ const std::vector<std::string>& extension_ids) {
+ for (const auto& id : extension_ids) {
+ const extensions::Extension* extension =
+ dispatcher_->extensions()->GetByID(id);
+ if (extension)
+ extension->permissions_data()->ClearTabSpecificPermissions(tab_id_);
+ }
+}
+
} // namespace extensions
« no previous file with comments | « extensions/renderer/extension_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698