OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Implementation of ChromeActiveDocument | 5 // Implementation of ChromeActiveDocument |
6 #include "chrome_frame/chrome_active_document.h" | 6 #include "chrome_frame/chrome_active_document.h" |
7 | 7 |
8 #include <hlink.h> | 8 #include <hlink.h> |
9 #include <htiface.h> | 9 #include <htiface.h> |
10 #include <initguid.h> | 10 #include <initguid.h> |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "base/logging.h" | 23 #include "base/logging.h" |
24 #include "base/path_service.h" | 24 #include "base/path_service.h" |
25 #include "base/process_util.h" | 25 #include "base/process_util.h" |
26 #include "base/string_tokenizer.h" | 26 #include "base/string_tokenizer.h" |
27 #include "base/string_util.h" | 27 #include "base/string_util.h" |
28 #include "base/threading/thread.h" | 28 #include "base/threading/thread.h" |
29 #include "base/threading/thread_local.h" | 29 #include "base/threading/thread_local.h" |
30 #include "base/utf_string_conversions.h" | 30 #include "base/utf_string_conversions.h" |
31 #include "base/win/scoped_variant.h" | 31 #include "base/win/scoped_variant.h" |
32 #include "base/win/win_util.h" | 32 #include "base/win/win_util.h" |
33 #include "grit/generated_resources.h" | |
34 #include "chrome/app/chrome_command_ids.h" | 33 #include "chrome/app/chrome_command_ids.h" |
35 #include "chrome/app/chrome_dll_resource.h" | 34 #include "chrome/app/chrome_dll_resource.h" |
36 #include "chrome/common/automation_messages.h" | 35 #include "chrome/common/automation_messages.h" |
37 #include "chrome/common/chrome_constants.h" | 36 #include "chrome/common/chrome_constants.h" |
38 #include "chrome/test/automation/browser_proxy.h" | 37 #include "chrome/test/automation/browser_proxy.h" |
39 #include "chrome/test/automation/tab_proxy.h" | 38 #include "chrome/test/automation/tab_proxy.h" |
40 #include "chrome_frame/bho.h" | 39 #include "chrome_frame/bho.h" |
41 #include "chrome_frame/bind_context_info.h" | 40 #include "chrome_frame/bind_context_info.h" |
42 #include "chrome_frame/buggy_bho_handling.h" | 41 #include "chrome_frame/buggy_bho_handling.h" |
43 #include "chrome_frame/crash_reporting/crash_metrics.h" | 42 #include "chrome_frame/crash_reporting/crash_metrics.h" |
44 #include "chrome_frame/utils.h" | 43 #include "chrome_frame/utils.h" |
45 #include "content/browser/tab_contents/tab_contents.h" | 44 #include "content/browser/tab_contents/tab_contents.h" |
46 #include "content/common/navigation_types.h" | 45 #include "content/common/navigation_types.h" |
47 #include "content/common/page_zoom.h" | 46 #include "content/common/page_zoom.h" |
| 47 #include "grit/generated_resources.h" |
48 | 48 |
49 DEFINE_GUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0, 0xC0, 0, 0, 0, 0, 0, 0, | 49 DEFINE_GUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0, 0xC0, 0, 0, 0, 0, 0, 0, |
50 0x46); | 50 0x46); |
51 | 51 |
52 base::ThreadLocalPointer<ChromeActiveDocument> g_active_doc_cache; | 52 base::ThreadLocalPointer<ChromeActiveDocument> g_active_doc_cache; |
53 | 53 |
54 bool g_first_launch_by_process_ = true; | 54 bool g_first_launch_by_process_ = true; |
55 | 55 |
56 const DWORD kIEEncodingIdArray[] = { | 56 const DWORD kIEEncodingIdArray[] = { |
57 #define DEFINE_ENCODING_ID_ARRAY(encoding_name, id, chrome_name) encoding_name, | 57 #define DEFINE_ENCODING_ID_ARRAY(encoding_name, id, chrome_name) encoding_name, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // the user opens a new IE window with a URL that has us as the DocObject. | 147 // the user opens a new IE window with a URL that has us as the DocObject. |
148 // Here we refuse to be activated in-place and we will force IE to UIActivate | 148 // Here we refuse to be activated in-place and we will force IE to UIActivate |
149 // us. | 149 // us. |
150 if (OLEIVERB_INPLACEACTIVATE == verb) | 150 if (OLEIVERB_INPLACEACTIVATE == verb) |
151 return OLEOBJ_E_INVALIDVERB; | 151 return OLEOBJ_E_INVALIDVERB; |
152 // Check if we should activate as a docobject or not | 152 // Check if we should activate as a docobject or not |
153 // (client supports IOleDocumentSite) | 153 // (client supports IOleDocumentSite) |
154 if (doc_site_) { | 154 if (doc_site_) { |
155 switch (verb) { | 155 switch (verb) { |
156 case OLEIVERB_SHOW: { | 156 case OLEIVERB_SHOW: { |
157 ScopedComPtr<IDocHostUIHandler> doc_host_handler; | 157 base::win::ScopedComPtr<IDocHostUIHandler> doc_host_handler; |
158 doc_host_handler.QueryFrom(doc_site_); | 158 doc_host_handler.QueryFrom(doc_site_); |
159 if (doc_host_handler.get()) | 159 if (doc_host_handler.get()) |
160 doc_host_handler->ShowUI(DOCHOSTUITYPE_BROWSE, this, this, NULL, NULL); | 160 doc_host_handler->ShowUI(DOCHOSTUITYPE_BROWSE, this, this, NULL, NULL); |
161 } | 161 } |
162 case OLEIVERB_OPEN: | 162 case OLEIVERB_OPEN: |
163 case OLEIVERB_UIACTIVATE: | 163 case OLEIVERB_UIACTIVATE: |
164 if (!m_bUIActive) | 164 if (!m_bUIActive) |
165 return doc_site_->ActivateMe(NULL); | 165 return doc_site_->ActivateMe(NULL); |
166 break; | 166 break; |
167 } | 167 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 BaseActiveX::GiveFocusToChrome(true); | 208 BaseActiveX::GiveFocusToChrome(true); |
209 } | 209 } |
210 | 210 |
211 STDMETHODIMP ChromeActiveDocument::Load(BOOL fully_avalable, | 211 STDMETHODIMP ChromeActiveDocument::Load(BOOL fully_avalable, |
212 IMoniker* moniker_name, | 212 IMoniker* moniker_name, |
213 LPBC bind_context, | 213 LPBC bind_context, |
214 DWORD mode) { | 214 DWORD mode) { |
215 if (NULL == moniker_name) | 215 if (NULL == moniker_name) |
216 return E_INVALIDARG; | 216 return E_INVALIDARG; |
217 | 217 |
218 ScopedComPtr<IOleClientSite> client_site; | 218 base::win::ScopedComPtr<IOleClientSite> client_site; |
219 if (bind_context) { | 219 if (bind_context) { |
220 ScopedComPtr<IUnknown> site; | 220 base::win::ScopedComPtr<IUnknown> site; |
221 bind_context->GetObjectParam(SZ_HTML_CLIENTSITE_OBJECTPARAM, | 221 bind_context->GetObjectParam(SZ_HTML_CLIENTSITE_OBJECTPARAM, |
222 site.Receive()); | 222 site.Receive()); |
223 if (site) | 223 if (site) |
224 client_site.QueryFrom(site); | 224 client_site.QueryFrom(site); |
225 } | 225 } |
226 | 226 |
227 if (client_site) { | 227 if (client_site) { |
228 SetClientSite(client_site); | 228 SetClientSite(client_site); |
229 DoQueryService(IID_INewWindowManager, client_site, | 229 DoQueryService(IID_INewWindowManager, client_site, |
230 popup_manager_.Receive()); | 230 popup_manager_.Receive()); |
231 | 231 |
232 // See if mshtml parsed the html header for us. If so, we need to | 232 // See if mshtml parsed the html header for us. If so, we need to |
233 // clear the browser service flag that we use to indicate that this | 233 // clear the browser service flag that we use to indicate that this |
234 // browser instance is navigating to a CF document. | 234 // browser instance is navigating to a CF document. |
235 ScopedComPtr<IBrowserService> browser_service; | 235 base::win::ScopedComPtr<IBrowserService> browser_service; |
236 DoQueryService(SID_SShellBrowser, client_site, browser_service.Receive()); | 236 DoQueryService(SID_SShellBrowser, client_site, browser_service.Receive()); |
237 if (browser_service) { | 237 if (browser_service) { |
238 bool flagged = CheckForCFNavigation(browser_service, true); | 238 bool flagged = CheckForCFNavigation(browser_service, true); |
239 DVLOG_IF(1, flagged) << "Cleared flagged browser service"; | 239 DVLOG_IF(1, flagged) << "Cleared flagged browser service"; |
240 } | 240 } |
241 } | 241 } |
242 | 242 |
243 NavigationManager* mgr = NavigationManager::GetThreadInstance(); | 243 NavigationManager* mgr = NavigationManager::GetThreadInstance(); |
244 DLOG_IF(ERROR, !mgr) << "Couldn't get instance of NavigationManager"; | 244 DLOG_IF(ERROR, !mgr) << "Couldn't get instance of NavigationManager"; |
245 | 245 |
246 std::wstring url; | 246 std::wstring url; |
247 | 247 |
248 ScopedComPtr<BindContextInfo> info; | 248 base::win::ScopedComPtr<BindContextInfo> info; |
249 BindContextInfo::FromBindContext(bind_context, info.Receive()); | 249 BindContextInfo::FromBindContext(bind_context, info.Receive()); |
250 DCHECK(info); | 250 DCHECK(info); |
251 if (info && !info->GetUrl().empty()) { | 251 if (info && !info->GetUrl().empty()) { |
252 url = info->GetUrl(); | 252 url = info->GetUrl(); |
253 if (mgr) { | 253 if (mgr) { |
254 // If the original URL contains an anchor, then the URL queried | 254 // If the original URL contains an anchor, then the URL queried |
255 // from the protocol sink wrapper does not contain the anchor. To | 255 // from the protocol sink wrapper does not contain the anchor. To |
256 // workaround this we retrieve the anchor from the navigation manager | 256 // workaround this we retrieve the anchor from the navigation manager |
257 // and append it to the url retrieved from the protocol sink wrapper. | 257 // and append it to the url retrieved from the protocol sink wrapper. |
258 GURL url_for_anchor(mgr->url()); | 258 GURL url_for_anchor(mgr->url()); |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 HRESULT ChromeActiveDocument::IOleObject_SetClientSite( | 543 HRESULT ChromeActiveDocument::IOleObject_SetClientSite( |
544 IOleClientSite* client_site) { | 544 IOleClientSite* client_site) { |
545 if (client_site == NULL) { | 545 if (client_site == NULL) { |
546 ChromeActiveDocument* cached_document = g_active_doc_cache.Get(); | 546 ChromeActiveDocument* cached_document = g_active_doc_cache.Get(); |
547 if (cached_document) { | 547 if (cached_document) { |
548 DCHECK(this == cached_document); | 548 DCHECK(this == cached_document); |
549 g_active_doc_cache.Set(NULL); | 549 g_active_doc_cache.Set(NULL); |
550 cached_document->Release(); | 550 cached_document->Release(); |
551 } | 551 } |
552 | 552 |
553 ScopedComPtr<IDocHostUIHandler> doc_host_handler; | 553 base::win::ScopedComPtr<IDocHostUIHandler> doc_host_handler; |
554 if (doc_site_) | 554 if (doc_site_) |
555 doc_host_handler.QueryFrom(doc_site_); | 555 doc_host_handler.QueryFrom(doc_site_); |
556 | 556 |
557 if (doc_host_handler.get()) | 557 if (doc_host_handler.get()) |
558 doc_host_handler->HideUI(); | 558 doc_host_handler->HideUI(); |
559 | 559 |
560 doc_site_.Release(); | 560 doc_site_.Release(); |
561 } | 561 } |
562 | 562 |
563 if (client_site != m_spClientSite) | 563 if (client_site != m_spClientSite) |
564 return BaseActiveX::IOleObject_SetClientSite(client_site); | 564 return BaseActiveX::IOleObject_SetClientSite(client_site); |
565 | 565 |
566 return S_OK; | 566 return S_OK; |
567 } | 567 } |
568 | 568 |
569 HRESULT ChromeActiveDocument::ActiveXDocActivate(LONG verb) { | 569 HRESULT ChromeActiveDocument::ActiveXDocActivate(LONG verb) { |
570 HRESULT hr = S_OK; | 570 HRESULT hr = S_OK; |
571 m_bNegotiatedWnd = TRUE; | 571 m_bNegotiatedWnd = TRUE; |
572 if (!m_bInPlaceActive) { | 572 if (!m_bInPlaceActive) { |
573 hr = m_spInPlaceSite->CanInPlaceActivate(); | 573 hr = m_spInPlaceSite->CanInPlaceActivate(); |
574 if (FAILED(hr)) | 574 if (FAILED(hr)) |
575 return hr; | 575 return hr; |
576 m_spInPlaceSite->OnInPlaceActivate(); | 576 m_spInPlaceSite->OnInPlaceActivate(); |
577 } | 577 } |
578 m_bInPlaceActive = TRUE; | 578 m_bInPlaceActive = TRUE; |
579 // get location in the parent window, | 579 // get location in the parent window, |
580 // as well as some information about the parent | 580 // as well as some information about the parent |
581 ScopedComPtr<IOleInPlaceUIWindow> in_place_ui_window; | 581 base::win::ScopedComPtr<IOleInPlaceUIWindow> in_place_ui_window; |
582 frame_info_.cb = sizeof(OLEINPLACEFRAMEINFO); | 582 frame_info_.cb = sizeof(OLEINPLACEFRAMEINFO); |
583 HWND parent_window = NULL; | 583 HWND parent_window = NULL; |
584 if (m_spInPlaceSite->GetWindow(&parent_window) == S_OK) { | 584 if (m_spInPlaceSite->GetWindow(&parent_window) == S_OK) { |
585 in_place_frame_.Release(); | 585 in_place_frame_.Release(); |
586 RECT position_rect = {0}; | 586 RECT position_rect = {0}; |
587 RECT clip_rect = {0}; | 587 RECT clip_rect = {0}; |
588 m_spInPlaceSite->GetWindowContext(in_place_frame_.Receive(), | 588 m_spInPlaceSite->GetWindowContext(in_place_frame_.Receive(), |
589 in_place_ui_window.Receive(), | 589 in_place_ui_window.Receive(), |
590 &position_rect, | 590 &position_rect, |
591 &clip_rect, | 591 &clip_rect, |
592 &frame_info_); | 592 &frame_info_); |
593 if (!m_bWndLess) { | 593 if (!m_bWndLess) { |
594 if (IsWindow()) { | 594 if (IsWindow()) { |
595 ::ShowWindow(m_hWnd, SW_SHOW); | 595 ::ShowWindow(m_hWnd, SW_SHOW); |
596 SetFocus(); | 596 SetFocus(); |
597 } else { | 597 } else { |
598 m_hWnd = Create(parent_window, position_rect); | 598 m_hWnd = Create(parent_window, position_rect); |
599 if (!IsWindow()) { | 599 if (!IsWindow()) { |
600 // This might happen if the automation server couldn't be | 600 // This might happen if the automation server couldn't be |
601 // instantiated. If so, a NOTREACHED() will have already been hit. | 601 // instantiated. If so, a NOTREACHED() will have already been hit. |
602 DLOG(ERROR) << "Failed to create Ax window"; | 602 DLOG(ERROR) << "Failed to create Ax window"; |
603 return AtlHresultFromLastError(); | 603 return AtlHresultFromLastError(); |
604 } | 604 } |
605 } | 605 } |
606 } | 606 } |
607 SetObjectRects(&position_rect, &clip_rect); | 607 SetObjectRects(&position_rect, &clip_rect); |
608 } | 608 } |
609 | 609 |
610 ScopedComPtr<IOleInPlaceActiveObject> in_place_active_object(this); | 610 base::win::ScopedComPtr<IOleInPlaceActiveObject> in_place_active_object(this); |
611 | 611 |
612 // Gone active by now, take care of UIACTIVATE | 612 // Gone active by now, take care of UIACTIVATE |
613 if (DoesVerbUIActivate(verb)) { | 613 if (DoesVerbUIActivate(verb)) { |
614 if (!m_bUIActive) { | 614 if (!m_bUIActive) { |
615 m_bUIActive = TRUE; | 615 m_bUIActive = TRUE; |
616 hr = m_spInPlaceSite->OnUIActivate(); | 616 hr = m_spInPlaceSite->OnUIActivate(); |
617 if (FAILED(hr)) | 617 if (FAILED(hr)) |
618 return hr; | 618 return hr; |
619 // set ourselves up in the host | 619 // set ourselves up in the host |
620 if (in_place_active_object) { | 620 if (in_place_active_object) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 CrashMetricsReporter::CHROME_FRAME_NAVIGATION_COUNT); | 700 CrashMetricsReporter::CHROME_FRAME_NAVIGATION_COUNT); |
701 | 701 |
702 UpdateNavigationState(nav_info, 0); | 702 UpdateNavigationState(nav_info, 0); |
703 } | 703 } |
704 | 704 |
705 void ChromeActiveDocument::OnCloseTab() { | 705 void ChromeActiveDocument::OnCloseTab() { |
706 // Base class will fire DIChromeFrameEvents::onclose. | 706 // Base class will fire DIChromeFrameEvents::onclose. |
707 BaseActiveX::OnCloseTab(); | 707 BaseActiveX::OnCloseTab(); |
708 | 708 |
709 // Close the container window. | 709 // Close the container window. |
710 ScopedComPtr<IWebBrowser2> web_browser2; | 710 base::win::ScopedComPtr<IWebBrowser2> web_browser2; |
711 DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive()); | 711 DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive()); |
712 if (web_browser2) | 712 if (web_browser2) |
713 web_browser2->Quit(); | 713 web_browser2->Quit(); |
714 } | 714 } |
715 | 715 |
716 void ChromeActiveDocument::UpdateNavigationState( | 716 void ChromeActiveDocument::UpdateNavigationState( |
717 const NavigationInfo& new_navigation_info, int flags) { | 717 const NavigationInfo& new_navigation_info, int flags) { |
718 // This could be NULL if the active document instance is being destroyed. | 718 // This could be NULL if the active document instance is being destroyed. |
719 if (!m_spInPlaceSite) { | 719 if (!m_spInPlaceSite) { |
720 DVLOG(1) << __FUNCTION__ << "m_spInPlaceSite is NULL. Returning"; | 720 DVLOG(1) << __FUNCTION__ << "m_spInPlaceSite is NULL. Returning"; |
(...skipping 26 matching lines...) Expand all Loading... |
747 IEExec(&CGID_ShellDocView, INTERNAL_CMDID_SET_SSL_LOCK, | 747 IEExec(&CGID_ShellDocView, INTERNAL_CMDID_SET_SSL_LOCK, |
748 OLECMDEXECOPT_DODEFAULT, secure_lock_status.AsInput(), NULL); | 748 OLECMDEXECOPT_DODEFAULT, secure_lock_status.AsInput(), NULL); |
749 } | 749 } |
750 | 750 |
751 // A number of poorly written bho's crash in their event sink callbacks if | 751 // A number of poorly written bho's crash in their event sink callbacks if |
752 // chrome frame is the currently loaded document. This is because they expect | 752 // chrome frame is the currently loaded document. This is because they expect |
753 // chrome frame to implement interfaces like IHTMLDocument, etc. We patch the | 753 // chrome frame to implement interfaces like IHTMLDocument, etc. We patch the |
754 // event sink's of these bho's and don't invoke the event sink if chrome | 754 // event sink's of these bho's and don't invoke the event sink if chrome |
755 // frame is the currently loaded document. | 755 // frame is the currently loaded document. |
756 if (GetConfigBool(true, kEnableBuggyBhoIntercept)) { | 756 if (GetConfigBool(true, kEnableBuggyBhoIntercept)) { |
757 ScopedComPtr<IWebBrowser2> wb2; | 757 base::win::ScopedComPtr<IWebBrowser2> wb2; |
758 DoQueryService(SID_SWebBrowserApp, m_spClientSite, wb2.Receive()); | 758 DoQueryService(SID_SWebBrowserApp, m_spClientSite, wb2.Receive()); |
759 if (wb2 && buggy_bho::BuggyBhoTls::GetInstance()) { | 759 if (wb2 && buggy_bho::BuggyBhoTls::GetInstance()) { |
760 buggy_bho::BuggyBhoTls::GetInstance()->PatchBuggyBHOs(wb2); | 760 buggy_bho::BuggyBhoTls::GetInstance()->PatchBuggyBHOs(wb2); |
761 } | 761 } |
762 } | 762 } |
763 | 763 |
764 // Ideally all navigations should come to Chrome Frame so that we can call | 764 // Ideally all navigations should come to Chrome Frame so that we can call |
765 // BeforeNavigate2 on installed BHOs and give them a chance to cancel the | 765 // BeforeNavigate2 on installed BHOs and give them a chance to cancel the |
766 // navigation. However, in practice what happens is as below: | 766 // navigation. However, in practice what happens is as below: |
767 // The very first navigation that happens in CF happens via a Load or a | 767 // The very first navigation that happens in CF happens via a Load or a |
(...skipping 13 matching lines...) Expand all Loading... |
781 bool is_attach_external_tab_url = cf_url.Parse(std::wstring(url_)) && | 781 bool is_attach_external_tab_url = cf_url.Parse(std::wstring(url_)) && |
782 cf_url.attach_to_external_tab(); | 782 cf_url.attach_to_external_tab(); |
783 | 783 |
784 bool is_internal_navigation = | 784 bool is_internal_navigation = |
785 IsNewNavigation(new_navigation_info, flags) || is_attach_external_tab_url; | 785 IsNewNavigation(new_navigation_info, flags) || is_attach_external_tab_url; |
786 | 786 |
787 if (new_navigation_info.url.is_valid()) | 787 if (new_navigation_info.url.is_valid()) |
788 url_.Allocate(UTF8ToWide(new_navigation_info.url.spec()).c_str()); | 788 url_.Allocate(UTF8ToWide(new_navigation_info.url.spec()).c_str()); |
789 | 789 |
790 if (is_internal_navigation) { | 790 if (is_internal_navigation) { |
791 ScopedComPtr<IDocObjectService> doc_object_svc; | 791 base::win::ScopedComPtr<IDocObjectService> doc_object_svc; |
792 ScopedComPtr<IWebBrowserEventsService> web_browser_events_svc; | 792 base::win::ScopedComPtr<IWebBrowserEventsService> web_browser_events_svc; |
793 | 793 |
794 DoQueryService(__uuidof(web_browser_events_svc), m_spClientSite, | 794 DoQueryService(__uuidof(web_browser_events_svc), m_spClientSite, |
795 web_browser_events_svc.Receive()); | 795 web_browser_events_svc.Receive()); |
796 | 796 |
797 if (!web_browser_events_svc.get()) { | 797 if (!web_browser_events_svc.get()) { |
798 DoQueryService(SID_SShellBrowser, m_spClientSite, | 798 DoQueryService(SID_SShellBrowser, m_spClientSite, |
799 doc_object_svc.Receive()); | 799 doc_object_svc.Receive()); |
800 } | 800 } |
801 | 801 |
802 // web_browser_events_svc can be NULL on IE6. | 802 // web_browser_events_svc can be NULL on IE6. |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 // Allow popup | 975 // Allow popup |
976 if (hr == S_OK) { | 976 if (hr == S_OK) { |
977 BaseActiveX::OnAttachExternalTab(params); | 977 BaseActiveX::OnAttachExternalTab(params); |
978 return; | 978 return; |
979 } | 979 } |
980 | 980 |
981 automation_client_->BlockExternalTab(params.cookie); | 981 automation_client_->BlockExternalTab(params.cookie); |
982 } | 982 } |
983 | 983 |
984 bool ChromeActiveDocument::PreProcessContextMenu(HMENU menu) { | 984 bool ChromeActiveDocument::PreProcessContextMenu(HMENU menu) { |
985 ScopedComPtr<IBrowserService> browser_service; | 985 base::win::ScopedComPtr<IBrowserService> browser_service; |
986 ScopedComPtr<ITravelLog> travel_log; | 986 base::win::ScopedComPtr<ITravelLog> travel_log; |
987 GetBrowserServiceAndTravelLog(browser_service.Receive(), | 987 GetBrowserServiceAndTravelLog(browser_service.Receive(), |
988 travel_log.Receive()); | 988 travel_log.Receive()); |
989 if (!browser_service || !travel_log) | 989 if (!browser_service || !travel_log) |
990 return true; | 990 return true; |
991 | 991 |
992 EnableMenuItem(menu, IDC_BACK, MF_BYCOMMAND | | 992 EnableMenuItem(menu, IDC_BACK, MF_BYCOMMAND | |
993 (SUCCEEDED(travel_log->GetTravelEntry(browser_service, TLOG_BACK, | 993 (SUCCEEDED(travel_log->GetTravelEntry(browser_service, TLOG_BACK, |
994 NULL)) ? | 994 NULL)) ? |
995 MF_ENABLED : MF_DISABLED)); | 995 MF_ENABLED : MF_DISABLED)); |
996 EnableMenuItem(menu, IDC_FORWARD, MF_BYCOMMAND | | 996 EnableMenuItem(menu, IDC_FORWARD, MF_BYCOMMAND | |
997 (SUCCEEDED(travel_log->GetTravelEntry(browser_service, TLOG_FORE, | 997 (SUCCEEDED(travel_log->GetTravelEntry(browser_service, TLOG_FORE, |
998 NULL)) ? | 998 NULL)) ? |
999 MF_ENABLED : MF_DISABLED)); | 999 MF_ENABLED : MF_DISABLED)); |
1000 // Call base class (adds 'About' item) | 1000 // Call base class (adds 'About' item) |
1001 return BaseActiveX::PreProcessContextMenu(menu); | 1001 return BaseActiveX::PreProcessContextMenu(menu); |
1002 } | 1002 } |
1003 | 1003 |
1004 bool ChromeActiveDocument::HandleContextMenuCommand( | 1004 bool ChromeActiveDocument::HandleContextMenuCommand( |
1005 UINT cmd, const MiniContextMenuParams& params) { | 1005 UINT cmd, const MiniContextMenuParams& params) { |
1006 ScopedComPtr<IWebBrowser2> web_browser2; | 1006 base::win::ScopedComPtr<IWebBrowser2> web_browser2; |
1007 DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive()); | 1007 DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive()); |
1008 | 1008 |
1009 if (cmd == IDC_BACK) | 1009 if (cmd == IDC_BACK) |
1010 web_browser2->GoBack(); | 1010 web_browser2->GoBack(); |
1011 else if (cmd == IDC_FORWARD) | 1011 else if (cmd == IDC_FORWARD) |
1012 web_browser2->GoForward(); | 1012 web_browser2->GoForward(); |
1013 else if (cmd == IDC_RELOAD) | 1013 else if (cmd == IDC_RELOAD) |
1014 web_browser2->Refresh(); | 1014 web_browser2->Refresh(); |
1015 else | 1015 else |
1016 return BaseActiveX::HandleContextMenuCommand(cmd, params); | 1016 return BaseActiveX::HandleContextMenuCommand(cmd, params); |
1017 | 1017 |
1018 return true; | 1018 return true; |
1019 } | 1019 } |
1020 | 1020 |
1021 HRESULT ChromeActiveDocument::IEExec(const GUID* cmd_group_guid, | 1021 HRESULT ChromeActiveDocument::IEExec(const GUID* cmd_group_guid, |
1022 DWORD command_id, DWORD cmd_exec_opt, | 1022 DWORD command_id, DWORD cmd_exec_opt, |
1023 VARIANT* in_args, VARIANT* out_args) { | 1023 VARIANT* in_args, VARIANT* out_args) { |
1024 HRESULT hr = E_FAIL; | 1024 HRESULT hr = E_FAIL; |
1025 | 1025 |
1026 ScopedComPtr<IOleCommandTarget> frame_cmd_target; | 1026 base::win::ScopedComPtr<IOleCommandTarget> frame_cmd_target; |
1027 | 1027 |
1028 ScopedComPtr<IOleInPlaceSite> in_place_site(m_spInPlaceSite); | 1028 base::win::ScopedComPtr<IOleInPlaceSite> in_place_site(m_spInPlaceSite); |
1029 if (!in_place_site.get() && m_spClientSite != NULL) | 1029 if (!in_place_site.get() && m_spClientSite != NULL) |
1030 in_place_site.QueryFrom(m_spClientSite); | 1030 in_place_site.QueryFrom(m_spClientSite); |
1031 | 1031 |
1032 if (in_place_site) | 1032 if (in_place_site) |
1033 hr = frame_cmd_target.QueryFrom(in_place_site); | 1033 hr = frame_cmd_target.QueryFrom(in_place_site); |
1034 | 1034 |
1035 if (frame_cmd_target) { | 1035 if (frame_cmd_target) { |
1036 hr = frame_cmd_target->Exec(cmd_group_guid, command_id, cmd_exec_opt, | 1036 hr = frame_cmd_target->Exec(cmd_group_guid, command_id, cmd_exec_opt, |
1037 in_args, out_args); | 1037 in_args, out_args); |
1038 } | 1038 } |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 // to update the menu state to indicate that which encoding was set. | 1244 // to update the menu state to indicate that which encoding was set. |
1245 // TODO(iyengar) | 1245 // TODO(iyengar) |
1246 // Do some investigation into why this Exec call fails. | 1246 // Do some investigation into why this Exec call fails. |
1247 IEExec(&CGID_ExplorerBarDoc, command_id, cmd_exec_opt, NULL, NULL); | 1247 IEExec(&CGID_ExplorerBarDoc, command_id, cmd_exec_opt, NULL, NULL); |
1248 return S_OK; | 1248 return S_OK; |
1249 } | 1249 } |
1250 | 1250 |
1251 void ChromeActiveDocument::OnGoToHistoryEntryOffset(int offset) { | 1251 void ChromeActiveDocument::OnGoToHistoryEntryOffset(int offset) { |
1252 DVLOG(1) << __FUNCTION__ << " - offset:" << offset; | 1252 DVLOG(1) << __FUNCTION__ << " - offset:" << offset; |
1253 | 1253 |
1254 ScopedComPtr<IBrowserService> browser_service; | 1254 base::win::ScopedComPtr<IBrowserService> browser_service; |
1255 ScopedComPtr<ITravelLog> travel_log; | 1255 base::win::ScopedComPtr<ITravelLog> travel_log; |
1256 GetBrowserServiceAndTravelLog(browser_service.Receive(), | 1256 GetBrowserServiceAndTravelLog(browser_service.Receive(), |
1257 travel_log.Receive()); | 1257 travel_log.Receive()); |
1258 | 1258 |
1259 if (browser_service && travel_log) | 1259 if (browser_service && travel_log) |
1260 travel_log->Travel(browser_service, offset); | 1260 travel_log->Travel(browser_service, offset); |
1261 } | 1261 } |
1262 | 1262 |
1263 void ChromeActiveDocument::OnMoveWindow(const gfx::Rect& dimensions) { | 1263 void ChromeActiveDocument::OnMoveWindow(const gfx::Rect& dimensions) { |
1264 ScopedComPtr<IWebBrowser2> web_browser2; | 1264 base::win::ScopedComPtr<IWebBrowser2> web_browser2; |
1265 DoQueryService(SID_SWebBrowserApp, m_spClientSite, | 1265 DoQueryService(SID_SWebBrowserApp, m_spClientSite, |
1266 web_browser2.Receive()); | 1266 web_browser2.Receive()); |
1267 if (!web_browser2) | 1267 if (!web_browser2) |
1268 return; | 1268 return; |
1269 DVLOG(1) << "this:" << this << "\ndimensions: width:" << dimensions.width() | 1269 DVLOG(1) << "this:" << this << "\ndimensions: width:" << dimensions.width() |
1270 << " height:" << dimensions.height(); | 1270 << " height:" << dimensions.height(); |
1271 if (!dimensions.IsEmpty()) { | 1271 if (!dimensions.IsEmpty()) { |
1272 web_browser2->put_MenuBar(VARIANT_FALSE); | 1272 web_browser2->put_MenuBar(VARIANT_FALSE); |
1273 web_browser2->put_ToolBar(VARIANT_FALSE); | 1273 web_browser2->put_ToolBar(VARIANT_FALSE); |
1274 | 1274 |
1275 int width = dimensions.width(); | 1275 int width = dimensions.width(); |
1276 int height = dimensions.height(); | 1276 int height = dimensions.height(); |
1277 // Compute the size of the browser window given the desired size of the | 1277 // Compute the size of the browser window given the desired size of the |
1278 // content area. As per MSDN, the WebBrowser object returns an error from | 1278 // content area. As per MSDN, the WebBrowser object returns an error from |
1279 // this method. As a result the code below is best effort. | 1279 // this method. As a result the code below is best effort. |
1280 web_browser2->ClientToWindow(&width, &height); | 1280 web_browser2->ClientToWindow(&width, &height); |
1281 | 1281 |
1282 web_browser2->put_Width(width); | 1282 web_browser2->put_Width(width); |
1283 web_browser2->put_Height(height); | 1283 web_browser2->put_Height(height); |
1284 web_browser2->put_Left(dimensions.x()); | 1284 web_browser2->put_Left(dimensions.x()); |
1285 web_browser2->put_Top(dimensions.y()); | 1285 web_browser2->put_Top(dimensions.y()); |
1286 } | 1286 } |
1287 } | 1287 } |
1288 | 1288 |
1289 HRESULT ChromeActiveDocument::GetBrowserServiceAndTravelLog( | 1289 HRESULT ChromeActiveDocument::GetBrowserServiceAndTravelLog( |
1290 IBrowserService** browser_service, ITravelLog** travel_log) { | 1290 IBrowserService** browser_service, ITravelLog** travel_log) { |
1291 DCHECK(browser_service || travel_log); | 1291 DCHECK(browser_service || travel_log); |
1292 ScopedComPtr<IBrowserService> browser_service_local; | 1292 base::win::ScopedComPtr<IBrowserService> browser_service_local; |
1293 HRESULT hr = DoQueryService(SID_SShellBrowser, m_spClientSite, | 1293 HRESULT hr = DoQueryService(SID_SShellBrowser, m_spClientSite, |
1294 browser_service_local.Receive()); | 1294 browser_service_local.Receive()); |
1295 if (!browser_service_local) { | 1295 if (!browser_service_local) { |
1296 NOTREACHED() << "DoQueryService for IBrowserService failed: " << hr; | 1296 NOTREACHED() << "DoQueryService for IBrowserService failed: " << hr; |
1297 return hr; | 1297 return hr; |
1298 } | 1298 } |
1299 | 1299 |
1300 if (travel_log) { | 1300 if (travel_log) { |
1301 hr = browser_service_local->GetTravelLog(travel_log); | 1301 hr = browser_service_local->GetTravelLog(travel_log); |
1302 DVLOG_IF(1, !travel_log) << "browser_service->GetTravelLog failed: " << hr; | 1302 DVLOG_IF(1, !travel_log) << "browser_service->GetTravelLog failed: " << hr; |
1303 } | 1303 } |
1304 | 1304 |
1305 if (browser_service) | 1305 if (browser_service) |
1306 *browser_service = browser_service_local.Detach(); | 1306 *browser_service = browser_service_local.Detach(); |
1307 | 1307 |
1308 return hr; | 1308 return hr; |
1309 } | 1309 } |
1310 | 1310 |
1311 LRESULT ChromeActiveDocument::OnForward(WORD notify_code, WORD id, | 1311 LRESULT ChromeActiveDocument::OnForward(WORD notify_code, WORD id, |
1312 HWND control_window, | 1312 HWND control_window, |
1313 BOOL& bHandled) { | 1313 BOOL& bHandled) { |
1314 ScopedComPtr<IWebBrowser2> web_browser2; | 1314 base::win::ScopedComPtr<IWebBrowser2> web_browser2; |
1315 DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive()); | 1315 DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive()); |
1316 DCHECK(web_browser2); | 1316 DCHECK(web_browser2); |
1317 | 1317 |
1318 if (web_browser2) | 1318 if (web_browser2) |
1319 web_browser2->GoForward(); | 1319 web_browser2->GoForward(); |
1320 return 0; | 1320 return 0; |
1321 } | 1321 } |
1322 | 1322 |
1323 LRESULT ChromeActiveDocument::OnBack(WORD notify_code, WORD id, | 1323 LRESULT ChromeActiveDocument::OnBack(WORD notify_code, WORD id, |
1324 HWND control_window, | 1324 HWND control_window, |
1325 BOOL& bHandled) { | 1325 BOOL& bHandled) { |
1326 ScopedComPtr<IWebBrowser2> web_browser2; | 1326 base::win::ScopedComPtr<IWebBrowser2> web_browser2; |
1327 DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive()); | 1327 DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive()); |
1328 DCHECK(web_browser2); | 1328 DCHECK(web_browser2); |
1329 | 1329 |
1330 if (web_browser2) | 1330 if (web_browser2) |
1331 web_browser2->GoBack(); | 1331 web_browser2->GoBack(); |
1332 return 0; | 1332 return 0; |
1333 } | 1333 } |
1334 | 1334 |
1335 LRESULT ChromeActiveDocument::OnFirePrivacyChange(UINT message, WPARAM wparam, | 1335 LRESULT ChromeActiveDocument::OnFirePrivacyChange(UINT message, WPARAM wparam, |
1336 LPARAM lparam, | 1336 LPARAM lparam, |
1337 BOOL& handled) { | 1337 BOOL& handled) { |
1338 if (!m_spClientSite) | 1338 if (!m_spClientSite) |
1339 return 0; | 1339 return 0; |
1340 | 1340 |
1341 ScopedComPtr<IWebBrowser2> web_browser2; | 1341 base::win::ScopedComPtr<IWebBrowser2> web_browser2; |
1342 DoQueryService(SID_SWebBrowserApp, m_spClientSite, | 1342 DoQueryService(SID_SWebBrowserApp, m_spClientSite, |
1343 web_browser2.Receive()); | 1343 web_browser2.Receive()); |
1344 if (!web_browser2) { | 1344 if (!web_browser2) { |
1345 NOTREACHED() << "Failed to retrieve IWebBrowser2 interface."; | 1345 NOTREACHED() << "Failed to retrieve IWebBrowser2 interface."; |
1346 return 0; | 1346 return 0; |
1347 } | 1347 } |
1348 | 1348 |
1349 ScopedComPtr<IShellBrowser> shell_browser; | 1349 base::win::ScopedComPtr<IShellBrowser> shell_browser; |
1350 DoQueryService(SID_STopLevelBrowser, web_browser2, | 1350 DoQueryService(SID_STopLevelBrowser, web_browser2, |
1351 shell_browser.Receive()); | 1351 shell_browser.Receive()); |
1352 DCHECK(shell_browser.get() != NULL); | 1352 DCHECK(shell_browser.get() != NULL); |
1353 ScopedComPtr<ITridentService2> trident_services; | 1353 base::win::ScopedComPtr<ITridentService2> trident_services; |
1354 trident_services.QueryFrom(shell_browser); | 1354 trident_services.QueryFrom(shell_browser); |
1355 if (trident_services) | 1355 if (trident_services) |
1356 trident_services->FirePrivacyImpactedStateChange(wparam); | 1356 trident_services->FirePrivacyImpactedStateChange(wparam); |
1357 else | 1357 else |
1358 NOTREACHED() << "Failed to retrieve IWebBrowser2 interface."; | 1358 NOTREACHED() << "Failed to retrieve IWebBrowser2 interface."; |
1359 return 0; | 1359 return 0; |
1360 } | 1360 } |
1361 | 1361 |
1362 LRESULT ChromeActiveDocument::OnShowWindow(UINT message, WPARAM wparam, | 1362 LRESULT ChromeActiveDocument::OnShowWindow(UINT message, WPARAM wparam, |
1363 LPARAM lparam, | 1363 LPARAM lparam, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 return true; | 1401 return true; |
1402 | 1402 |
1403 if (new_navigation_info.url != navigation_info_->url) | 1403 if (new_navigation_info.url != navigation_info_->url) |
1404 return true; | 1404 return true; |
1405 | 1405 |
1406 if (new_navigation_info.referrer != navigation_info_->referrer) | 1406 if (new_navigation_info.referrer != navigation_info_->referrer) |
1407 return true; | 1407 return true; |
1408 | 1408 |
1409 return false; | 1409 return false; |
1410 } | 1410 } |
OLD | NEW |