Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 #include "ui/base/l10n/l10n_util.h" | 52 #include "ui/base/l10n/l10n_util.h" |
| 53 #include "ui/base/layout.h" | 53 #include "ui/base/layout.h" |
| 54 #include "ui/base/resource/resource_bundle.h" | 54 #include "ui/base/resource/resource_bundle.h" |
| 55 | 55 |
| 56 #if defined(TOOLKIT_VIEWS) | 56 #if defined(TOOLKIT_VIEWS) |
| 57 #include "ui/views/widget/widget.h" | 57 #include "ui/views/widget/widget.h" |
| 58 #endif | 58 #endif |
| 59 | 59 |
| 60 using WebKit::WebDragOperation; | 60 using WebKit::WebDragOperation; |
| 61 using WebKit::WebDragOperationsMask; | 61 using WebKit::WebDragOperationsMask; |
| 62 using content::DownloadItem; | |
| 62 using content::NativeWebKeyboardEvent; | 63 using content::NativeWebKeyboardEvent; |
| 63 using content::OpenURLParams; | 64 using content::OpenURLParams; |
| 64 using content::RenderViewHost; | 65 using content::RenderViewHost; |
| 65 using content::SiteInstance; | 66 using content::SiteInstance; |
| 66 using content::WebContents; | 67 using content::WebContents; |
| 67 | 68 |
| 68 // Helper class that rate-limits the creation of renderer processes for | 69 // Helper class that rate-limits the creation of renderer processes for |
| 69 // ExtensionHosts, to avoid blocking the UI. | 70 // ExtensionHosts, to avoid blocking the UI. |
| 70 class ExtensionHost::ProcessCreationQueue { | 71 class ExtensionHost::ProcessCreationQueue { |
| 71 public: | 72 public: |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 403 // TODO(mpcomplete): is this check really necessary? | 404 // TODO(mpcomplete): is this check really necessary? |
| 404 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || | 405 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || |
| 405 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG || | 406 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG || |
| 406 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE || | 407 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE || |
| 407 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR || | 408 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR || |
| 408 extension_host_type_ == chrome::VIEW_TYPE_PANEL) { | 409 extension_host_type_ == chrome::VIEW_TYPE_PANEL) { |
| 409 Close(); | 410 Close(); |
| 410 } | 411 } |
| 411 } | 412 } |
| 412 | 413 |
| 414 void ExtensionHost::OnStartDownload( | |
| 415 WebContents* source, DownloadItem* download) { | |
| 416 Profile* profile = Profile::FromBrowserContext(source->GetBrowserContext()); | |
| 417 Browser* browser = browser::FindTabbedBrowser( | |
| 418 profile, false); // Match incognito exactly. | |
|
Ben Goodger (Google)
2012/05/29 18:23:48
So, this pattern is effectively equivalent to Brow
| |
| 419 if (!browser && view()) | |
| 420 browser = view()->browser(); | |
| 421 if (browser) | |
| 422 browser->OnStartDownload(source, download); | |
| 423 } | |
| 424 | |
| 413 void ExtensionHost::WillRunJavaScriptDialog() { | 425 void ExtensionHost::WillRunJavaScriptDialog() { |
| 414 ExtensionProcessManager* pm = | 426 ExtensionProcessManager* pm = |
| 415 ExtensionSystem::Get(profile_)->process_manager(); | 427 ExtensionSystem::Get(profile_)->process_manager(); |
| 416 if (pm) | 428 if (pm) |
| 417 pm->IncrementLazyKeepaliveCount(extension()); | 429 pm->IncrementLazyKeepaliveCount(extension()); |
| 418 } | 430 } |
| 419 | 431 |
| 420 void ExtensionHost::DidCloseJavaScriptDialog() { | 432 void ExtensionHost::DidCloseJavaScriptDialog() { |
| 421 ExtensionProcessManager* pm = | 433 ExtensionProcessManager* pm = |
| 422 ExtensionSystem::Get(profile_)->process_manager(); | 434 ExtensionSystem::Get(profile_)->process_manager(); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 590 params.user_gesture = user_gesture; | 602 params.user_gesture = user_gesture; |
| 591 browser::Navigate(¶ms); | 603 browser::Navigate(¶ms); |
| 592 } | 604 } |
| 593 | 605 |
| 594 void ExtensionHost::RenderViewReady() { | 606 void ExtensionHost::RenderViewReady() { |
| 595 content::NotificationService::current()->Notify( | 607 content::NotificationService::current()->Notify( |
| 596 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 608 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
| 597 content::Source<Profile>(profile_), | 609 content::Source<Profile>(profile_), |
| 598 content::Details<ExtensionHost>(this)); | 610 content::Details<ExtensionHost>(this)); |
| 599 } | 611 } |
| OLD | NEW |