summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/extension_popup_api.cc17
-rw-r--r--chrome/browser/extensions/extension_popup_apitest.cc2
2 files changed, 17 insertions, 2 deletions
diff --git a/chrome/browser/extensions/extension_popup_api.cc b/chrome/browser/extensions/extension_popup_api.cc
index f778e0e..091fa71 100644
--- a/chrome/browser/extensions/extension_popup_api.cc
+++ b/chrome/browser/extensions/extension_popup_api.cc
@@ -42,6 +42,8 @@ const wchar_t kWidthKey[] = L"width";
const wchar_t kHeightKey[] = L"height";
const wchar_t kTopKey[] = L"top";
const wchar_t kLeftKey[] = L"left";
+const wchar_t kGiveFocusKey[] = L"giveFocus";
+const wchar_t kDomAnchorKey[] = L"domAnchor";
}; // namespace
@@ -81,8 +83,12 @@ bool PopupShowFunction::RunImpl() {
std::string url_string;
EXTENSION_FUNCTION_VALIDATE(args->GetString(0, &url_string));
+ DictionaryValue* show_details = NULL;
+ EXTENSION_FUNCTION_VALIDATE(args->GetDictionary(1, &show_details));
+
DictionaryValue* dom_anchor = NULL;
- EXTENSION_FUNCTION_VALIDATE(args->GetDictionary(1, &dom_anchor));
+ EXTENSION_FUNCTION_VALIDATE(show_details->GetDictionary(kDomAnchorKey,
+ &dom_anchor));
int dom_top, dom_left;
EXTENSION_FUNCTION_VALIDATE(dom_anchor->GetInteger(kTopKey,
@@ -98,6 +104,13 @@ bool PopupShowFunction::RunImpl() {
EXTENSION_FUNCTION_VALIDATE(dom_top >= 0 && dom_left >= 0 &&
dom_width >= 0 && dom_height >= 0);
+ // The default behaviour is to give the focus to the pop-up window.
+ bool give_focus = true;
+ if (show_details->HasKey(kGiveFocusKey)) {
+ EXTENSION_FUNCTION_VALIDATE(show_details->GetBoolean(kGiveFocusKey,
+ &give_focus));
+ }
+
GURL url = dispatcher()->url().Resolve(url_string);
if (!url.is_valid()) {
error_ = kInvalidURLError;
@@ -127,7 +140,7 @@ bool PopupShowFunction::RunImpl() {
(NULL != dispatcher()->GetExtensionHost()) ? BubbleBorder::BOTTOM_LEFT :
BubbleBorder::TOP_LEFT;
popup_ = ExtensionPopup::Show(url, dispatcher()->GetBrowser(), rect,
- arrow_location);
+ arrow_location, give_focus);
ExtensionPopupHost* popup_host = dispatcher()->GetPopupHost();
DCHECK(popup_host);
diff --git a/chrome/browser/extensions/extension_popup_apitest.cc b/chrome/browser/extensions/extension_popup_apitest.cc
index d8e33af..16c5374 100644
--- a/chrome/browser/extensions/extension_popup_apitest.cc
+++ b/chrome/browser/extensions/extension_popup_apitest.cc
@@ -10,5 +10,7 @@
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, FLAKY_Popup) {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableExperimentalExtensionApis);
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kEnableExtensionToolstrips);
ASSERT_TRUE(RunExtensionTest("popup_api")) << message_;
}