| 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 "apps/app_window_contents.h" | 5 #include "apps/app_window_contents.h" |
| 6 | 6 |
| 7 #include "apps/ui/native_app_window.h" | 7 #include "apps/ui/native_app_window.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/profiles/profile.h" | |
| 10 #include "chrome/common/extensions/api/app_window.h" | 9 #include "chrome/common/extensions/api/app_window.h" |
| 11 #include "chrome/common/extensions/extension_messages.h" | 10 #include "chrome/common/extensions/extension_messages.h" |
| 11 #include "content/public/browser/browser_context.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.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/common/renderer_preferences.h" | 18 #include "content/public/common/renderer_preferences.h" |
| 19 | 19 |
| 20 namespace app_window = extensions::api::app_window; | 20 namespace app_window = extensions::api::app_window; |
| 21 | 21 |
| 22 namespace apps { | 22 namespace apps { |
| 23 | 23 |
| 24 AppWindowContents::AppWindowContents(ShellWindow* host) | 24 AppWindowContents::AppWindowContents(ShellWindow* host) |
| 25 : host_(host) { | 25 : host_(host) { |
| 26 } | 26 } |
| 27 | 27 |
| 28 AppWindowContents::~AppWindowContents() { | 28 AppWindowContents::~AppWindowContents() { |
| 29 } | 29 } |
| 30 | 30 |
| 31 void AppWindowContents::Initialize(Profile* profile, const GURL& url) { | 31 void AppWindowContents::Initialize(content::BrowserContext* context, |
| 32 const GURL& url) { |
| 32 url_ = url; | 33 url_ = url; |
| 33 | 34 |
| 34 extension_function_dispatcher_.reset( | 35 extension_function_dispatcher_.reset( |
| 35 new ExtensionFunctionDispatcher(profile, this)); | 36 new ExtensionFunctionDispatcher(context, this)); |
| 36 | 37 |
| 37 web_contents_.reset(content::WebContents::Create( | 38 web_contents_.reset( |
| 38 content::WebContents::CreateParams( | 39 content::WebContents::Create(content::WebContents::CreateParams( |
| 39 profile, content::SiteInstance::CreateForURL(profile, url_)))); | 40 context, content::SiteInstance::CreateForURL(context, url_)))); |
| 40 | 41 |
| 41 content::WebContentsObserver::Observe(web_contents_.get()); | 42 content::WebContentsObserver::Observe(web_contents_.get()); |
| 42 web_contents_->GetMutableRendererPrefs()-> | 43 web_contents_->GetMutableRendererPrefs()-> |
| 43 browser_handles_all_top_level_requests = true; | 44 browser_handles_all_top_level_requests = true; |
| 44 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); | 45 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); |
| 45 } | 46 } |
| 46 | 47 |
| 47 void AppWindowContents::LoadContents(int32 creator_process_id) { | 48 void AppWindowContents::LoadContents(int32 creator_process_id) { |
| 48 // If the new view is in the same process as the creator, block the created | 49 // If the new view is in the same process as the creator, block the created |
| 49 // RVH from loading anything until the background page has had a chance to | 50 // RVH from loading anything until the background page has had a chance to |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 content::RenderViewHost* rvh) { | 157 content::RenderViewHost* rvh) { |
| 157 DCHECK(rvh); | 158 DCHECK(rvh); |
| 158 content::BrowserThread::PostTask( | 159 content::BrowserThread::PostTask( |
| 159 content::BrowserThread::IO, FROM_HERE, | 160 content::BrowserThread::IO, FROM_HERE, |
| 160 base::Bind(&content::ResourceDispatcherHost::BlockRequestsForRoute, | 161 base::Bind(&content::ResourceDispatcherHost::BlockRequestsForRoute, |
| 161 base::Unretained(content::ResourceDispatcherHost::Get()), | 162 base::Unretained(content::ResourceDispatcherHost::Get()), |
| 162 rvh->GetProcess()->GetID(), rvh->GetRoutingID())); | 163 rvh->GetProcess()->GetID(), rvh->GetRoutingID())); |
| 163 } | 164 } |
| 164 | 165 |
| 165 } // namespace apps | 166 } // namespace apps |
| OLD | NEW |