| 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" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "content/public/browser/render_frame_host.h" | 12 #include "content/public/browser/render_frame_host.h" |
| 13 #include "content/public/browser/render_process_host.h" | 13 #include "content/public/browser/render_process_host.h" |
| 14 #include "content/public/browser/render_view_host.h" | 14 #include "content/public/browser/render_view_host.h" |
| 15 #include "content/public/browser/resource_dispatcher_host.h" | 15 #include "content/public/browser/resource_dispatcher_host.h" |
| 16 #include "content/public/browser/site_instance.h" | 16 #include "content/public/browser/site_instance.h" |
| 17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/browser/web_contents_source.h" |
| 18 #include "content/public/common/renderer_preferences.h" | 19 #include "content/public/common/renderer_preferences.h" |
| 19 #include "extensions/browser/app_window/native_app_window.h" | 20 #include "extensions/browser/app_window/native_app_window.h" |
| 20 #include "extensions/common/extension_messages.h" | 21 #include "extensions/common/extension_messages.h" |
| 21 | 22 |
| 22 namespace extensions { | 23 namespace extensions { |
| 23 | 24 |
| 24 AppWindowContentsImpl::AppWindowContentsImpl(AppWindow* host) | 25 AppWindowContentsImpl::AppWindowContentsImpl(AppWindow* host) |
| 25 : host_(host), is_blocking_requests_(false), is_window_ready_(false) {} | 26 : host_(host), is_blocking_requests_(false), is_window_ready_(false) {} |
| 26 | 27 |
| 27 AppWindowContentsImpl::~AppWindowContentsImpl() {} | 28 AppWindowContentsImpl::~AppWindowContentsImpl() {} |
| 28 | 29 |
| 29 void AppWindowContentsImpl::Initialize(content::BrowserContext* context, | 30 void AppWindowContentsImpl::Initialize(content::BrowserContext* context, |
| 30 const GURL& url) { | 31 const GURL& url) { |
| 31 url_ = url; | 32 url_ = url; |
| 32 | 33 |
| 33 web_contents_.reset( | 34 web_contents_.reset( |
| 34 content::WebContents::Create(content::WebContents::CreateParams( | 35 content::WebContents::Create(content::WebContents::CreateParams( |
| 35 context, content::SiteInstance::CreateForURL(context, url_)))); | 36 context, content::SiteInstance::CreateForURL(context, url_)))); |
| 37 WebContentsSource::CreateForWebContentsAndLocation(web_contents_.get(), |
| 38 FROM_HERE); |
| 36 | 39 |
| 37 Observe(web_contents_.get()); | 40 Observe(web_contents_.get()); |
| 38 web_contents_->GetMutableRendererPrefs()-> | 41 web_contents_->GetMutableRendererPrefs()-> |
| 39 browser_handles_all_top_level_requests = true; | 42 browser_handles_all_top_level_requests = true; |
| 40 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); | 43 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); |
| 41 } | 44 } |
| 42 | 45 |
| 43 void AppWindowContentsImpl::LoadContents(int32 creator_process_id) { | 46 void AppWindowContentsImpl::LoadContents(int32 creator_process_id) { |
| 44 // If the new view is in the same process as the creator, block the created | 47 // If the new view is in the same process as the creator, block the created |
| 45 // RVH from loading anything until the background page has had a chance to | 48 // RVH from loading anything until the background page has had a chance to |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // TODO(devlin): This will need to change for site isolation. | 143 // TODO(devlin): This will need to change for site isolation. |
| 141 content::BrowserThread::PostTask( | 144 content::BrowserThread::PostTask( |
| 142 content::BrowserThread::IO, FROM_HERE, | 145 content::BrowserThread::IO, FROM_HERE, |
| 143 base::Bind(&content::ResourceDispatcherHost::BlockRequestsForRoute, | 146 base::Bind(&content::ResourceDispatcherHost::BlockRequestsForRoute, |
| 144 base::Unretained(content::ResourceDispatcherHost::Get()), | 147 base::Unretained(content::ResourceDispatcherHost::Get()), |
| 145 rfh->GetProcess()->GetID(), | 148 rfh->GetProcess()->GetID(), |
| 146 rfh->GetRenderViewHost()->GetRoutingID())); | 149 rfh->GetRenderViewHost()->GetRoutingID())); |
| 147 } | 150 } |
| 148 | 151 |
| 149 } // namespace extensions | 152 } // namespace extensions |
| OLD | NEW |