Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
permission control from manifest and webview attribute
- Loading branch information
Showing
11 changed files
with
305 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// Copyright 2014 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 file. | ||
|
||
#include "content/nw/src/browser/shell_extensions_api_client.h" | ||
|
||
#include "base/files/file_path.h" | ||
#include "content/public/browser/browser_context.h" | ||
#include "content/public/browser/browser_thread.h" | ||
#include "content/nw/src/browser/shell_web_view_guest_delegate.h" | ||
#include "extensions/browser/api/device_permissions_prompt.h" | ||
#include "extensions/browser/api/virtual_keyboard_private/virtual_keyboard_delegate.h" | ||
#include "extensions/browser/api/web_request/web_request_event_router_delegate.h" | ||
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h" | ||
#include "extensions/browser/guest_view/web_view/web_view_permission_helper_delegate.h" | ||
#include "extensions/browser/guest_view/web_view/web_view_guest.h" | ||
|
||
namespace extensions { | ||
|
||
ShellExtensionsAPIClient::ShellExtensionsAPIClient() {} | ||
|
||
ShellExtensionsAPIClient::~ShellExtensionsAPIClient() {} | ||
|
||
void ShellExtensionsAPIClient::AddAdditionalValueStoreCaches( | ||
content::BrowserContext* context, | ||
const scoped_refptr<SettingsStorageFactory>& factory, | ||
const scoped_refptr<ObserverListThreadSafe<SettingsObserver> >& observers, | ||
std::map<settings_namespace::Namespace, ValueStoreCache*>* caches) { | ||
} | ||
|
||
AppViewGuestDelegate* ShellExtensionsAPIClient::CreateAppViewGuestDelegate() | ||
const { | ||
return NULL; | ||
} | ||
|
||
double ShellWebViewGuestDelegate::GetZoom() { | ||
return 1.0; | ||
} | ||
|
||
void ShellWebViewGuestDelegate::OnSetZoom(double zoom_factor) { | ||
} | ||
|
||
void ShellWebViewGuestDelegate::OnShowContextMenu( | ||
int request_id, | ||
const MenuItemVector* items) { | ||
} | ||
|
||
bool ShellWebViewGuestDelegate::HandleContextMenu( | ||
const content::ContextMenuParams& params) { | ||
return false; | ||
} | ||
|
||
ExtensionOptionsGuestDelegate* | ||
ShellExtensionsAPIClient::CreateExtensionOptionsGuestDelegate( | ||
ExtensionOptionsGuest* guest) const { | ||
return NULL; | ||
} | ||
|
||
scoped_ptr<MimeHandlerViewGuestDelegate> | ||
ShellExtensionsAPIClient::CreateMimeHandlerViewGuestDelegate( | ||
MimeHandlerViewGuest* guest) const { | ||
return scoped_ptr<MimeHandlerViewGuestDelegate>(); | ||
} | ||
|
||
WebViewGuestDelegate* ShellExtensionsAPIClient::CreateWebViewGuestDelegate( | ||
WebViewGuest* web_view_guest) const { | ||
return new ShellWebViewGuestDelegate(web_view_guest); | ||
} | ||
|
||
WebViewPermissionHelperDelegate* ShellExtensionsAPIClient:: | ||
CreateWebViewPermissionHelperDelegate( | ||
WebViewPermissionHelper* web_view_permission_helper) const { | ||
return new WebViewPermissionHelperDelegate(web_view_permission_helper); | ||
} | ||
|
||
WebRequestEventRouterDelegate* | ||
ShellExtensionsAPIClient::CreateWebRequestEventRouterDelegate() const { | ||
return new WebRequestEventRouterDelegate(); | ||
} | ||
|
||
scoped_refptr<ContentRulesRegistry> | ||
ShellExtensionsAPIClient::CreateContentRulesRegistry( | ||
content::BrowserContext* browser_context, | ||
RulesCacheDelegate* cache_delegate) const { | ||
return scoped_refptr<ContentRulesRegistry>(); | ||
} | ||
|
||
scoped_ptr<DevicePermissionsPrompt> | ||
ShellExtensionsAPIClient::CreateDevicePermissionsPrompt( | ||
content::WebContents* web_contents) const { | ||
return nullptr; | ||
} | ||
|
||
scoped_ptr<VirtualKeyboardDelegate> | ||
ShellExtensionsAPIClient::CreateVirtualKeyboardDelegate() const { | ||
return nullptr; | ||
} | ||
|
||
ManagementAPIDelegate* ShellExtensionsAPIClient::CreateManagementAPIDelegate() | ||
const { | ||
return nullptr; | ||
} | ||
|
||
} // namespace extensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2014 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 file. | ||
|
||
#ifndef NW_BROWSER_EXTENSIONS_API_CHROME_EXTENSIONS_API_CLIENT_H_ | ||
#define NW_BROWSER_EXTENSIONS_API_CHROME_EXTENSIONS_API_CLIENT_H_ | ||
|
||
#include "base/compiler_specific.h" | ||
#include "extensions/browser/api/extensions_api_client.h" | ||
|
||
namespace extensions { | ||
|
||
// Extra support for extensions APIs in Chrome. | ||
class ShellExtensionsAPIClient : public ExtensionsAPIClient { | ||
public: | ||
ShellExtensionsAPIClient(); | ||
~ShellExtensionsAPIClient() override; | ||
|
||
// ExtensionsApiClient implementation. | ||
void AddAdditionalValueStoreCaches( | ||
content::BrowserContext* context, | ||
const scoped_refptr<SettingsStorageFactory>& factory, | ||
const scoped_refptr<ObserverListThreadSafe<SettingsObserver>>& observers, | ||
std::map<settings_namespace::Namespace, ValueStoreCache*>* caches) | ||
override; | ||
AppViewGuestDelegate* CreateAppViewGuestDelegate() const override; | ||
ExtensionOptionsGuestDelegate* CreateExtensionOptionsGuestDelegate( | ||
ExtensionOptionsGuest* guest) const override; | ||
scoped_ptr<MimeHandlerViewGuestDelegate> CreateMimeHandlerViewGuestDelegate( | ||
MimeHandlerViewGuest* guest) const override; | ||
WebViewGuestDelegate* CreateWebViewGuestDelegate( | ||
WebViewGuest* web_view_guest) const override; | ||
WebViewPermissionHelperDelegate* CreateWebViewPermissionHelperDelegate( | ||
WebViewPermissionHelper* web_view_permission_helper) const override; | ||
WebRequestEventRouterDelegate* CreateWebRequestEventRouterDelegate() | ||
const override; | ||
scoped_refptr<ContentRulesRegistry> CreateContentRulesRegistry( | ||
content::BrowserContext* browser_context, | ||
RulesCacheDelegate* cache_delegate) const override; | ||
scoped_ptr<DevicePermissionsPrompt> CreateDevicePermissionsPrompt( | ||
content::WebContents* web_contents) const override; | ||
scoped_ptr<VirtualKeyboardDelegate> CreateVirtualKeyboardDelegate() | ||
const override; | ||
ManagementAPIDelegate* CreateManagementAPIDelegate() const override; | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(ShellExtensionsAPIClient); | ||
}; | ||
|
||
} // namespace extensions | ||
|
||
#endif // CHROME_BROWSER_EXTENSIONS_API_CHROME_EXTENSIONS_API_CLIENT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2014 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 file. | ||
|
||
|
||
#include "content/nw/src/browser/shell_web_view_guest_delegate.h" | ||
|
||
#include "content/public/browser/child_process_security_policy.h" | ||
#include "content/public/browser/render_process_host.h" | ||
#include "extensions/browser/api/web_request/web_request_api.h" | ||
#include "extensions/browser/guest_view/web_view/web_view_constants.h" | ||
|
||
namespace extensions { | ||
|
||
ShellWebViewGuestDelegate::ShellWebViewGuestDelegate( | ||
WebViewGuest* web_view_guest) | ||
: web_view_guest_(web_view_guest), | ||
nw_disabled_(false), | ||
weak_ptr_factory_(this) { | ||
} | ||
|
||
ShellWebViewGuestDelegate::~ShellWebViewGuestDelegate() { | ||
} | ||
|
||
void ShellWebViewGuestDelegate::OnAttachWebViewHelpers( | ||
content::WebContents* contents) { | ||
} | ||
|
||
void ShellWebViewGuestDelegate::OnDidAttachToEmbedder() { | ||
web_view_guest_->attach_params()->GetBoolean("nwdisable", &nw_disabled_); | ||
if (nw_disabled_) | ||
return; | ||
content::RenderProcessHost* host = | ||
web_view_guest_->web_contents()->GetRenderProcessHost(); | ||
content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( | ||
host->GetID(), url::kFileScheme); | ||
} | ||
|
||
void ShellWebViewGuestDelegate::OnDidCommitProvisionalLoadForFrame( | ||
bool is_main_frame) { | ||
} | ||
|
||
void ShellWebViewGuestDelegate::OnDidInitialize() { | ||
} | ||
|
||
void ShellWebViewGuestDelegate::OnDocumentLoadedInFrame( | ||
content::RenderFrameHost* render_frame_host) { | ||
} | ||
|
||
void ShellWebViewGuestDelegate::OnEmbedderWillBeDestroyed() { | ||
} | ||
|
||
void ShellWebViewGuestDelegate::OnGuestDestroyed() { | ||
} | ||
|
||
} // namespace extensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2014 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 file. | ||
|
||
#ifndef NW_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_GUEST_DELEGATE_H_ | ||
#define NW_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_GUEST_DELEGATE_H_ | ||
|
||
#include "extensions/browser/guest_view/web_view/web_view_guest.h" | ||
#include "extensions/browser/guest_view/web_view/web_view_guest_delegate.h" | ||
|
||
|
||
namespace extensions { | ||
|
||
class ShellWebViewGuestDelegate : public WebViewGuestDelegate { | ||
public : | ||
explicit ShellWebViewGuestDelegate(WebViewGuest* web_view_guest); | ||
~ShellWebViewGuestDelegate() override; | ||
|
||
// WebViewGuestDelegate implementation. | ||
double GetZoom() override; | ||
bool HandleContextMenu(const content::ContextMenuParams& params) override; | ||
void OnAttachWebViewHelpers(content::WebContents* contents) override; | ||
void OnDidAttachToEmbedder() override; | ||
void OnDidCommitProvisionalLoadForFrame(bool is_main_frame) override; | ||
void OnDidInitialize() override; | ||
void OnDocumentLoadedInFrame( | ||
content::RenderFrameHost* render_frame_host) override; | ||
void OnEmbedderWillBeDestroyed() override; | ||
void OnGuestDestroyed() override; | ||
void OnSetZoom(double zoom_factor) override; | ||
void OnShowContextMenu(int request_id, const MenuItemVector* items) override; | ||
|
||
WebViewGuest* web_view_guest() const { return web_view_guest_; } | ||
|
||
private: | ||
content::WebContents* guest_web_contents() const { | ||
return web_view_guest()->web_contents(); | ||
} | ||
|
||
WebViewGuest* const web_view_guest_; | ||
|
||
bool nw_disabled_; | ||
// This is used to ensure pending tasks will not fire after this object is | ||
// destroyed. | ||
base::WeakPtrFactory<ShellWebViewGuestDelegate> weak_ptr_factory_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(ShellWebViewGuestDelegate); | ||
}; | ||
|
||
} // namespace extensions | ||
|
||
#endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_GUEST_DELEGATE_H_ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.