| 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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 WebContents* associated_contents = GetAssociatedWebContents(); | 580 WebContents* associated_contents = GetAssociatedWebContents(); |
| 581 if (associated_contents && | 581 if (associated_contents && |
| 582 associated_contents->GetBrowserContext() == | 582 associated_contents->GetBrowserContext() == |
| 583 new_contents->GetBrowserContext()) { | 583 new_contents->GetBrowserContext()) { |
| 584 associated_contents->AddNewContents( | 584 associated_contents->AddNewContents( |
| 585 new_contents, disposition, initial_pos, user_gesture); | 585 new_contents, disposition, initial_pos, user_gesture); |
| 586 return; | 586 return; |
| 587 } | 587 } |
| 588 } | 588 } |
| 589 | 589 |
| 590 // Find a browser with a profile that matches the new tab. If none is found, | |
| 591 // NULL argument to NavigateParams is valid. | |
| 592 Profile* profile = | 590 Profile* profile = |
| 593 Profile::FromBrowserContext(new_contents->GetBrowserContext()); | 591 Profile::FromBrowserContext(new_contents->GetBrowserContext()); |
| 594 Browser* browser = browser::FindTabbedBrowser( | 592 Browser* browser = browser::FindOrCreateTabbedBrowser(profile); |
| 595 profile, false); // Match incognito exactly. | |
| 596 TabContents* tab_contents = new TabContents(new_contents); | 593 TabContents* tab_contents = new TabContents(new_contents); |
| 597 chrome::NavigateParams params(browser, tab_contents); | 594 chrome::NavigateParams params(browser, tab_contents); |
| 598 | 595 |
| 599 // The extension_app_id parameter ends up as app_name in the Browser | 596 // The extension_app_id parameter ends up as app_name in the Browser |
| 600 // which causes the Browser to return true for is_app(). This affects | 597 // which causes the Browser to return true for is_app(). This affects |
| 601 // among other things, whether the location bar gets displayed. | 598 // among other things, whether the location bar gets displayed. |
| 602 // TODO(mpcomplete): This seems wrong. What if the extension content is hosted | 599 // TODO(mpcomplete): This seems wrong. What if the extension content is hosted |
| 603 // in a tab? | 600 // in a tab? |
| 604 if (disposition == NEW_POPUP) | 601 if (disposition == NEW_POPUP) |
| 605 params.extension_app_id = extension_id_; | 602 params.extension_app_id = extension_id_; |
| 606 | 603 |
| 607 if (!browser) | |
| 608 params.profile = profile; | |
| 609 params.disposition = disposition; | 604 params.disposition = disposition; |
| 610 params.window_bounds = initial_pos; | 605 params.window_bounds = initial_pos; |
| 611 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 606 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 612 params.user_gesture = user_gesture; | 607 params.user_gesture = user_gesture; |
| 613 chrome::Navigate(¶ms); | 608 chrome::Navigate(¶ms); |
| 614 } | 609 } |
| 615 | 610 |
| 616 void ExtensionHost::RenderViewReady() { | 611 void ExtensionHost::RenderViewReady() { |
| 617 content::NotificationService::current()->Notify( | 612 content::NotificationService::current()->Notify( |
| 618 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 613 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
| 619 content::Source<Profile>(profile_), | 614 content::Source<Profile>(profile_), |
| 620 content::Details<ExtensionHost>(this)); | 615 content::Details<ExtensionHost>(this)); |
| 621 } | 616 } |
| OLD | NEW |