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

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

Issue 5271011: Avoid double-setting of the tool band ID in the CEEE executors manager.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' 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') | ceee/ie/plugin/toolband/tool_band_unittest.cc » ('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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 _ATL_FUNC_INFO ToolBand::handler_type_idispatch_variantref_ = 50 _ATL_FUNC_INFO ToolBand::handler_type_idispatch_variantref_ =
51 { CC_STDCALL, VT_EMPTY, 2, { VT_DISPATCH, VT_VARIANT | VT_BYREF } }; 51 { CC_STDCALL, VT_EMPTY, 2, { VT_DISPATCH, VT_VARIANT | VT_BYREF } };
52 52
53 ToolBand::ToolBand() 53 ToolBand::ToolBand()
54 : already_tried_installing_(false), 54 : already_tried_installing_(false),
55 own_line_flag_(false), 55 own_line_flag_(false),
56 already_checked_own_line_flag_(false), 56 already_checked_own_line_flag_(false),
57 listening_to_browser_events_(false), 57 listening_to_browser_events_(false),
58 band_id_(0), 58 band_id_(0),
59 is_quitting_(false), 59 is_quitting_(false),
60 already_sent_id_to_bho_(false),
60 current_width_(kToolBandMinWidth), 61 current_width_(kToolBandMinWidth),
61 current_height_(kToolBandHeight) { 62 current_height_(kToolBandHeight) {
62 TRACE_EVENT_BEGIN("ceee.toolband", this, ""); 63 TRACE_EVENT_BEGIN("ceee.toolband", this, "");
63 } 64 }
64 65
65 ToolBand::~ToolBand() { 66 ToolBand::~ToolBand() {
66 TRACE_EVENT_END("ceee.toolband", this, ""); 67 TRACE_EVENT_END("ceee.toolband", this, "");
67 } 68 }
68 69
69 HRESULT ToolBand::FinalConstruct() { 70 HRESULT ToolBand::FinalConstruct() {
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 if (SUCCEEDED(hr2) && bho_iid_access.get() != NULL) { 690 if (SUCCEEDED(hr2) && bho_iid_access.get() != NULL) {
690 CLSID calling_card = {}; 691 CLSID calling_card = {};
691 hr2 = bho_iid_access->GetClassID(&calling_card); 692 hr2 = bho_iid_access->GetClassID(&calling_card);
692 DCHECK(SUCCEEDED(hr2) && calling_card == CLSID_BrowserHelperObject); 693 DCHECK(SUCCEEDED(hr2) && calling_card == CLSID_BrowserHelperObject);
693 } 694 }
694 } 695 }
695 #endif 696 #endif
696 DVLOG(1) << "BHO already loaded"; 697 DVLOG(1) << "BHO already loaded";
697 if (existing_bho.vt != VT_UNKNOWN || existing_bho.punkVal == NULL) 698 if (existing_bho.vt != VT_UNKNOWN || existing_bho.punkVal == NULL)
698 return E_FAIL; 699 return E_FAIL;
699 else 700
700 return SendSessionIdToBho(existing_bho.punkVal); 701 hr = SendSessionIdToBho(existing_bho.punkVal);
702 DCHECK(SUCCEEDED(hr)) << "Failed to send tool band session ID to the " <<
703 "BHO." << com::LogHr(hr);
704 return SUCCEEDED(hr) ? S_OK : hr;
701 } 705 }
702 706
703 ScopedComPtr<IObjectWithSite> bho; 707 ScopedComPtr<IObjectWithSite> bho;
704 hr = CreateBhoInstance(bho.Receive()); 708 hr = CreateBhoInstance(bho.Receive());
705 709
706 if (FAILED(hr)) { 710 if (FAILED(hr)) {
707 NOTREACHED() << "Failed to create CEEE BHO." << com::LogHr(hr); 711 NOTREACHED() << "Failed to create CEEE BHO." << com::LogHr(hr);
708 return hr; 712 return hr;
709 } 713 }
710 714
711 hr = bho->SetSite(web_browser_); 715 hr = bho->SetSite(web_browser_);
712 if (FAILED(hr)) { 716 if (FAILED(hr)) {
713 NOTREACHED() << "CEEE BHO SetSite failed.:" << com::LogHr(hr); 717 NOTREACHED() << "CEEE BHO SetSite failed.:" << com::LogHr(hr);
714 return hr; 718 return hr;
715 } 719 }
716 720
717 hr = web_browser_->PutProperty(bho_class_id_bstr, CComVariant(bho)); 721 hr = web_browser_->PutProperty(bho_class_id_bstr, CComVariant(bho));
718 if (FAILED(hr)) { 722 if (FAILED(hr)) {
719 LOG(ERROR) << "Assigning BHO to the web browser failed." << com::LogHr(hr); 723 LOG(ERROR) << "Assigning BHO to the web browser failed." << com::LogHr(hr);
720 return hr; 724 return hr;
721 } 725 }
722 LOG_IF(INFO, SUCCEEDED(hr)) << "CEEE BHO has been created by the toolband."; 726 LOG_IF(INFO, SUCCEEDED(hr)) << "CEEE BHO has been created by the toolband.";
723 727
724 return SendSessionIdToBho(bho); 728 hr = SendSessionIdToBho(bho);
729 DCHECK(SUCCEEDED(hr)) << "Failed to send tool band session ID to the BHO." <<
730 com::LogHr(hr);
731 return SUCCEEDED(hr) ? S_OK : hr;
725 } 732 }
726 733
727 HRESULT ToolBand::CreateBhoInstance(IObjectWithSite** new_bho_instance) { 734 HRESULT ToolBand::CreateBhoInstance(IObjectWithSite** new_bho_instance) {
728 DCHECK(new_bho_instance != NULL && *new_bho_instance == NULL); 735 DCHECK(new_bho_instance != NULL && *new_bho_instance == NULL);
729 return BrowserHelperObject::CreateInstance(new_bho_instance); 736 return BrowserHelperObject::CreateInstance(new_bho_instance);
730 } 737 }
731 738
732 HRESULT ToolBand::GetSessionId(int* session_id) { 739 HRESULT ToolBand::GetSessionId(int* session_id) {
733 if (chrome_frame_) { 740 if (chrome_frame_) {
734 ScopedComPtr<IChromeFrameInternal> chrome_frame_internal_; 741 ScopedComPtr<IChromeFrameInternal> chrome_frame_internal_;
735 chrome_frame_internal_.QueryFrom(chrome_frame_); 742 chrome_frame_internal_.QueryFrom(chrome_frame_);
736 if (chrome_frame_internal_) { 743 if (chrome_frame_internal_) {
737 return chrome_frame_internal_->getSessionId(session_id); 744 return chrome_frame_internal_->getSessionId(session_id);
738 } 745 }
739 } 746 }
740 NOTREACHED(); 747 NOTREACHED();
741 return E_UNEXPECTED; 748 return E_UNEXPECTED;
742 } 749 }
743 750
744 HRESULT ToolBand::SendSessionIdToBho(IUnknown* bho) { 751 HRESULT ToolBand::SendSessionIdToBho(IUnknown* bho) {
752 if (already_sent_id_to_bho_)
753 return S_FALSE;
745 // Now send the tool band's session ID to the BHO. 754 // Now send the tool band's session ID to the BHO.
746 ScopedComPtr<ICeeeBho> ceee_bho; 755 ScopedComPtr<ICeeeBho> ceee_bho;
747 HRESULT hr = ceee_bho.QueryFrom(bho); 756 HRESULT hr = ceee_bho.QueryFrom(bho);
748 if (SUCCEEDED(hr)) { 757 if (SUCCEEDED(hr)) {
749 int session_id = 0; 758 int session_id = 0;
750 hr = GetSessionId(&session_id); 759 hr = GetSessionId(&session_id);
751 if (SUCCEEDED(hr)) { 760 if (SUCCEEDED(hr)) {
752 return ceee_bho->SetToolBandSessionId(session_id); 761 hr = ceee_bho->SetToolBandSessionId(session_id);
762 if (SUCCEEDED(hr))
763 already_sent_id_to_bho_ = true;
764 return hr;
753 } 765 }
754 } 766 }
755 return E_FAIL; 767 return E_FAIL;
756 } 768 }
OLDNEW
« no previous file with comments | « ceee/ie/plugin/toolband/tool_band.h ('k') | ceee/ie/plugin/toolband/tool_band_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698