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

Side by Side Diff: chrome/browser/extensions/extension_host.cc

Issue 10412061: Fix crashes in DownloadRequestLimiter when extension popups/bubbles initiate downloads automatically (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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 | Annotate | Revision Log
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 "chrome/browser/extensions/extension_host.h" 5 #include "chrome/browser/extensions/extension_host.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "ui/base/keycodes/keyboard_codes.h" 51 #include "ui/base/keycodes/keyboard_codes.h"
52 #include "ui/base/l10n/l10n_util.h" 52 #include "ui/base/l10n/l10n_util.h"
53 #include "ui/base/resource/resource_bundle.h" 53 #include "ui/base/resource/resource_bundle.h"
54 54
55 #if defined(TOOLKIT_VIEWS) 55 #if defined(TOOLKIT_VIEWS)
56 #include "ui/views/widget/widget.h" 56 #include "ui/views/widget/widget.h"
57 #endif 57 #endif
58 58
59 using WebKit::WebDragOperation; 59 using WebKit::WebDragOperation;
60 using WebKit::WebDragOperationsMask; 60 using WebKit::WebDragOperationsMask;
61 using content::DownloadItem;
61 using content::NativeWebKeyboardEvent; 62 using content::NativeWebKeyboardEvent;
62 using content::OpenURLParams; 63 using content::OpenURLParams;
63 using content::RenderViewHost; 64 using content::RenderViewHost;
64 using content::SiteInstance; 65 using content::SiteInstance;
65 using content::WebContents; 66 using content::WebContents;
66 67
67 // Helper class that rate-limits the creation of renderer processes for 68 // Helper class that rate-limits the creation of renderer processes for
68 // ExtensionHosts, to avoid blocking the UI. 69 // ExtensionHosts, to avoid blocking the UI.
69 class ExtensionHost::ProcessCreationQueue { 70 class ExtensionHost::ProcessCreationQueue {
70 public: 71 public:
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 // TODO(mpcomplete): is this check really necessary? 403 // TODO(mpcomplete): is this check really necessary?
403 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || 404 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP ||
404 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG || 405 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG ||
405 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE || 406 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE ||
406 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR || 407 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR ||
407 extension_host_type_ == chrome::VIEW_TYPE_PANEL) { 408 extension_host_type_ == chrome::VIEW_TYPE_PANEL) {
408 Close(); 409 Close();
409 } 410 }
410 } 411 }
411 412
413 void ExtensionHost::OnStartDownload(
414 WebContents* source, DownloadItem* download) {
415 Profile* profile = Profile::FromBrowserContext(source->GetBrowserContext());
416 Browser* browser = browser::FindTabbedBrowser(
417 profile, false); // Match incognito exactly.
418 if (!browser && view())
419 browser = view()->browser();
420 if (browser)
421 // I don't know why Browser::OnStartDownload() is private when
422 // WebContentsDelegate::OnStartDownload() is public. Seems silly to me.
Avi (use Gerrit) 2012/05/23 20:53:28 Then fix it.
benjhayden 2012/05/24 20:43:39 Done.
423 static_cast<content::WebContentsDelegate*>(browser)->OnStartDownload(
424 source, download);
425 }
426
412 void ExtensionHost::WillRunJavaScriptDialog() { 427 void ExtensionHost::WillRunJavaScriptDialog() {
413 ExtensionProcessManager* pm = 428 ExtensionProcessManager* pm =
414 ExtensionSystem::Get(profile_)->process_manager(); 429 ExtensionSystem::Get(profile_)->process_manager();
415 if (pm) 430 if (pm)
416 pm->IncrementLazyKeepaliveCount(extension()); 431 pm->IncrementLazyKeepaliveCount(extension());
417 } 432 }
418 433
419 void ExtensionHost::DidCloseJavaScriptDialog() { 434 void ExtensionHost::DidCloseJavaScriptDialog() {
420 ExtensionProcessManager* pm = 435 ExtensionProcessManager* pm =
421 ExtensionSystem::Get(profile_)->process_manager(); 436 ExtensionSystem::Get(profile_)->process_manager();
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 params.user_gesture = user_gesture; 604 params.user_gesture = user_gesture;
590 browser::Navigate(&params); 605 browser::Navigate(&params);
591 } 606 }
592 607
593 void ExtensionHost::RenderViewReady() { 608 void ExtensionHost::RenderViewReady() {
594 content::NotificationService::current()->Notify( 609 content::NotificationService::current()->Notify(
595 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, 610 chrome::NOTIFICATION_EXTENSION_HOST_CREATED,
596 content::Source<Profile>(profile_), 611 content::Source<Profile>(profile_),
597 content::Details<ExtensionHost>(this)); 612 content::Details<ExtensionHost>(this));
598 } 613 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698