diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-09 23:18:05 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-09 23:18:05 +0000 |
commit | 7f860dd842e8e4aab9d2b16dc6c804e4fbc6235a (patch) | |
tree | fb391a628ec98acccc5d05d04bd98e9c8f4fa958 | |
parent | 0b48038ecfc7d12d3b6960be265fb93276eec77a (diff) | |
download | chromium_src-7f860dd842e8e4aab9d2b16dc6c804e4fbc6235a.zip chromium_src-7f860dd842e8e4aab9d2b16dc6c804e4fbc6235a.tar.gz chromium_src-7f860dd842e8e4aab9d2b16dc6c804e4fbc6235a.tar.bz2 |
Added support in Chromeframe full tab mode IE for setting zoom levels via View->Zoom. Currently we only support
Zoom in and zoom out as Chrome only supports these zoom levels.
Added an automation IPC message AutomationMsg_SetZoomLevel to set the zoom level in ChromeFrame.
The other change is in the active document in the handling of the attach external tab message. We now honor the
dimensions if any when we Launch the URL. This ensures that any windows opened outside chrome frame also honor these
dimensions.
Fixes bug http://code.google.com/p/chromium/issues/detail?id=36000
Bug=36000
Review URL: http://codereview.chromium.org/3064049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55494 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 1 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.h | 2 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_win.cc | 10 | ||||
-rw-r--r-- | chrome/browser/automation/chrome_frame_automation_provider.cc | 3 | ||||
-rw-r--r-- | chrome/test/automation/automation_messages_internal.h | 8 | ||||
-rw-r--r-- | chrome_frame/chrome_active_document.cc | 74 | ||||
-rw-r--r-- | chrome_frame/chrome_active_document.h | 12 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_automation.cc | 7 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_automation.h | 4 |
9 files changed, 102 insertions, 19 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 271d8b1..4ab8bc6 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -571,6 +571,7 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { OnMessageFromExternalHost) IPC_MESSAGE_HANDLER(AutomationMsg_BrowserMove, OnBrowserMoved) IPC_MESSAGE_HANDLER(AutomationMsg_RunUnloadHandlers, OnRunUnloadHandlers) + IPC_MESSAGE_HANDLER(AutomationMsg_SetZoomLevel, OnSetZoomLevel) #endif // defined(OS_WIN) #if defined(OS_CHROMEOS) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_LoginWithUserAndPass, diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 94a697c..f693d89 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -913,6 +913,8 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, void OnRunUnloadHandlers(int handle, gfx::NativeWindow notification_window, int notification_message); + void OnSetZoomLevel(int handle, int zoom_level); + ExternalTabContainer* GetExternalTabForHandle(int handle); #endif // defined(OS_WIN) diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index 51959bd..81cdcf2 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -20,6 +20,7 @@ #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/views/bookmark_bar_view.h" +#include "chrome/common/page_zoom.h" #include "chrome/test/automation/automation_messages.h" #include "views/widget/root_view.h" #include "views/widget/widget_win.h" @@ -603,3 +604,12 @@ void AutomationProvider::OnRunUnloadHandlers( } } +void AutomationProvider::OnSetZoomLevel(int handle, int zoom_level) { + if (tab_tracker_->ContainsHandle(handle)) { + NavigationController* tab = tab_tracker_->GetResource(handle); + if (tab->tab_contents() && tab->tab_contents()->render_view_host()) { + tab->tab_contents()->render_view_host()->Zoom( + static_cast<PageZoom::Function>(zoom_level)); + } + } +} diff --git a/chrome/browser/automation/chrome_frame_automation_provider.cc b/chrome/browser/automation/chrome_frame_automation_provider.cc index 52f8ded..b3ea659 100644 --- a/chrome/browser/automation/chrome_frame_automation_provider.cc +++ b/chrome/browser/automation/chrome_frame_automation_provider.cc @@ -65,7 +65,8 @@ bool ChromeFrameAutomationProvider::IsValidMessage(uint32 type) { case AutomationMsg_SaveAsAsync::ID: case AutomationMsg_RemoveBrowsingData::ID: case AutomationMsg_OverrideEncoding::ID: - case AutomationMsg_RunUnloadHandlers::ID: { + case AutomationMsg_RunUnloadHandlers::ID: + case AutomationMsg_SetZoomLevel::ID: { is_valid_message = true; break; } diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index 7b65d30..65555c3 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -1420,4 +1420,12 @@ IPC_BEGIN_MESSAGES(Automation) IPC_MESSAGE_ROUTED3(AutomationMsg_RunUnloadHandlers, int, gfx::NativeWindow, int) + // This message sets the current zoom level on the tab + // Request: + // -int: Tab handle + // -int: Zoom level. Values ZOOM_OUT = -1, RESET = 0, ZOOM_IN = 1 + // Response: + // None expected + IPC_MESSAGE_ROUTED2(AutomationMsg_SetZoomLevel, int, int) + IPC_END_MESSAGES(Automation) diff --git a/chrome_frame/chrome_active_document.cc b/chrome_frame/chrome_active_document.cc index 0fac7fc..ee29183 100644 --- a/chrome_frame/chrome_active_document.cc +++ b/chrome_frame/chrome_active_document.cc @@ -33,6 +33,7 @@ #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/navigation_types.h" +#include "chrome/common/page_zoom.h" #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" #include "chrome_frame/bho.h" @@ -571,23 +572,7 @@ HRESULT ChromeActiveDocument::ActiveXDocActivate(LONG verb) { return AtlHresultFromLastError(); } } - - ScopedComPtr<IWebBrowser2> web_browser2; - DoQueryService(SID_SWebBrowserApp, m_spClientSite, - web_browser2.Receive()); - if (web_browser2) { - if (!dimensions_.IsEmpty()) { - web_browser2->put_Width(dimensions_.width()); - web_browser2->put_Height(dimensions_.height()); - web_browser2->put_Left(dimensions_.x()); - web_browser2->put_Top(dimensions_.y()); - web_browser2->put_MenuBar(VARIANT_FALSE); - web_browser2->put_ToolBar(VARIANT_FALSE); - - dimensions_.set_height(0); - dimensions_.set_width(0); - } - } + SetWindowDimensions(); } SetObjectRects(&position_rect, &clip_rect); } @@ -864,6 +849,36 @@ void ChromeActiveDocument::OnDisplayPrivacyInfo() { DoPrivacyDlg(m_hWnd, url_, this, TRUE); } +void ChromeActiveDocument::OnGetZoomRange(const GUID* cmd_group_guid, + DWORD command_id, + DWORD cmd_exec_opt, + VARIANT* in_args, + VARIANT* out_args) { + if (out_args != NULL) { + out_args->vt = VT_I4; + out_args->lVal = 0; + } +} + +void ChromeActiveDocument::OnSetZoomRange(const GUID* cmd_group_guid, + DWORD command_id, + DWORD cmd_exec_opt, + VARIANT* in_args, + VARIANT* out_args) { + const int kZoomIn = 125; + const int kZoomOut = 75; + + if (in_args && V_VT(in_args) == VT_I4 && IsValid()) { + if (in_args->lVal == kZoomIn) { + automation_client_->SetZoomLevel(PageZoom::ZOOM_IN); + } else if (in_args->lVal == kZoomOut) { + automation_client_->SetZoomLevel(PageZoom::ZOOM_OUT); + } else { + DLOG(WARNING) << "Unsupported zoom level:" << in_args->lVal; + } + } +} + void ChromeActiveDocument::OnOpenURL(int tab_handle, const GURL& url_to_open, const GURL& referrer, @@ -977,11 +992,12 @@ bool ChromeActiveDocument::LaunchUrl(const ChromeFrameUrl& cf_url, std::string utf8_url; WideToUTF8(url_, url_.Length(), &utf8_url); - DLOG(INFO) << "Url is " << url_; + DLOG(INFO) << "this:" << this << " url is:" << url_; if (cf_url.attach_to_external_tab()) { dimensions_ = cf_url.dimensions(); automation_client_->AttachExternalTab(cf_url.cookie()); + SetWindowDimensions(); } else if (!automation_client_->InitiateNavigation(utf8_url, referrer, is_privileged_)) { @@ -1222,3 +1238,25 @@ LRESULT ChromeActiveDocument::OnSetFocus(UINT message, WPARAM wparam, GiveFocusToChrome(false); return 0; } + +void ChromeActiveDocument::SetWindowDimensions() { + ScopedComPtr<IWebBrowser2> web_browser2; + DoQueryService(SID_SWebBrowserApp, m_spClientSite, + web_browser2.Receive()); + if (!web_browser2) + return; + DLOG(INFO) << "this:" << this; + DLOG(INFO) << "dimensions: width:" << dimensions_.width() + << "height:" << dimensions_.height(); + if (!dimensions_.IsEmpty()) { + web_browser2->put_Width(dimensions_.width()); + web_browser2->put_Height(dimensions_.height()); + web_browser2->put_Left(dimensions_.x()); + web_browser2->put_Top(dimensions_.y()); + web_browser2->put_MenuBar(VARIANT_FALSE); + web_browser2->put_ToolBar(VARIANT_FALSE); + + dimensions_.set_height(0); + dimensions_.set_width(0); + } +} diff --git a/chrome_frame/chrome_active_document.h b/chrome_frame/chrome_active_document.h index 8b5f5e2..b8c59eb 100644 --- a/chrome_frame/chrome_active_document.h +++ b/chrome_frame/chrome_active_document.h @@ -273,6 +273,8 @@ BEGIN_EXEC_COMMAND_MAP(ChromeActiveDocument) EXEC_COMMAND_HANDLER_NO_ARGS(&CGID_ShellDocView, DOCHOST_DISPLAY_PRIVACY, OnDisplayPrivacyInfo) + EXEC_COMMAND_HANDLER(NULL, OLECMDID_OPTICAL_GETZOOMRANGE, OnGetZoomRange) + EXEC_COMMAND_HANDLER(NULL, OLECMDID_OPTICAL_ZOOM, OnSetZoomRange) END_EXEC_COMMAND_MAP() // IPCs from automation server. @@ -381,6 +383,12 @@ END_EXEC_COMMAND_MAP() VARIANT* out_args); void OnDisplayPrivacyInfo(); + void OnGetZoomRange(const GUID* cmd_group_guid, DWORD command_id, + DWORD cmd_exec_opt, VARIANT* in_args, VARIANT* out_args); + + void OnSetZoomRange(const GUID* cmd_group_guid, DWORD command_id, + DWORD cmd_exec_opt, VARIANT* in_args, VARIANT* out_args); + // Call exec on our site's command target HRESULT IEExec(const GUID* cmd_group_guid, DWORD command_id, DWORD cmd_exec_opt, VARIANT* in_args, VARIANT* out_args); @@ -424,6 +432,10 @@ END_EXEC_COMMAND_MAP() // we do not fire the DocumentComplete event to avoid a crash. static bool ShouldFireDocumentComplete(); + // Sets the dimensions on the IE window. These dimensions are parsed out from + // the information passed in from Chrome during window.open. + void SetWindowDimensions(); + protected: typedef std::map<int, OLECMDF> CommandStatusMap; diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc index 72c488c..ea2c127 100644 --- a/chrome_frame/chrome_frame_automation.cc +++ b/chrome_frame/chrome_frame_automation.cc @@ -1251,6 +1251,13 @@ void ChromeFrameAutomationClient::RunUnloadHandlers(HWND notification_window, } } +void ChromeFrameAutomationClient::SetZoomLevel(PageZoom::Function zoom_level) { + if (automation_server_) { + automation_server_->Send(new AutomationMsg_SetZoomLevel(0, tab_handle_, + zoom_level)); + } +} + ////////////////////////////////////////////////////////////////////////// // PluginUrlRequestDelegate implementation. // Forward network related responses to Chrome. diff --git a/chrome_frame/chrome_frame_automation.h b/chrome_frame/chrome_frame_automation.h index b38d4df..60fdcd4 100644 --- a/chrome_frame/chrome_frame_automation.h +++ b/chrome_frame/chrome_frame_automation.h @@ -18,6 +18,7 @@ #include "base/task.h" #include "base/timer.h" #include "base/thread.h" +#include "chrome/common/page_zoom.h" #include "chrome/test/automation/automation_proxy.h" #include "chrome/test/automation/tab_proxy.h" #include "chrome_frame/chrome_frame_delegate.h" @@ -277,6 +278,9 @@ class ChromeFrameAutomationClient // unload handlers on the page. void RunUnloadHandlers(HWND notification_window, int notification_message); + // Sets the current zoom level on the tab. + void SetZoomLevel(PageZoom::Function zoom_level); + protected: // ChromeFrameAutomationProxy::LaunchDelegate implementation. virtual void LaunchComplete(ChromeFrameAutomationProxy* proxy, |