forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app_shell: Add ShellContentRendererClient
This is a step toward getting app_shell to initialize a renderer with extension support. * Add apps/shell/renderer so we can separate out the render process code * Do a little bit of cleanup in the Permissions system, which is the next thing to tackle. BUG=335632 TEST=none Review URL: https://codereview.chromium.org/149163002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248548 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
jamescook@chromium.org
committed
Feb 3, 2014
1 parent
019bfaf
commit 71470b9
Showing
13 changed files
with
207 additions
and
48 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
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,12 @@ | ||
include_rules = [ | ||
# Only allow includes the renderer can use. | ||
"-content/public/browser", | ||
"+content/public/common", | ||
"+content/public/renderer", | ||
"+content/public/test", | ||
|
||
# TODO(jamescook): Remove these. http://crbug.com/305404 | ||
# Chrome pieces for bring-up. | ||
"+chrome/renderer/extensions/dispatcher.h", | ||
"+chrome/renderer/extensions/extension_helper.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// 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 "apps/shell/renderer/shell_content_renderer_client.h" | ||
|
||
#include "apps/shell/shell_extensions_client.h" | ||
#include "chrome/renderer/extensions/dispatcher.h" | ||
#include "chrome/renderer/extensions/extension_helper.h" | ||
#include "content/public/renderer/render_thread.h" | ||
#include "extensions/common/extensions_client.h" | ||
|
||
using blink::WebFrame; | ||
using blink::WebString; | ||
using content::RenderThread; | ||
|
||
namespace apps { | ||
|
||
ShellContentRendererClient::ShellContentRendererClient() {} | ||
|
||
ShellContentRendererClient::~ShellContentRendererClient() {} | ||
|
||
void ShellContentRendererClient::RenderThreadStarted() { | ||
RenderThread* thread = RenderThread::Get(); | ||
|
||
extension_dispatcher_.reset(new extensions::Dispatcher()); | ||
thread->AddObserver(extension_dispatcher_.get()); | ||
|
||
// TODO(jamescook): Init WebSecurityPolicy for chrome-extension: schemes. | ||
// See ChromeContentRendererClient for details. | ||
|
||
extensions_client_.reset(new ShellExtensionsClient); | ||
extensions::ExtensionsClient::Set(extensions_client_.get()); | ||
} | ||
|
||
void ShellContentRendererClient::RenderFrameCreated( | ||
content::RenderFrame* render_frame) { | ||
// TODO(jamescook): Create ExtensionFrameHelper? This might be needed for | ||
// Pepper plugins like Flash. | ||
} | ||
|
||
void ShellContentRendererClient::RenderViewCreated( | ||
content::RenderView* render_view) { | ||
new extensions::ExtensionHelper(render_view, extension_dispatcher_.get()); | ||
} | ||
|
||
bool ShellContentRendererClient::WillSendRequest( | ||
blink::WebFrame* frame, | ||
content::PageTransition transition_type, | ||
const GURL& url, | ||
const GURL& first_party_for_cookies, | ||
GURL* new_url) { | ||
// TODO(jamescook): Cause an error for bad extension scheme requests? | ||
return false; | ||
} | ||
|
||
void ShellContentRendererClient::DidCreateScriptContext( | ||
WebFrame* frame, v8::Handle<v8::Context> context, int extension_group, | ||
int world_id) { | ||
extension_dispatcher_->DidCreateScriptContext( | ||
frame, context, extension_group, world_id); | ||
} | ||
|
||
void ShellContentRendererClient::WillReleaseScriptContext( | ||
WebFrame* frame, v8::Handle<v8::Context> context, int world_id) { | ||
extension_dispatcher_->WillReleaseScriptContext(frame, context, world_id); | ||
} | ||
|
||
bool ShellContentRendererClient::ShouldEnableSiteIsolationPolicy() const { | ||
// Extension renderers don't need site isolation. | ||
return false; | ||
} | ||
|
||
} // namespace apps |
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,54 @@ | ||
// 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 APPS_SHELL_RENDERER_SHELL_CONTENT_RENDERER_CLIENT_H_ | ||
#define APPS_SHELL_RENDERER_SHELL_CONTENT_RENDERER_CLIENT_H_ | ||
|
||
#include "base/compiler_specific.h" | ||
#include "base/macros.h" | ||
#include "base/memory/scoped_ptr.h" | ||
#include "content/public/renderer/content_renderer_client.h" | ||
|
||
namespace extensions { | ||
class Dispatcher; | ||
} | ||
|
||
namespace apps { | ||
|
||
class ShellExtensionsClient; | ||
|
||
// Renderer initialization and runtime support for app_shell. | ||
class ShellContentRendererClient : public content::ContentRendererClient { | ||
public: | ||
ShellContentRendererClient(); | ||
virtual ~ShellContentRendererClient(); | ||
|
||
// content::ContentRendererClient implementation: | ||
virtual void RenderThreadStarted() OVERRIDE; | ||
virtual void RenderFrameCreated(content::RenderFrame* render_frame) OVERRIDE; | ||
virtual void RenderViewCreated(content::RenderView* render_view) OVERRIDE; | ||
virtual bool WillSendRequest(blink::WebFrame* frame, | ||
content::PageTransition transition_type, | ||
const GURL& url, | ||
const GURL& first_party_for_cookies, | ||
GURL* new_url) OVERRIDE; | ||
virtual void DidCreateScriptContext(blink::WebFrame* frame, | ||
v8::Handle<v8::Context> context, | ||
int extension_group, | ||
int world_id) OVERRIDE; | ||
virtual void WillReleaseScriptContext(blink::WebFrame* frame, | ||
v8::Handle<v8::Context> context, | ||
int world_id) OVERRIDE; | ||
virtual bool ShouldEnableSiteIsolationPolicy() const OVERRIDE; | ||
|
||
private: | ||
scoped_ptr<ShellExtensionsClient> extensions_client_; | ||
scoped_ptr<extensions::Dispatcher> extension_dispatcher_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(ShellContentRendererClient); | ||
}; | ||
|
||
} // namespace apps | ||
|
||
#endif // APPS_SHELL_RENDERER_SHELL_CONTENT_RENDERER_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
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
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.