Index: extensions/browser/api/declarative/declarative_api.cc |
diff --git a/extensions/browser/api/declarative/declarative_api.cc b/extensions/browser/api/declarative/declarative_api.cc |
index 8aa0b4d218cf3f2c52dc596ac06630ab82b35480..b37d5009a7e75ce29a6a6bc6305aca2dc9458ea3 100644 |
--- a/extensions/browser/api/declarative/declarative_api.cc |
+++ b/extensions/browser/api/declarative/declarative_api.cc |
@@ -33,27 +33,6 @@ namespace extensions { |
namespace { |
-const char kWebRequest[] = "declarativeWebRequest."; |
-const char kWebViewExpectedError[] = "Webview event with Webview ID expected."; |
- |
-bool IsWebViewEvent(const std::string& event_name) { |
- // Sample event names: |
- // webViewInternal.onRequest. |
- // webViewInternal.onMessage. |
- return event_name.compare(0, |
- strlen(webview::kWebViewEventPrefix), |
- webview::kWebViewEventPrefix) == 0; |
-} |
- |
-std::string GetWebRequestEventName(const std::string& event_name) { |
- std::string web_request_event_name(event_name); |
- if (IsWebViewEvent(web_request_event_name)) { |
- web_request_event_name.replace( |
- 0, strlen(webview::kWebViewEventPrefix), kWebRequest); |
- } |
- return web_request_event_name; |
-} |
- |
void ConvertBinaryDictionaryValuesToBase64(base::DictionaryValue* dict); |
// Encodes |binary| as base64 and returns a new StringValue populated with the |
@@ -122,7 +101,10 @@ RulesFunction::~RulesFunction() {} |
bool RulesFunction::HasPermission() { |
std::string event_name; |
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &event_name)); |
- if (IsWebViewEvent(event_name) && |
+ int web_view_instance_id = 0; |
not at google - send to devlin
2014/12/11 22:10:48
I think this is a good change.
An even better cha
Xi Han
2014/12/12 22:28:30
This is a good suggestion, but I found when this f
|
+ EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &web_view_instance_id)); |
+ |
+ if (web_view_instance_id != 0 && |
extension_->permissions_data()->HasAPIPermission( |
extensions::APIPermission::kWebView)) |
return true; |
@@ -143,14 +125,10 @@ bool RulesFunction::RunAsync() { |
EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &web_view_instance_id)); |
int embedder_process_id = render_view_host()->GetProcess()->GetID(); |
- bool has_web_view = web_view_instance_id != 0; |
- if (has_web_view != IsWebViewEvent(event_name)) |
- EXTENSION_FUNCTION_ERROR(kWebViewExpectedError); |
- event_name = GetWebRequestEventName(event_name); |
- |
+ bool from_web_view = web_view_instance_id != 0; |
// If we are not operating on a particular <webview>, then the key is 0. |
int rules_registry_id = RulesRegistryService::kDefaultRulesRegistryID; |
- if (has_web_view) { |
+ if (from_web_view) { |
rules_registry_id = WebViewGuest::GetOrGenerateRulesRegistryID( |
embedder_process_id, web_view_instance_id); |
} |