| 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 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 dialog_creator_.reset(CreateJavaScriptDialogCreatorInstance(this)); | 584 dialog_creator_.reset(CreateJavaScriptDialogCreatorInstance(this)); |
| 585 } | 585 } |
| 586 return dialog_creator_.get(); | 586 return dialog_creator_.get(); |
| 587 } | 587 } |
| 588 | 588 |
| 589 void ExtensionHost::RunFileChooser(WebContents* tab, | 589 void ExtensionHost::RunFileChooser(WebContents* tab, |
| 590 const content::FileChooserParams& params) { | 590 const content::FileChooserParams& params) { |
| 591 FileSelectHelper::RunFileChooser(tab, params); | 591 FileSelectHelper::RunFileChooser(tab, params); |
| 592 } | 592 } |
| 593 | 593 |
| 594 void ExtensionHost::AddNewContents(WebContents* source, | 594 bool ExtensionHost::AddNewContents(WebContents* source, |
| 595 WebContents* new_contents, | 595 WebContents* new_contents, |
| 596 WindowOpenDisposition disposition, | 596 WindowOpenDisposition disposition, |
| 597 const gfx::Rect& initial_pos, | 597 const gfx::Rect& initial_pos, |
| 598 bool user_gesture) { | 598 bool user_gesture) { |
| 599 // First, if the creating extension view was associated with a tab contents, | 599 // First, if the creating extension view was associated with a tab contents, |
| 600 // use that tab content's delegate. We must be careful here that the | 600 // use that tab content's delegate. We must be careful here that the |
| 601 // associated tab contents has the same profile as the new tab contents. In | 601 // associated tab contents has the same profile as the new tab contents. In |
| 602 // the case of extensions in 'spanning' incognito mode, they can mismatch. | 602 // the case of extensions in 'spanning' incognito mode, they can mismatch. |
| 603 // We don't want to end up putting a normal tab into an incognito window, or | 603 // We don't want to end up putting a normal tab into an incognito window, or |
| 604 // vice versa. | 604 // vice versa. |
| 605 // Note that we don't do this for popup windows, because we need to associate | 605 // Note that we don't do this for popup windows, because we need to associate |
| 606 // those with their extension_app_id. | 606 // those with their extension_app_id. |
| 607 if (disposition != NEW_POPUP) { | 607 if (disposition != NEW_POPUP) { |
| 608 WebContents* associated_contents = GetAssociatedWebContents(); | 608 WebContents* associated_contents = GetAssociatedWebContents(); |
| 609 if (associated_contents && | 609 if (associated_contents && |
| 610 associated_contents->GetBrowserContext() == | 610 associated_contents->GetBrowserContext() == |
| 611 new_contents->GetBrowserContext()) { | 611 new_contents->GetBrowserContext()) { |
| 612 associated_contents->AddNewContents( | 612 WebContentsDelegate* delegate = associated_contents->GetDelegate(); |
| 613 new_contents, disposition, initial_pos, user_gesture); | 613 return delegate && delegate->AddNewContents( |
| 614 return; | 614 associated_contents, new_contents, disposition, initial_pos, |
| 615 user_gesture); |
| 615 } | 616 } |
| 616 } | 617 } |
| 617 | 618 |
| 618 ExtensionTabUtil::CreateTab(new_contents, extension_id_, disposition, | 619 ExtensionTabUtil::CreateTab(new_contents, extension_id_, disposition, |
| 619 initial_pos, user_gesture); | 620 initial_pos, user_gesture); |
| 621 return true; |
| 620 } | 622 } |
| 621 | 623 |
| 622 void ExtensionHost::RenderViewReady() { | 624 void ExtensionHost::RenderViewReady() { |
| 623 content::NotificationService::current()->Notify( | 625 content::NotificationService::current()->Notify( |
| 624 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 626 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
| 625 content::Source<Profile>(profile_), | 627 content::Source<Profile>(profile_), |
| 626 content::Details<ExtensionHost>(this)); | 628 content::Details<ExtensionHost>(this)); |
| 627 } | 629 } |
| 628 | 630 |
| 629 } // namespace extensions | 631 } // namespace extensions |
| OLD | NEW |