Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Unified Diff: chrome/browser/extensions/api/extension_action/extension_action_api.cc

Issue 25305002: Implement initial chrome.browserAction.openPopup API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/extension_action/extension_action_api.cc
diff --git a/chrome/browser/extensions/api/extension_action/extension_action_api.cc b/chrome/browser/extensions/api/extension_action/extension_action_api.cc
index 488e852afc0dd84d7abcddc6411398c4576ff659..3af22b4584932b9ee0032a6225e9cfb12b209af6 100644
--- a/chrome/browser/extensions/api/extension_action/extension_action_api.cc
+++ b/chrome/browser/extensions/api/extension_action/extension_action_api.cc
@@ -32,6 +32,8 @@
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
+#include "chrome/browser/ui/browser_finder.h"
+
using content::WebContents;
namespace page_actions_keys = extension_page_actions_api_constants;
@@ -209,6 +211,7 @@ ExtensionActionAPI::ExtensionActionAPI(Profile* profile) {
registry->RegisterFunction<BrowserActionGetPopupFunction>();
registry->RegisterFunction<BrowserActionEnableFunction>();
registry->RegisterFunction<BrowserActionDisableFunction>();
+ registry->RegisterFunction<BrowserActionOpenPopupFunction>();
// Page Actions
registry->RegisterFunction<EnablePageActionsFunction>();
@@ -805,6 +808,19 @@ bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() {
return true;
}
+bool BrowserActionOpenPopupFunction::RunImpl() {
+ Browser* browser =
+ chrome::FindOrCreateTabbedBrowser(profile_, chrome::GetActiveDesktop());
mark a. foltz 2013/10/07 22:08:14 Need to decide which window gets the popup. - W
justinlin 2013/10/09 18:19:32 Yes, we should use the last active.
+ std::pair<const std::string, void* /*gfx::NativeWindow*/> details =
+ std::make_pair(extension_id(), browser/*browser->window()->GetNativeWindow()*/);
+ content::NotificationService::current()->Notify(
mark a. foltz 2013/10/07 22:08:14 It looks like only the Mac UI handles this notific
justinlin 2013/10/09 18:19:32 Using an observer notification instead now.
+ chrome::NOTIFICATION_EXTENSION_COMMAND_BROWSER_ACTION_MAC,
+ content::Source<Profile>(profile_),
+ content::Details<
+ std::pair<const std::string, void* /*gfx::NativeWindow*/> >(&details));
+ return true;
+}
+
//
// ScriptBadgeGetAttentionFunction
//

Powered by Google App Engine
This is Rietveld 408576698