GitHub PullRequestReviewCommentEvent at 2014-02-11 09:56:47
Repository: crosswalk
Actor: pozdnyakov
Payload: {"comment":{"url":"https://api.github.com/repos/crosswalk-project/crosswalk/pulls/comments/9618056","id":9618056,"diff_hunk":"@@ -627,5 +632,76 @@ Application* ApplicationService::Launch(\n   return application;\n }\n \n+void ApplicationService::CheckAPIAccessControl(const std::string& app_id,\n+    const std::string& extension_name,\n+    const std::string& api_name, const PermissionCallback& callback) {\n+  Application* app = GetApplicationByID(app_id);\n+  if (!app) {\n+    LOG(ERROR) << \"No running application found with ID: \"\n+      << app_id;\n+    callback.Run(UNDEFINED_RUNTIME_PERM);\n+    return;\n+  }\n+  if (!app->ContainsExtension(extension_name)) {\n+    LOG(ERROR) << \"Can not find extension: \"\n+      << extension_name << \" of Application with ID: \"\n+      << app_id;\n+    callback.Run(UNDEFINED_RUNTIME_PERM);\n+    return;\n+  }\n+  // Permission name should have been registered at extension initialization.\n+  std::string permission_name =\n+      app->GetRegisteredPermissionName(extension_name, api_name);\n+  if (permission_name.size() == 0) {\n+    LOG(ERROR) << \"API: \" << api_name << \" of extension: \"\n+      << extension_name << \" not registered!\";\n+    callback.Run(UNDEFINED_RUNTIME_PERM);\n+    return;\n+  }\n+  // Okay, since we have the permission name, let's get down to the policies.\n+  // First, find out whether the permission is stored for the current session.\n+  StoredPermission perm = app->GetPermission(\n+      SESSION_PERMISSION, permission_name);\n+  if (perm != UNDEFINED_STORED_PERM) {\n+    // \"PROMPT\" should not be in the session storage.\n+    DCHECK(perm != PROMPT);\n+    if (perm == ALLOW) {\n+      callback.Run(ALLOW_SESSION);\n+      return;\n+    }\n+    if (perm == DENY) {\n+      callback.Run(DENY_SESSION);\n+      return;\n+    }\n+    NOTREACHED();\n+  }\n+  // Then, consult the persistent policy storage.","path":"application/browser/application_service.cc","position":59,"original_position":59,"commit_id":"3331e9e0c6c4f5e07ac3b97a586a2980f459de21","original_commit_id":"3331e9e0c6c4f5e07ac3b97a586a2980f459de21","user":{"login":"pozdnyakov","id":998253,"avatar_url":"https://gravatar.com/avatar/4ffb512f7312fbe30369fb8b78de59af?d=https%3A%2F%2Fidenticons.github.com%2F8e231c4fb7821d5ecb7d9114e4a4a204.png&r=x","gravatar_id":"4ffb512f7312fbe30369fb8b78de59af","url":"https://api.github.com/users/pozdnyakov","html_url":"https://github.com/pozdnyakov","followers_url":"https://api.github.com/users/pozdnyakov/followers","following_url":"https://api.github.com/users/pozdnyakov/following{/other_user}","gists_url":"https://api.github.com/users/pozdnyakov/gists{/gist_id}","starred_url":"https://api.github.com/users/pozdnyakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pozdnyakov/subscriptions","organizations_url":"https://api.github.com/users/pozdnyakov/orgs","repos_url":"https://api.github.com/users/pozdnyakov/repos","events_url":"https://api.github.com/users/pozdnyakov/events{/privacy}","received_events_url":"https://api.github.com/users/pozdnyakov/received_events","type":"User","site_admin":false},"body":"query the persistent policy storage?","created_at":"2014-02-11T09:56:47Z","updated_at":"2014-02-11T09:56:47Z","html_url":"https://github.com/crosswalk-project/crosswalk/pull/1571#discussion_r9618056","pull_request_url":"https://api.github.com/repos/crosswalk-project/crosswalk/pulls/1571","_links":{"self":{"href":"https://api.github.com/repos/crosswalk-project/crosswalk/pulls/comments/9618056"},"html":{"href":"https://github.com/crosswalk-project/crosswalk/pull/1571#discussion_r9618056"},"pull_request":{"href":"https://api.github.com/repos/crosswalk-project/crosswalk/pulls/1571"}}}}