summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-13 00:47:45 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-13 00:47:45 +0000
commit87eab229472ea6f07c1e481c251fd33153decb86 (patch)
tree30d4f7aaca6699b8a8fa5c13c60314dcd2c184db
parent32cf3d9de04f4c5432c557dfe9f24dd4ea4f54d1 (diff)
downloadchromium_src-87eab229472ea6f07c1e481c251fd33153decb86.zip
chromium_src-87eab229472ea6f07c1e481c251fd33153decb86.tar.gz
chromium_src-87eab229472ea6f07c1e481c251fd33153decb86.tar.bz2
Add support for repositioning/resizing a tab window. This is needed as the SetWindowPos call
can fail on Vista if the caller is running under low IL. Review URL: http://codereview.chromium.org/42150 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11604 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/automation/automation_provider.cc25
-rw-r--r--chrome/browser/automation/automation_provider.h4
-rw-r--r--chrome/test/automation/automation_messages.h53
-rw-r--r--chrome/test/automation/automation_messages_internal.h8
-rw-r--r--chrome/test/automation/tab_proxy.cc17
-rw-r--r--chrome/test/automation/tab_proxy.h6
6 files changed, 113 insertions, 0 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index e37244c..5fa08ef 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -867,6 +867,7 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) {
WaitForTabToBeRestored)
IPC_MESSAGE_HANDLER(AutomationMsg_SetInitialFocus,
SetInitialFocus)
+ IPC_MESSAGE_HANDLER(AutomationMsg_TabReposition, OnTabReposition)
#endif // defined(OS_WIN)
IPC_MESSAGE_HANDLER(AutomationMsg_GetSecurityState,
GetSecurityState)
@@ -2712,3 +2713,27 @@ void AutomationProvider::OverrideEncoding(int tab_handle,
void AutomationProvider::SavePackageShouldPromptUser(bool should_prompt) {
SavePackage::SetShouldPromptUser(should_prompt);
}
+
+#ifdef OS_WIN
+void AutomationProvider::OnTabReposition(
+ int tab_handle, const IPC::Reposition_Params& params) {
+ if (!tab_tracker_->ContainsHandle(tab_handle))
+ return;
+
+ if (!IsWindow(params.window))
+ return;
+
+ unsigned long process_id = 0;
+ unsigned long thread_id = 0;
+
+ thread_id = GetWindowThreadProcessId(params.window, &process_id);
+
+ if (thread_id != GetCurrentThreadId()) {
+ NOTREACHED();
+ return;
+ }
+
+ SetWindowPos(params.window, params.window_insert_after, params.left,
+ params.top, params.width, params.height, params.flags);
+}
+#endif // defined(OS_WIN)
diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h
index c9aa0be..c2bdba3 100644
--- a/chrome/browser/automation/automation_provider.h
+++ b/chrome/browser/automation/automation_provider.h
@@ -24,6 +24,7 @@
#include "chrome/common/ipc_message.h"
#include "chrome/common/ipc_sync_channel.h"
#include "chrome/common/notification_observer.h"
+#include "chrome/test/automation/automation_messages.h"
#include "chrome/views/event.h"
#include "webkit/glue/find_in_page_request.h"
@@ -295,6 +296,9 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>,
// Chrome.
void SetAcceleratorsForTab(int handle, HACCEL accel_table,
int accel_entry_count, bool* status);
+
+ void OnTabReposition(int tab_handle,
+ const IPC::Reposition_Params& params);
#endif // defined(OS_WIN)
// Gets the security state for the tab associated to the specified |handle|.
diff --git a/chrome/test/automation/automation_messages.h b/chrome/test/automation/automation_messages.h
index ffeef1f..52a9945 100644
--- a/chrome/test/automation/automation_messages.h
+++ b/chrome/test/automation/automation_messages.h
@@ -120,6 +120,59 @@ struct ParamTraits<NavigationEntry::PageType> {
}
};
+#if defined(OS_WIN)
+struct Reposition_Params {
+ HWND window;
+ HWND window_insert_after;
+ int left;
+ int top;
+ int width;
+ int height;
+ int flags;
+};
+
+// Traits for SetWindowPos_Params structure to pack/unpack.
+template <>
+struct ParamTraits<Reposition_Params> {
+ typedef Reposition_Params param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, p.window);
+ WriteParam(m, p.window_insert_after);
+ WriteParam(m, p.left);
+ WriteParam(m, p.top);
+ WriteParam(m, p.width);
+ WriteParam(m, p.height);
+ WriteParam(m, p.flags);
+ }
+ static bool Read(const Message* m, void** iter, param_type* p) {
+ return ReadParam(m, iter, &p->window) &&
+ ReadParam(m, iter, &p->window_insert_after) &&
+ ReadParam(m, iter, &p->left) &&
+ ReadParam(m, iter, &p->top) &&
+ ReadParam(m, iter, &p->width) &&
+ ReadParam(m, iter, &p->height) &&
+ ReadParam(m, iter, &p->flags);
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ l->append(L"(");
+ LogParam(p.window, l);
+ l->append(L", ");
+ LogParam(p.window_insert_after, l);
+ l->append(L", ");
+ LogParam(p.left, l);
+ l->append(L", ");
+ LogParam(p.top, l);
+ l->append(L", ");
+ LogParam(p.width, l);
+ l->append(L", ");
+ LogParam(p.height, l);
+ l->append(L", ");
+ LogParam(p.flags, l);
+ l->append(L")");
+ }
+};
+#endif // defined(OS_WIN)
+
} // namespace IPC
#define MESSAGES_INTERNAL_FILE \
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h
index 98474ac..15daa28 100644
--- a/chrome/test/automation/automation_messages_internal.h
+++ b/chrome/test/automation/automation_messages_internal.h
@@ -860,4 +860,12 @@ IPC_BEGIN_MESSAGES(Automation)
// None expected
IPC_MESSAGE_ROUTED2(AutomationMsg_NavigationFailed, int, GURL)
+#if defined(OS_WIN)
+ // This message is an outgoing message from an automation client to Chrome.
+ // It is used to reposition a chrome tab window.
+ IPC_MESSAGE_ROUTED2(AutomationMsg_TabReposition,
+ int /* tab handle */,
+ IPC::Reposition_Params /* SetWindowPos params */)
+#endif // defined(OS_WIN)
+
IPC_END_MESSAGES(Automation)
diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc
index 07656e8..1ac8b75 100644
--- a/chrome/test/automation/tab_proxy.cc
+++ b/chrome/test/automation/tab_proxy.cc
@@ -606,3 +606,20 @@ bool TabProxy::OverrideEncoding(const std::wstring& encoding) {
&succeeded));
return succeeded;
}
+
+#if defined(OS_WIN)
+void TabProxy::Reposition(HWND window, HWND window_insert_after, int left,
+ int top, int width, int height, int flags) {
+
+ IPC::Reposition_Params params;
+ params.window = window;
+ params.window_insert_after = window_insert_after;
+ params.left = left;
+ params.top = top;
+ params.width = width;
+ params.height = height;
+ params.flags = flags;
+ sender_->Send(new AutomationMsg_TabReposition(0, handle_, params));
+}
+#endif // defined(OS_WIN)
+
diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h
index dc10a13..3603763 100644
--- a/chrome/test/automation/tab_proxy.h
+++ b/chrome/test/automation/tab_proxy.h
@@ -285,6 +285,12 @@ class TabProxy : public AutomationResourceProxy {
// Uses the specified encoding to override encoding of the page in the tab.
bool OverrideEncoding(const std::wstring& encoding);
+#if defined(OS_WIN)
+ // Resizes the tab window.
+ void Reposition(HWND window, HWND window_insert_after, int left, int top,
+ int width, int height, int flags);
+#endif // defined(OS_WIN)
+
private:
DISALLOW_COPY_AND_ASSIGN(TabProxy);
};