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_WEB_CONTENTS_SWAPPED message from the web contents (which will |
66 // suspend resource requests on the new RVH to ensure that we block the new | 66 // be sent during LoadURL) and suspend resource requests on the new RVH to |
67 // RVH from loading anything. It should be okay to remove the | 67 // ensure that we block the new RVH from loading anything. It should be okay |
68 // NOTIFICATION_RVH_CHANGED registration once http://crbug.com/123007 is | 68 // to remove the NOTIFICATION_WEB_CONTENTS_SWAPPED 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_WEB_CONTENTS_SWAPPED, |
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 27 matching lines...) Expand all Loading... |
110 | 109 |
111 content::WebContents* AppWindowContents::GetWebContents() const { | 110 content::WebContents* AppWindowContents::GetWebContents() const { |
112 return web_contents_.get(); | 111 return web_contents_.get(); |
113 } | 112 } |
114 | 113 |
115 void AppWindowContents::Observe( | 114 void AppWindowContents::Observe( |
116 int type, | 115 int type, |
117 const content::NotificationSource& source, | 116 const content::NotificationSource& source, |
118 const content::NotificationDetails& details) { | 117 const content::NotificationDetails& details) { |
119 switch (type) { | 118 switch (type) { |
120 case content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED: { | 119 case content::NOTIFICATION_WEB_CONTENTS_SWAPPED: { |
121 // TODO(jeremya): once http://crbug.com/123007 is fixed, we'll no longer | 120 // TODO(jeremya): once http://crbug.com/123007 is fixed, we'll no longer |
122 // need to suspend resource requests here (the call in the constructor | 121 // need to suspend resource requests here (the call in the constructor |
123 // should be enough). | 122 // should be enough). |
124 content::Details<std::pair<content::RenderViewHost*, | 123 content::Details<std::pair<content::RenderViewHost*, |
125 content::RenderViewHost*> > | 124 content::RenderViewHost*> > |
126 host_details(details); | 125 host_details(details); |
127 if (host_details->first) | 126 if (host_details->first) |
128 SuspendRenderViewHost(host_details->second); | 127 SuspendRenderViewHost(host_details->second); |
129 break; | 128 break; |
130 } | 129 } |
(...skipping 37 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 |