Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 23514016: <webview>: Cleanup WebRequest event listeners when embedder destroyed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed WebRequest unit test Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/browser_plugin/browser_plugin_guest.h" 5 #include "content/browser/browser_plugin/browser_plugin_guest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 guest->embedder_web_contents()->GetRenderViewHost()), 312 guest->embedder_web_contents()->GetRenderViewHost()),
313 browser_plugin_guest_(guest) { 313 browser_plugin_guest_(guest) {
314 } 314 }
315 315
316 virtual ~EmbedderRenderViewHostObserver() { 316 virtual ~EmbedderRenderViewHostObserver() {
317 } 317 }
318 318
319 // RenderViewHostObserver: 319 // RenderViewHostObserver:
320 virtual void RenderViewHostDestroyed( 320 virtual void RenderViewHostDestroyed(
321 RenderViewHost* render_view_host) OVERRIDE { 321 RenderViewHost* render_view_host) OVERRIDE {
322 browser_plugin_guest_->embedder_web_contents_ = NULL; 322 browser_plugin_guest_->EmbedderDestroyed();
323 browser_plugin_guest_->Destroy();
324 } 323 }
325 324
326 private: 325 private:
327 BrowserPluginGuest* browser_plugin_guest_; 326 BrowserPluginGuest* browser_plugin_guest_;
328 327
329 DISALLOW_COPY_AND_ASSIGN(EmbedderRenderViewHostObserver); 328 DISALLOW_COPY_AND_ASSIGN(EmbedderRenderViewHostObserver);
330 }; 329 };
331 330
332 BrowserPluginGuest::BrowserPluginGuest( 331 BrowserPluginGuest::BrowserPluginGuest(
333 int instance_id, 332 int instance_id,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 AsWeakPtr(), 416 AsWeakPtr(),
418 request_id); 417 request_id);
419 // If BrowserPluginGuestDelegate hasn't handled the permission then we simply 418 // If BrowserPluginGuestDelegate hasn't handled the permission then we simply
420 // reject it immediately. 419 // reject it immediately.
421 if (!delegate_->RequestPermission(permission_type, request_info, callback)) 420 if (!delegate_->RequestPermission(permission_type, request_info, callback))
422 callback.Run(false, ""); 421 callback.Run(false, "");
423 422
424 return request_id; 423 return request_id;
425 } 424 }
426 425
426 void BrowserPluginGuest::EmbedderDestroyed() {
427 embedder_web_contents_ = NULL;
428 if (delegate_)
429 delegate_->EmbedderDestroyed();
430 Destroy();
431 }
432
427 void BrowserPluginGuest::Destroy() { 433 void BrowserPluginGuest::Destroy() {
428 is_in_destruction_ = true; 434 is_in_destruction_ = true;
429 if (!attached() && opener()) 435 if (!attached() && opener())
430 opener()->pending_new_windows_.erase(this); 436 opener()->pending_new_windows_.erase(this);
431 DestroyUnattachedWindows(); 437 DestroyUnattachedWindows();
432 GetWebContents()->GetBrowserPluginGuestManager()->RemoveGuest(instance_id_); 438 GetWebContents()->GetBrowserPluginGuestManager()->RemoveGuest(instance_id_);
433 delete GetWebContents(); 439 delete GetWebContents();
434 } 440 }
435 441
436 bool BrowserPluginGuest::OnMessageReceivedFromEmbedder( 442 bool BrowserPluginGuest::OnMessageReceivedFromEmbedder(
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 request_info.Set(browser_plugin::kRequestMethod, 1693 request_info.Set(browser_plugin::kRequestMethod,
1688 base::Value::CreateStringValue(request_method)); 1694 base::Value::CreateStringValue(request_method));
1689 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); 1695 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url));
1690 1696
1691 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD, 1697 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD,
1692 new DownloadRequest(callback), 1698 new DownloadRequest(callback),
1693 request_info); 1699 request_info);
1694 } 1700 }
1695 1701
1696 } // namespace content 1702 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.h ('k') | content/public/browser/browser_plugin_guest_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698