| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 browser->OnStartDownload(source, download); |
| 422 } |
| 423 |
| 412 void ExtensionHost::WillRunJavaScriptDialog() { | 424 void ExtensionHost::WillRunJavaScriptDialog() { |
| 413 ExtensionProcessManager* pm = | 425 ExtensionProcessManager* pm = |
| 414 ExtensionSystem::Get(profile_)->process_manager(); | 426 ExtensionSystem::Get(profile_)->process_manager(); |
| 415 if (pm) | 427 if (pm) |
| 416 pm->IncrementLazyKeepaliveCount(extension()); | 428 pm->IncrementLazyKeepaliveCount(extension()); |
| 417 } | 429 } |
| 418 | 430 |
| 419 void ExtensionHost::DidCloseJavaScriptDialog() { | 431 void ExtensionHost::DidCloseJavaScriptDialog() { |
| 420 ExtensionProcessManager* pm = | 432 ExtensionProcessManager* pm = |
| 421 ExtensionSystem::Get(profile_)->process_manager(); | 433 ExtensionSystem::Get(profile_)->process_manager(); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 params.user_gesture = user_gesture; | 601 params.user_gesture = user_gesture; |
| 590 browser::Navigate(¶ms); | 602 browser::Navigate(¶ms); |
| 591 } | 603 } |
| 592 | 604 |
| 593 void ExtensionHost::RenderViewReady() { | 605 void ExtensionHost::RenderViewReady() { |
| 594 content::NotificationService::current()->Notify( | 606 content::NotificationService::current()->Notify( |
| 595 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 607 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
| 596 content::Source<Profile>(profile_), | 608 content::Source<Profile>(profile_), |
| 597 content::Details<ExtensionHost>(this)); | 609 content::Details<ExtensionHost>(this)); |
| 598 } | 610 } |
| OLD | NEW |