Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: ceee/ie/plugin/toolband/tool_band.cc

Issue 6063001: ceee: Include base/win/scope_comptr.h instead of base/scoped_comptr_win.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/ceee
Patch Set: fix chrome_frame Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ceee/ie/plugin/toolband/tool_band.h ('k') | chrome_frame/utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // IE toolband implementation. 5 // IE toolband implementation.
6 #include "ceee/ie/plugin/toolband/tool_band.h" 6 #include "ceee/ie/plugin/toolband/tool_band.h"
7 7
8 #include <atlsafe.h> 8 #include <atlsafe.h>
9 #include <atlstr.h> 9 #include <atlstr.h>
10 #include <shlguid.h> 10 #include <shlguid.h>
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 listening_to_browser_events_ = SUCCEEDED(hr); 280 listening_to_browser_events_ = SUCCEEDED(hr);
281 DCHECK(SUCCEEDED(hr)) << 281 DCHECK(SUCCEEDED(hr)) <<
282 "DispEventAdvise on web browser failed. Error: " << hr; 282 "DispEventAdvise on web browser failed. Error: " << hr;
283 // Non-critical functionality. If fails in the field, just move on. 283 // Non-critical functionality. If fails in the field, just move on.
284 } 284 }
285 285
286 return S_OK; 286 return S_OK;
287 } 287 }
288 288
289 HRESULT ToolBand::InitializeAndShowWindow(IUnknown* site) { 289 HRESULT ToolBand::InitializeAndShowWindow(IUnknown* site) {
290 ScopedComPtr<IOleWindow> site_window; 290 base::win::ScopedComPtr<IOleWindow> site_window;
291 HRESULT hr = site_window.QueryFrom(site); 291 HRESULT hr = site_window.QueryFrom(site);
292 if (FAILED(hr)) { 292 if (FAILED(hr)) {
293 LOG(ERROR) << "Failed to get site window: " << com::LogHr(hr); 293 LOG(ERROR) << "Failed to get site window: " << com::LogHr(hr);
294 return hr; 294 return hr;
295 } 295 }
296 296
297 DCHECK(NULL != site_window.get()); 297 DCHECK(NULL != site_window.get());
298 hr = site_window->GetWindow(&parent_window_.m_hWnd); 298 hr = site_window->GetWindow(&parent_window_.m_hWnd);
299 if (FAILED(hr)) { 299 if (FAILED(hr)) {
300 LOG(ERROR) << "Failed to get parent window handle: " << com::LogHr(hr); 300 LOG(ERROR) << "Failed to get parent window handle: " << com::LogHr(hr);
(...skipping 11 matching lines...) Expand all
312 312
313 return hr; 313 return hr;
314 } 314 }
315 315
316 HRESULT ToolBand::Teardown() { 316 HRESULT ToolBand::Teardown() {
317 TRACE_EVENT_INSTANT("ceee.toolband.teardown", this, ""); 317 TRACE_EVENT_INSTANT("ceee.toolband.teardown", this, "");
318 318
319 if (IsWindow()) { 319 if (IsWindow()) {
320 // Teardown the ActiveX host window. 320 // Teardown the ActiveX host window.
321 CAxWindow host(m_hWnd); 321 CAxWindow host(m_hWnd);
322 ScopedComPtr<IObjectWithSite> host_with_site; 322 base::win::ScopedComPtr<IObjectWithSite> host_with_site;
323 HRESULT hr = host.QueryHost(host_with_site.Receive()); 323 HRESULT hr = host.QueryHost(host_with_site.Receive());
324 if (SUCCEEDED(hr)) 324 if (SUCCEEDED(hr))
325 host_with_site->SetSite(NULL); 325 host_with_site->SetSite(NULL);
326 326
327 DestroyWindow(); 327 DestroyWindow();
328 } 328 }
329 329
330 if (chrome_frame_) { 330 if (chrome_frame_) {
331 ChromeFrameEvents::DispEventUnadvise(chrome_frame_); 331 ChromeFrameEvents::DispEventUnadvise(chrome_frame_);
332 } 332 }
(...skipping 10 matching lines...) Expand all
343 343
344 void ToolBand::OnFinalMessage(HWND window) { 344 void ToolBand::OnFinalMessage(HWND window) {
345 GetUnknown()->Release(); 345 GetUnknown()->Release();
346 } 346 }
347 347
348 LRESULT ToolBand::OnCreate(LPCREATESTRUCT lpCreateStruct) { 348 LRESULT ToolBand::OnCreate(LPCREATESTRUCT lpCreateStruct) {
349 // Grab a self-reference. 349 // Grab a self-reference.
350 GetUnknown()->AddRef(); 350 GetUnknown()->AddRef();
351 351
352 // Create a host window instance. 352 // Create a host window instance.
353 ScopedComPtr<IAxWinHostWindow> host; 353 base::win::ScopedComPtr<IAxWinHostWindow> host;
354 HRESULT hr = CAxHostWindow::CreateInstance(host.Receive()); 354 HRESULT hr = CAxHostWindow::CreateInstance(host.Receive());
355 if (FAILED(hr)) { 355 if (FAILED(hr)) {
356 LOG(ERROR) << "Failed to create ActiveX host window. " << com::LogHr(hr); 356 LOG(ERROR) << "Failed to create ActiveX host window. " << com::LogHr(hr);
357 return 1; 357 return 1;
358 } 358 }
359 359
360 // We're the site for the host window, this needs to be in place 360 // We're the site for the host window, this needs to be in place
361 // before we attach ChromeFrame to the ActiveX control window, so 361 // before we attach ChromeFrame to the ActiveX control window, so
362 // as to allow it to probe our service provider. 362 // as to allow it to probe our service provider.
363 hr = SetChildSite(host); 363 hr = SetChildSite(host);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 // user deleted the extension but the registry stayed the same. 557 // user deleted the extension but the registry stayed the same.
558 already_tried_installing_ = true; 558 already_tried_installing_ = true;
559 chrome_frame_->installExtension(CComBSTR(extension_path_.c_str())); 559 chrome_frame_->installExtension(CComBSTR(extension_path_.c_str()));
560 } else { 560 } else {
561 // Hide the browser bar as fast as we can. 561 // Hide the browser bar as fast as we can.
562 // Set the current height of the bar to 0, so that if the user manually 562 // Set the current height of the bar to 0, so that if the user manually
563 // shows the bar, it will not be visible on screen. 563 // shows the bar, it will not be visible on screen.
564 current_height_ = 0; 564 current_height_ = 0;
565 565
566 // Ask IE to reload all info for this toolband. 566 // Ask IE to reload all info for this toolband.
567 ScopedComPtr<IOleCommandTarget> cmd_target; 567 base::win::ScopedComPtr<IOleCommandTarget> cmd_target;
568 HRESULT hr = GetSite(IID_IOleCommandTarget, 568 HRESULT hr = GetSite(IID_IOleCommandTarget,
569 reinterpret_cast<void**>(cmd_target.Receive())); 569 reinterpret_cast<void**>(cmd_target.Receive()));
570 if (SUCCEEDED(hr)) { 570 if (SUCCEEDED(hr)) {
571 CComVariant band_id(static_cast<int>(band_id_)); 571 CComVariant band_id(static_cast<int>(band_id_));
572 hr = cmd_target->Exec(&CGID_DeskBand, DBID_BANDINFOCHANGED, 572 hr = cmd_target->Exec(&CGID_DeskBand, DBID_BANDINFOCHANGED,
573 OLECMDEXECOPT_DODEFAULT, &band_id, NULL); 573 OLECMDEXECOPT_DODEFAULT, &band_id, NULL);
574 if (FAILED(hr)) { 574 if (FAILED(hr)) {
575 LOG(ERROR) << "Failed to Execute DBID_BANDINFOCHANGED. Error Code: " 575 LOG(ERROR) << "Failed to Execute DBID_BANDINFOCHANGED. Error Code: "
576 << com::LogHr(hr); 576 << com::LogHr(hr);
577 } 577 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 std::hex << hr; 677 std::hex << hr;
678 return hr; 678 return hr;
679 } 679 }
680 680
681 if (existing_bho.vt != VT_EMPTY) { 681 if (existing_bho.vt != VT_EMPTY) {
682 DCHECK(existing_bho.vt == VT_UNKNOWN && existing_bho.punkVal != NULL); 682 DCHECK(existing_bho.vt == VT_UNKNOWN && existing_bho.punkVal != NULL);
683 #ifndef NDEBUG 683 #ifndef NDEBUG
684 if (existing_bho.vt == VT_UNKNOWN && existing_bho.punkVal != NULL) { 684 if (existing_bho.vt == VT_UNKNOWN && existing_bho.punkVal != NULL) {
685 // This is a sanity / assumption check regarding what we should regard 685 // This is a sanity / assumption check regarding what we should regard
686 // as a valid BHO. 686 // as a valid BHO.
687 ScopedComPtr<IPersist> bho_iid_access; 687 base::win::ScopedComPtr<IPersist> bho_iid_access;
688 HRESULT hr2 = bho_iid_access.QueryFrom(existing_bho.punkVal); 688 HRESULT hr2 = bho_iid_access.QueryFrom(existing_bho.punkVal);
689 DCHECK(SUCCEEDED(hr2) && bho_iid_access.get() != NULL); 689 DCHECK(SUCCEEDED(hr2) && bho_iid_access.get() != NULL);
690 if (SUCCEEDED(hr2) && bho_iid_access.get() != NULL) { 690 if (SUCCEEDED(hr2) && bho_iid_access.get() != NULL) {
691 CLSID calling_card = {}; 691 CLSID calling_card = {};
692 hr2 = bho_iid_access->GetClassID(&calling_card); 692 hr2 = bho_iid_access->GetClassID(&calling_card);
693 DCHECK(SUCCEEDED(hr2) && calling_card == CLSID_BrowserHelperObject); 693 DCHECK(SUCCEEDED(hr2) && calling_card == CLSID_BrowserHelperObject);
694 } 694 }
695 } 695 }
696 #endif 696 #endif
697 DVLOG(1) << "BHO already loaded"; 697 DVLOG(1) << "BHO already loaded";
698 if (existing_bho.vt != VT_UNKNOWN || existing_bho.punkVal == NULL) 698 if (existing_bho.vt != VT_UNKNOWN || existing_bho.punkVal == NULL)
699 return E_FAIL; 699 return E_FAIL;
700 700
701 hr = SendSessionIdToBho(existing_bho.punkVal); 701 hr = SendSessionIdToBho(existing_bho.punkVal);
702 DCHECK(SUCCEEDED(hr)) << "Failed to send tool band session ID to the " << 702 DCHECK(SUCCEEDED(hr)) << "Failed to send tool band session ID to the " <<
703 "BHO." << com::LogHr(hr); 703 "BHO." << com::LogHr(hr);
704 return SUCCEEDED(hr) ? S_OK : hr; 704 return SUCCEEDED(hr) ? S_OK : hr;
705 } 705 }
706 706
707 ScopedComPtr<IObjectWithSite> bho; 707 base::win::ScopedComPtr<IObjectWithSite> bho;
708 hr = CreateBhoInstance(bho.Receive()); 708 hr = CreateBhoInstance(bho.Receive());
709 709
710 if (FAILED(hr)) { 710 if (FAILED(hr)) {
711 NOTREACHED() << "Failed to create CEEE BHO." << com::LogHr(hr); 711 NOTREACHED() << "Failed to create CEEE BHO." << com::LogHr(hr);
712 return hr; 712 return hr;
713 } 713 }
714 714
715 hr = bho->SetSite(web_browser_); 715 hr = bho->SetSite(web_browser_);
716 if (FAILED(hr)) { 716 if (FAILED(hr)) {
717 NOTREACHED() << "CEEE BHO SetSite failed.:" << com::LogHr(hr); 717 NOTREACHED() << "CEEE BHO SetSite failed.:" << com::LogHr(hr);
(...skipping 13 matching lines...) Expand all
731 return SUCCEEDED(hr) ? S_OK : hr; 731 return SUCCEEDED(hr) ? S_OK : hr;
732 } 732 }
733 733
734 HRESULT ToolBand::CreateBhoInstance(IObjectWithSite** new_bho_instance) { 734 HRESULT ToolBand::CreateBhoInstance(IObjectWithSite** new_bho_instance) {
735 DCHECK(new_bho_instance != NULL && *new_bho_instance == NULL); 735 DCHECK(new_bho_instance != NULL && *new_bho_instance == NULL);
736 return BrowserHelperObject::CreateInstance(new_bho_instance); 736 return BrowserHelperObject::CreateInstance(new_bho_instance);
737 } 737 }
738 738
739 HRESULT ToolBand::GetSessionId(int* session_id) { 739 HRESULT ToolBand::GetSessionId(int* session_id) {
740 if (chrome_frame_) { 740 if (chrome_frame_) {
741 ScopedComPtr<IChromeFrameInternal> chrome_frame_internal_; 741 base::win::ScopedComPtr<IChromeFrameInternal> chrome_frame_internal_;
742 chrome_frame_internal_.QueryFrom(chrome_frame_); 742 chrome_frame_internal_.QueryFrom(chrome_frame_);
743 if (chrome_frame_internal_) { 743 if (chrome_frame_internal_) {
744 return chrome_frame_internal_->getSessionId(session_id); 744 return chrome_frame_internal_->getSessionId(session_id);
745 } 745 }
746 } 746 }
747 NOTREACHED(); 747 NOTREACHED();
748 return E_UNEXPECTED; 748 return E_UNEXPECTED;
749 } 749 }
750 750
751 HRESULT ToolBand::SendSessionIdToBho(IUnknown* bho) { 751 HRESULT ToolBand::SendSessionIdToBho(IUnknown* bho) {
752 if (already_sent_id_to_bho_) 752 if (already_sent_id_to_bho_)
753 return S_FALSE; 753 return S_FALSE;
754 // Now send the tool band's session ID to the BHO. 754 // Now send the tool band's session ID to the BHO.
755 ScopedComPtr<ICeeeBho> ceee_bho; 755 base::win::ScopedComPtr<ICeeeBho> ceee_bho;
756 HRESULT hr = ceee_bho.QueryFrom(bho); 756 HRESULT hr = ceee_bho.QueryFrom(bho);
757 if (SUCCEEDED(hr)) { 757 if (SUCCEEDED(hr)) {
758 int session_id = 0; 758 int session_id = 0;
759 hr = GetSessionId(&session_id); 759 hr = GetSessionId(&session_id);
760 if (SUCCEEDED(hr)) { 760 if (SUCCEEDED(hr)) {
761 hr = ceee_bho->SetToolBandSessionId(session_id); 761 hr = ceee_bho->SetToolBandSessionId(session_id);
762 if (SUCCEEDED(hr)) 762 if (SUCCEEDED(hr))
763 already_sent_id_to_bho_ = true; 763 already_sent_id_to_bho_ = true;
764 return hr; 764 return hr;
765 } 765 }
766 } 766 }
767 return E_FAIL; 767 return E_FAIL;
768 } 768 }
OLDNEW
« no previous file with comments | « ceee/ie/plugin/toolband/tool_band.h ('k') | chrome_frame/utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698