Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: apps/shell/renderer/shell_content_renderer_client.cc

Issue 412713002: Move apps/shell to extensions/shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 40% Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "apps/shell/renderer/shell_content_renderer_client.h"
6
7 #include "apps/shell/common/shell_extensions_client.h"
8 #include "apps/shell/renderer/shell_dispatcher_delegate.h"
9 #include "apps/shell/renderer/shell_extensions_renderer_client.h"
10 #include "apps/shell/renderer/shell_renderer_main_delegate.h"
11 #include "content/public/renderer/render_frame.h"
12 #include "content/public/renderer/render_frame_observer.h"
13 #include "content/public/renderer/render_frame_observer_tracker.h"
14 #include "content/public/renderer/render_thread.h"
15 #include "extensions/common/extensions_client.h"
16 #include "extensions/renderer/dispatcher.h"
17 #include "extensions/renderer/extension_helper.h"
18
19 using blink::WebFrame;
20 using blink::WebString;
21 using content::RenderThread;
22
23 namespace apps {
24
25 namespace {
26
27 // TODO: promote ExtensionFrameHelper to a common place and share with this.
28 class ShellFrameHelper
29 : public content::RenderFrameObserver,
30 public content::RenderFrameObserverTracker<ShellFrameHelper> {
31 public:
32 ShellFrameHelper(content::RenderFrame* render_frame,
33 extensions::Dispatcher* extension_dispatcher);
34 virtual ~ShellFrameHelper();
35
36 // RenderFrameObserver implementation.
37 virtual void WillReleaseScriptContext(v8::Handle<v8::Context>,
38 int world_id) OVERRIDE;
39
40 private:
41 extensions::Dispatcher* extension_dispatcher_;
42
43 DISALLOW_COPY_AND_ASSIGN(ShellFrameHelper);
44 };
45
46 ShellFrameHelper::ShellFrameHelper(content::RenderFrame* render_frame,
47 extensions::Dispatcher* extension_dispatcher)
48 : content::RenderFrameObserver(render_frame),
49 content::RenderFrameObserverTracker<ShellFrameHelper>(render_frame),
50 extension_dispatcher_(extension_dispatcher) {}
51
52 ShellFrameHelper::~ShellFrameHelper() {}
53
54 void ShellFrameHelper::WillReleaseScriptContext(v8::Handle<v8::Context> context,
55 int world_id) {
56 extension_dispatcher_->WillReleaseScriptContext(
57 render_frame()->GetWebFrame(), context, world_id);
58 }
59
60 } // namespace
61
62 ShellContentRendererClient::ShellContentRendererClient(
63 scoped_ptr<ShellRendererMainDelegate> delegate)
64 : delegate_(delegate.Pass()) {
65 }
66
67 ShellContentRendererClient::~ShellContentRendererClient() {}
68
69 void ShellContentRendererClient::RenderThreadStarted() {
70 RenderThread* thread = RenderThread::Get();
71
72 extensions_client_.reset(new ShellExtensionsClient);
73 extensions::ExtensionsClient::Set(extensions_client_.get());
74
75 extensions_renderer_client_.reset(new ShellExtensionsRendererClient);
76 extensions::ExtensionsRendererClient::Set(extensions_renderer_client_.get());
77
78 extension_dispatcher_delegate_.reset(new ShellDispatcherDelegate());
79
80 // Must be initialized after ExtensionsRendererClient.
81 extension_dispatcher_.reset(
82 new extensions::Dispatcher(extension_dispatcher_delegate_.get()));
83 thread->AddObserver(extension_dispatcher_.get());
84
85 // TODO(jamescook): Init WebSecurityPolicy for chrome-extension: schemes.
86 // See ChromeContentRendererClient for details.
87 if (delegate_)
88 delegate_->OnThreadStarted(thread);
89 }
90
91 void ShellContentRendererClient::RenderFrameCreated(
92 content::RenderFrame* render_frame) {
93 // ShellFrameHelper destroyes itself when the RenderFrame is destroyed.
94 new ShellFrameHelper(render_frame, extension_dispatcher_.get());
95 }
96
97 void ShellContentRendererClient::RenderViewCreated(
98 content::RenderView* render_view) {
99 new extensions::ExtensionHelper(render_view, extension_dispatcher_.get());
100 if (delegate_)
101 delegate_->OnViewCreated(render_view);
102 }
103
104 bool ShellContentRendererClient::WillSendRequest(
105 blink::WebFrame* frame,
106 content::PageTransition transition_type,
107 const GURL& url,
108 const GURL& first_party_for_cookies,
109 GURL* new_url) {
110 // TODO(jamescook): Cause an error for bad extension scheme requests?
111 return false;
112 }
113
114 void ShellContentRendererClient::DidCreateScriptContext(
115 WebFrame* frame, v8::Handle<v8::Context> context, int extension_group,
116 int world_id) {
117 extension_dispatcher_->DidCreateScriptContext(
118 frame, context, extension_group, world_id);
119 }
120
121 bool ShellContentRendererClient::ShouldEnableSiteIsolationPolicy() const {
122 // Extension renderers don't need site isolation.
123 return false;
124 }
125
126 } // namespace apps
OLDNEW
« no previous file with comments | « apps/shell/renderer/shell_content_renderer_client.h ('k') | apps/shell/renderer/shell_custom_bindings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698