OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/guest_view/web_view/web_view_guest.h" | 5 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "components/browsing_data/storage_partition_http_cache_data_remover.h" | 10 #include "components/browsing_data/storage_partition_http_cache_data_remover.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 190 } |
191 | 191 |
192 using WebViewKey = std::pair<int, int>; | 192 using WebViewKey = std::pair<int, int>; |
193 using WebViewKeyToIDMap = std::map<WebViewKey, int>; | 193 using WebViewKeyToIDMap = std::map<WebViewKey, int>; |
194 static base::LazyInstance<WebViewKeyToIDMap> web_view_key_to_id_map = | 194 static base::LazyInstance<WebViewKeyToIDMap> web_view_key_to_id_map = |
195 LAZY_INSTANCE_INITIALIZER; | 195 LAZY_INSTANCE_INITIALIZER; |
196 | 196 |
197 } // namespace | 197 } // namespace |
198 | 198 |
199 // static | 199 // static |
200 void WebViewGuest::CleanUp(int embedder_process_id, int view_instance_id) { | 200 void WebViewGuest::CleanUp(content::BrowserContext* browser_context, |
201 GuestViewBase::CleanUp(embedder_process_id, view_instance_id); | 201 int embedder_process_id, |
202 | 202 int view_instance_id) { |
203 auto rph = content::RenderProcessHost::FromID(embedder_process_id); | 203 GuestViewBase::CleanUp(browser_context, embedder_process_id, |
204 // TODO(paulmeyer): It should be impossible for rph to be nullptr here, but | 204 view_instance_id); |
205 // this check is needed here for now as there seems to be occasional crashes | |
206 // because of this (http//crbug.com/499438). This should be removed once the | |
207 // cause is discovered and fixed. | |
208 DCHECK(rph != nullptr) | |
209 << "Cannot find RenderProcessHost for embedder process ID# " | |
210 << embedder_process_id; | |
211 if (rph == nullptr) | |
212 return; | |
213 auto browser_context = rph->GetBrowserContext(); | |
214 | 205 |
215 // Clean up rules registries for the WebView. | 206 // Clean up rules registries for the WebView. |
216 WebViewKey key(embedder_process_id, view_instance_id); | 207 WebViewKey key(embedder_process_id, view_instance_id); |
217 auto it = web_view_key_to_id_map.Get().find(key); | 208 auto it = web_view_key_to_id_map.Get().find(key); |
218 if (it != web_view_key_to_id_map.Get().end()) { | 209 if (it != web_view_key_to_id_map.Get().end()) { |
219 auto rules_registry_id = it->second; | 210 auto rules_registry_id = it->second; |
220 web_view_key_to_id_map.Get().erase(it); | 211 web_view_key_to_id_map.Get().erase(it); |
221 RulesRegistryService::Get(browser_context) | 212 RulesRegistryService* rrs = |
222 ->RemoveRulesRegistriesByID(rules_registry_id); | 213 RulesRegistryService::GetIfExists(browser_context); |
| 214 if (rrs) |
| 215 rrs->RemoveRulesRegistriesByID(rules_registry_id); |
223 } | 216 } |
224 | 217 |
225 // Clean up web request event listeners for the WebView. | 218 // Clean up web request event listeners for the WebView. |
226 content::BrowserThread::PostTask( | 219 content::BrowserThread::PostTask( |
227 content::BrowserThread::IO, | 220 content::BrowserThread::IO, |
228 FROM_HERE, | 221 FROM_HERE, |
229 base::Bind( | 222 base::Bind( |
230 &RemoveWebViewEventListenersOnIOThread, | 223 &RemoveWebViewEventListenersOnIOThread, |
231 browser_context, | 224 browser_context, |
232 embedder_process_id, | 225 embedder_process_id, |
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 1443 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
1451 DispatchEventToView( | 1444 DispatchEventToView( |
1452 new GuestViewEvent(webview::kEventExitFullscreen, args.Pass())); | 1445 new GuestViewEvent(webview::kEventExitFullscreen, args.Pass())); |
1453 } | 1446 } |
1454 // Since we changed fullscreen state, sending a Resize message ensures that | 1447 // Since we changed fullscreen state, sending a Resize message ensures that |
1455 // renderer/ sees the change. | 1448 // renderer/ sees the change. |
1456 web_contents()->GetRenderViewHost()->WasResized(); | 1449 web_contents()->GetRenderViewHost()->WasResized(); |
1457 } | 1450 } |
1458 | 1451 |
1459 } // namespace extensions | 1452 } // namespace extensions |
OLD | NEW |