| 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/native_app_window.h" | 7 #include "apps/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" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/extensions/api/app_window.h" | 10 #include "chrome/common/extensions/api/app_window.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 creator_process_id) { | 53 creator_process_id) { |
| 54 SuspendRenderViewHost(web_contents_->GetRenderViewHost()); | 54 SuspendRenderViewHost(web_contents_->GetRenderViewHost()); |
| 55 } else { | 55 } else { |
| 56 VLOG(1) << "ShellWindow created in new process (" | 56 VLOG(1) << "ShellWindow created in new process (" |
| 57 << web_contents_->GetRenderViewHost()->GetProcess()->GetID() | 57 << web_contents_->GetRenderViewHost()->GetProcess()->GetID() |
| 58 << ") != creator (" << creator_process_id | 58 << ") != creator (" << creator_process_id |
| 59 << "). Routing disabled."; | 59 << "). Routing disabled."; |
| 60 } | 60 } |
| 61 | 61 |
| 62 // TODO(jeremya): there's a bug where navigating a web contents to an | 62 // TODO(jeremya): there's a bug where navigating a web contents to an |
| 63 // extension URL causes it to create a new RVH and discard the old | 63 // extension URL causes it to create a new RVH and discard the old (perfectly |
| 64 // (perfectly usable) one. To work around this, we watch for a RVH_CHANGED | 64 // usable) one. To work around this, we watch for a |
| 65 // message from the web contents (which will be sent during LoadURL) and | 65 // NOTIFICATION_RENDER_VIEW_HOST_CHANGED message from the web contents (which |
| 66 // suspend resource requests on the new RVH to ensure that we block the new | 66 // will be sent during LoadURL) and suspend resource requests on the new RVH |
| 67 // RVH from loading anything. It should be okay to remove the | 67 // to ensure that we block the new RVH from loading anything. It should be |
| 68 // NOTIFICATION_RVH_CHANGED registration once http://crbug.com/123007 is | 68 // okay to remove the NOTIFICATION_RENDER_VIEW_HOST_CHANGED registration once |
| 69 // fixed. | 69 // http://crbug.com/123007 is fixed. |
| 70 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 70 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 71 content::Source<content::NavigationController>( | 71 content::Source<content::WebContents>(web_contents())); |
| 72 &web_contents()->GetController())); | |
| 73 web_contents_->GetController().LoadURL( | 72 web_contents_->GetController().LoadURL( |
| 74 url_, content::Referrer(), content::PAGE_TRANSITION_LINK, | 73 url_, content::Referrer(), content::PAGE_TRANSITION_LINK, |
| 75 std::string()); | 74 std::string()); |
| 76 registrar_.RemoveAll(); | 75 registrar_.RemoveAll(); |
| 77 } | 76 } |
| 78 | 77 |
| 79 void AppWindowContents::NativeWindowChanged( | 78 void AppWindowContents::NativeWindowChanged( |
| 80 NativeAppWindow* native_app_window) { | 79 NativeAppWindow* native_app_window) { |
| 81 base::ListValue args; | 80 base::ListValue args; |
| 82 DictionaryValue* dictionary = new DictionaryValue(); | 81 DictionaryValue* dictionary = new DictionaryValue(); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 content::RenderViewHost* rvh) { | 167 content::RenderViewHost* rvh) { |
| 169 DCHECK(rvh); | 168 DCHECK(rvh); |
| 170 content::BrowserThread::PostTask( | 169 content::BrowserThread::PostTask( |
| 171 content::BrowserThread::IO, FROM_HERE, | 170 content::BrowserThread::IO, FROM_HERE, |
| 172 base::Bind(&content::ResourceDispatcherHost::BlockRequestsForRoute, | 171 base::Bind(&content::ResourceDispatcherHost::BlockRequestsForRoute, |
| 173 base::Unretained(content::ResourceDispatcherHost::Get()), | 172 base::Unretained(content::ResourceDispatcherHost::Get()), |
| 174 rvh->GetProcess()->GetID(), rvh->GetRoutingID())); | 173 rvh->GetProcess()->GetID(), rvh->GetRoutingID())); |
| 175 } | 174 } |
| 176 | 175 |
| 177 } // namespace apps | 176 } // namespace apps |
| OLD | NEW |