summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/browser_action_apitest.cc33
-rw-r--r--chrome/browser/extensions/extension_host.cc6
-rw-r--r--chrome/browser/extensions/extension_host.h2
3 files changed, 36 insertions, 5 deletions
diff --git a/chrome/browser/extensions/browser_action_apitest.cc b/chrome/browser/extensions/browser_action_apitest.cc
index 692e74e..5a7c086 100644
--- a/chrome/browser/extensions/browser_action_apitest.cc
+++ b/chrome/browser/extensions/browser_action_apitest.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/views/browser_actions_container.h"
+#include "chrome/browser/views/extensions/extension_popup.h"
#include "chrome/browser/views/toolbar_view.h"
#include "chrome/common/extensions/extension_action.h"
#include "chrome/test/ui_test_utils.h"
@@ -62,7 +63,6 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BrowserAction) {
ASSERT_TRUE(result);
}
-
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DynamicBrowserAction) {
ASSERT_TRUE(RunExtensionTest("browser_action_no_icon")) << message_;
@@ -84,3 +84,34 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DynamicBrowserAction) {
ExtensionActionState* action_state = extension->browser_action_state();
ASSERT_TRUE(action_state->icon());
}
+
+IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BrowserActionPopup) {
+ ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("popup")));
+
+ ResultCatcher catcher;
+ BrowserActionsContainer* browser_actions =
+ browser()->window()->GetBrowserWindowTesting()->GetToolbarView()->
+ browser_actions();
+
+ // Simulate a click on the browser action and verify the size of the resulting
+ // popup.
+ browser_actions->TestExecuteBrowserAction(0);
+ EXPECT_TRUE(browser_actions->TestGetPopup() != NULL);
+ ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
+ gfx::Rect bounds = browser_actions->TestGetPopup()->view()->bounds();
+ EXPECT_EQ(100, bounds.width());
+ EXPECT_EQ(100, bounds.height());
+ browser_actions->HidePopup();
+ EXPECT_TRUE(browser_actions->TestGetPopup() == NULL);
+
+ // Do it again, and verify the new bigger size (the popup grows each time it's
+ // opened).
+ browser_actions->TestExecuteBrowserAction(0);
+ EXPECT_TRUE(browser_actions->TestGetPopup() != NULL);
+ ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
+ bounds = browser_actions->TestGetPopup()->view()->bounds();
+ EXPECT_EQ(200, bounds.width());
+ EXPECT_EQ(200, bounds.height());
+ browser_actions->HidePopup();
+ EXPECT_TRUE(browser_actions->TestGetPopup() == NULL);
+}
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index 8b45d4c..5413cd7 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -213,9 +213,9 @@ void ExtensionHost::Observe(NotificationType type,
}
}
-void ExtensionHost::UpdatePreferredWidth(int pref_width) {
+void ExtensionHost::UpdatePreferredSize(const gfx::Size& new_size) {
if (view_.get())
- view_->UpdatePreferredWidth(pref_width);
+ view_->UpdatePreferredSize(new_size);
}
void ExtensionHost::RenderViewGone(RenderViewHost* render_view_host) {
@@ -503,7 +503,7 @@ void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) {
extension_function_dispatcher_.reset(
new ExtensionFunctionDispatcher(render_view_host, this, url_));
- render_view_host->Send(new ViewMsg_EnableIntrinsicWidthChangedMode(
+ render_view_host->Send(new ViewMsg_EnablePreferredSizeChangedMode(
render_view_host->routing_id()));
}
diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h
index ba145b4..0c43067 100644
--- a/chrome/browser/extensions/extension_host.h
+++ b/chrome/browser/extensions/extension_host.h
@@ -134,7 +134,7 @@ class ExtensionHost : public RenderViewHostDelegate,
virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
virtual void HandleMouseEvent();
virtual void HandleMouseLeave();
- virtual void UpdatePreferredWidth(int pref_width);
+ virtual void UpdatePreferredSize(const gfx::Size& new_size);
// NotificationObserver
virtual void Observe(NotificationType type,