OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/browser/app_window/app_window_contents.h" | 5 #include "extensions/browser/app_window/app_window_contents.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 namespace extensions { | 21 namespace extensions { |
22 | 22 |
23 AppWindowContentsImpl::AppWindowContentsImpl(AppWindow* host) : host_(host) {} | 23 AppWindowContentsImpl::AppWindowContentsImpl(AppWindow* host) : host_(host) {} |
24 | 24 |
25 AppWindowContentsImpl::~AppWindowContentsImpl() {} | 25 AppWindowContentsImpl::~AppWindowContentsImpl() {} |
26 | 26 |
27 void AppWindowContentsImpl::Initialize(content::BrowserContext* context, | 27 void AppWindowContentsImpl::Initialize(content::BrowserContext* context, |
28 const GURL& url) { | 28 const GURL& url) { |
29 url_ = url; | 29 url_ = url; |
30 | 30 |
31 extension_function_dispatcher_.reset( | |
32 new ExtensionFunctionDispatcher(context, this)); | |
33 | |
34 web_contents_.reset( | 31 web_contents_.reset( |
35 content::WebContents::Create(content::WebContents::CreateParams( | 32 content::WebContents::Create(content::WebContents::CreateParams( |
36 context, content::SiteInstance::CreateForURL(context, url_)))); | 33 context, content::SiteInstance::CreateForURL(context, url_)))); |
37 | 34 |
38 Observe(web_contents_.get()); | 35 Observe(web_contents_.get()); |
39 web_contents_->GetMutableRendererPrefs()-> | 36 web_contents_->GetMutableRendererPrefs()-> |
40 browser_handles_all_top_level_requests = true; | 37 browser_handles_all_top_level_requests = true; |
41 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); | 38 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); |
42 } | 39 } |
43 | 40 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 "app.window", | 86 "app.window", |
90 "appWindowShownForTests", | 87 "appWindowShownForTests", |
91 args, | 88 args, |
92 false)); | 89 false)); |
93 } | 90 } |
94 | 91 |
95 content::WebContents* AppWindowContentsImpl::GetWebContents() const { | 92 content::WebContents* AppWindowContentsImpl::GetWebContents() const { |
96 return web_contents_.get(); | 93 return web_contents_.get(); |
97 } | 94 } |
98 | 95 |
| 96 WindowController* AppWindowContentsImpl::GetWindowController() const { |
| 97 return nullptr; |
| 98 } |
| 99 |
99 bool AppWindowContentsImpl::OnMessageReceived(const IPC::Message& message) { | 100 bool AppWindowContentsImpl::OnMessageReceived(const IPC::Message& message) { |
100 bool handled = true; | 101 bool handled = true; |
101 IPC_BEGIN_MESSAGE_MAP(AppWindowContentsImpl, message) | 102 IPC_BEGIN_MESSAGE_MAP(AppWindowContentsImpl, message) |
102 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) | |
103 IPC_MESSAGE_HANDLER(ExtensionHostMsg_UpdateDraggableRegions, | 103 IPC_MESSAGE_HANDLER(ExtensionHostMsg_UpdateDraggableRegions, |
104 UpdateDraggableRegions) | 104 UpdateDraggableRegions) |
105 IPC_MESSAGE_UNHANDLED(handled = false) | 105 IPC_MESSAGE_UNHANDLED(handled = false) |
106 IPC_END_MESSAGE_MAP() | 106 IPC_END_MESSAGE_MAP() |
107 return handled; | 107 return handled; |
108 } | 108 } |
109 | 109 |
110 WindowController* AppWindowContentsImpl::GetExtensionWindowController() const { | |
111 return NULL; | |
112 } | |
113 | |
114 content::WebContents* AppWindowContentsImpl::GetAssociatedWebContents() const { | |
115 return web_contents_.get(); | |
116 } | |
117 | |
118 void AppWindowContentsImpl::OnRequest( | |
119 const ExtensionHostMsg_Request_Params& params) { | |
120 extension_function_dispatcher_->Dispatch( | |
121 params, web_contents_->GetRenderViewHost()); | |
122 } | |
123 | |
124 void AppWindowContentsImpl::UpdateDraggableRegions( | 110 void AppWindowContentsImpl::UpdateDraggableRegions( |
125 const std::vector<DraggableRegion>& regions) { | 111 const std::vector<DraggableRegion>& regions) { |
126 host_->UpdateDraggableRegions(regions); | 112 host_->UpdateDraggableRegions(regions); |
127 } | 113 } |
128 | 114 |
129 void AppWindowContentsImpl::SuspendRenderViewHost( | 115 void AppWindowContentsImpl::SuspendRenderViewHost( |
130 content::RenderViewHost* rvh) { | 116 content::RenderViewHost* rvh) { |
131 DCHECK(rvh); | 117 DCHECK(rvh); |
132 content::BrowserThread::PostTask( | 118 content::BrowserThread::PostTask( |
133 content::BrowserThread::IO, FROM_HERE, | 119 content::BrowserThread::IO, FROM_HERE, |
134 base::Bind(&content::ResourceDispatcherHost::BlockRequestsForRoute, | 120 base::Bind(&content::ResourceDispatcherHost::BlockRequestsForRoute, |
135 base::Unretained(content::ResourceDispatcherHost::Get()), | 121 base::Unretained(content::ResourceDispatcherHost::Get()), |
136 rvh->GetProcess()->GetID(), rvh->GetRoutingID())); | 122 rvh->GetProcess()->GetID(), rvh->GetRoutingID())); |
137 } | 123 } |
138 | 124 |
139 } // namespace extensions | 125 } // namespace extensions |
OLD | NEW |