diff options
Diffstat (limited to 'chrome_frame')
-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 |
4 files changed, 79 insertions, 18 deletions
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, |