| 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/api/extension_action/extension_action_api.h" | 5 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 return true; | 609 return true; |
| 610 } | 610 } |
| 611 | 611 |
| 612 BrowserActionOpenPopupFunction::BrowserActionOpenPopupFunction() | 612 BrowserActionOpenPopupFunction::BrowserActionOpenPopupFunction() |
| 613 : response_sent_(false) { | 613 : response_sent_(false) { |
| 614 } | 614 } |
| 615 | 615 |
| 616 bool BrowserActionOpenPopupFunction::RunAsync() { | 616 bool BrowserActionOpenPopupFunction::RunAsync() { |
| 617 // We only allow the popup in the active window. | 617 // We only allow the popup in the active window. |
| 618 Profile* profile = GetProfile(); | 618 Profile* profile = GetProfile(); |
| 619 Browser* browser = chrome::FindLastActiveWithProfile( | 619 Browser* browser = chrome::FindLastActiveWithProfile(profile); |
| 620 profile, chrome::GetActiveDesktop()); | |
| 621 // It's possible that the last active browser actually corresponds to the | 620 // It's possible that the last active browser actually corresponds to the |
| 622 // associated incognito profile, and this won't be returned by | 621 // associated incognito profile, and this won't be returned by |
| 623 // FindLastActiveWithProfile. If the browser we found isn't active and the | 622 // FindLastActiveWithProfile. If the browser we found isn't active and the |
| 624 // extension can operate incognito, then check the last active incognito, too. | 623 // extension can operate incognito, then check the last active incognito, too. |
| 625 if ((!browser || !browser->window()->IsActive()) && | 624 if ((!browser || !browser->window()->IsActive()) && |
| 626 util::IsIncognitoEnabled(extension()->id(), profile) && | 625 util::IsIncognitoEnabled(extension()->id(), profile) && |
| 627 profile->HasOffTheRecordProfile()) { | 626 profile->HasOffTheRecordProfile()) { |
| 628 browser = chrome::FindLastActiveWithProfile( | 627 browser = |
| 629 profile->GetOffTheRecordProfile(), chrome::GetActiveDesktop()); | 628 chrome::FindLastActiveWithProfile(profile->GetOffTheRecordProfile()); |
| 630 } | 629 } |
| 631 | 630 |
| 632 // If there's no active browser, or the Toolbar isn't visible, abort. | 631 // If there's no active browser, or the Toolbar isn't visible, abort. |
| 633 // Otherwise, try to open a popup in the active browser. | 632 // Otherwise, try to open a popup in the active browser. |
| 634 // TODO(justinlin): Remove toolbar check when http://crbug.com/308645 is | 633 // TODO(justinlin): Remove toolbar check when http://crbug.com/308645 is |
| 635 // fixed. | 634 // fixed. |
| 636 if (!browser || | 635 if (!browser || |
| 637 !browser->window()->IsActive() || | 636 !browser->window()->IsActive() || |
| 638 !browser->window()->IsToolbarVisible() || | 637 !browser->window()->IsToolbarVisible() || |
| 639 !ExtensionActionAPI::Get(GetProfile())->ShowExtensionActionPopup( | 638 !ExtensionActionAPI::Get(GetProfile())->ShowExtensionActionPopup( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || | 681 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || |
| 683 host->extension()->id() != extension_->id()) | 682 host->extension()->id() != extension_->id()) |
| 684 return; | 683 return; |
| 685 | 684 |
| 686 SendResponse(true); | 685 SendResponse(true); |
| 687 response_sent_ = true; | 686 response_sent_ = true; |
| 688 registrar_.RemoveAll(); | 687 registrar_.RemoveAll(); |
| 689 } | 688 } |
| 690 | 689 |
| 691 } // namespace extensions | 690 } // namespace extensions |
| OLD | NEW |