Implement PermissionManager

This commit is contained in:
Cheng Zhao 2015-05-22 14:50:41 +08:00
parent eee334c7f6
commit 0cbf8b6cd2
5 changed files with 133 additions and 0 deletions

View file

@ -7,6 +7,7 @@
#include "browser/brightray_paths.h"
#include "browser/inspectable_web_contents_impl.h"
#include "browser/network_delegate.h"
#include "browser/permission_manager.h"
#include "common/application_info.h"
#include "base/files/file_path.h"
@ -158,4 +159,10 @@ content::SSLHostStateDelegate* BrowserContext::GetSSLHostStateDelegate() {
return nullptr;
}
content::PermissionManager* BrowserContext::GetPermissionManager() {
if (!permission_manager_.get())
permission_manager_.reset(new PermissionManager);
return permission_manager_.get();
}
} // namespace brightray

View file

@ -5,6 +5,7 @@
#ifndef BRIGHTRAY_BROWSER_BROWSER_CONTEXT_H_
#define BRIGHTRAY_BROWSER_BROWSER_CONTEXT_H_
#include "browser/permission_manager.h"
#include "browser/url_request_context_getter.h"
#include "content/public/browser/browser_context.h"
@ -14,6 +15,8 @@ class PrefService;
namespace brightray {
class PermissionManager;
class BrowserContext : public content::BrowserContext,
public brightray::URLRequestContextGetter::Delegate {
public:
@ -63,11 +66,13 @@ class BrowserContext : public content::BrowserContext,
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
content::PushMessagingService* GetPushMessagingService() override;
content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
content::PermissionManager* GetPermissionManager() override;
base::FilePath path_;
scoped_ptr<ResourceContext> resource_context_;
scoped_refptr<URLRequestContextGetter> url_request_getter_;
scoped_ptr<PrefService> prefs_;
scoped_ptr<PermissionManager> permission_manager_;
DISALLOW_COPY_AND_ASSIGN(BrowserContext);
};

View file

@ -0,0 +1,65 @@
// Copyright (c) 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-CHROMIUM file.
#include "browser/permission_manager.h"
#include "base/callback.h"
#include "content/public/browser/permission_type.h"
namespace brightray {
PermissionManager::PermissionManager() {
}
PermissionManager::~PermissionManager() {
}
void PermissionManager::RequestPermission(
content::PermissionType permission,
content::WebContents* web_contents,
int request_id,
const GURL& requesting_origin,
bool user_gesture,
const base::Callback<void(content::PermissionStatus)>& callback) {
callback.Run(content::PERMISSION_STATUS_GRANTED);
}
void PermissionManager::CancelPermissionRequest(
content::PermissionType permission,
content::WebContents* web_contents,
int request_id,
const GURL& requesting_origin) {
}
void PermissionManager::ResetPermission(
content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) {
}
content::PermissionStatus PermissionManager::GetPermissionStatus(
content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) {
return content::PERMISSION_STATUS_GRANTED;
}
void PermissionManager::RegisterPermissionUsage(
content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) {
}
int PermissionManager::SubscribePermissionStatusChange(
content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin,
const base::Callback<void(content::PermissionStatus)>& callback) {
return -1;
}
void PermissionManager::UnsubscribePermissionStatusChange(int subscription_id) {
}
} // namespace brightray

View file

@ -0,0 +1,54 @@
// Copyright (c) 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-CHROMIUM file.
#ifndef BROWSER_PERMISSION_MANAGER_H_
#define BROWSER_PERMISSION_MANAGER_H_
#include "base/callback_forward.h"
#include "base/macros.h"
#include "content/public/browser/permission_manager.h"
namespace brightray {
class PermissionManager : public content::PermissionManager {
public:
PermissionManager();
~PermissionManager() override;
// content::PermissionManager:
void RequestPermission(
content::PermissionType permission,
content::WebContents* web_contents,
int request_id,
const GURL& requesting_origin,
bool user_gesture,
const base::Callback<void(content::PermissionStatus)>& callback) override;
void CancelPermissionRequest(content::PermissionType permission,
content::WebContents* web_contents,
int request_id,
const GURL& requesting_origin) override;
void ResetPermission(content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) override;
content::PermissionStatus GetPermissionStatus(
content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) override;
void RegisterPermissionUsage(content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) override;
int SubscribePermissionStatusChange(
content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin,
const base::Callback<void(content::PermissionStatus)>& callback) override;
void UnsubscribePermissionStatusChange(int subscription_id) override;
private:
DISALLOW_COPY_AND_ASSIGN(PermissionManager);
};
} // namespace brightray
#endif // BROWSER_PERMISSION_MANAGER_H_

View file

@ -42,6 +42,8 @@
'browser/notification_presenter.h',
'browser/notification_presenter_mac.h',
'browser/notification_presenter_mac.mm',
'browser/permission_manager.cc',
'browser/permission_manager.h',
'browser/platform_notification_service_impl.cc',
'browser/platform_notification_service_impl.h',
'browser/linux/notification_presenter_linux.h',