コード例 #1
0
//----------------------------------------------------------------------------
//
STDMETHODIMP CAnchoAddonService::getDispatchObject(IDispatch **aRet)
{
  ENSURE_RETVAL(aRet);
  *aRet = static_cast<IDispatch*>(this);
  AddRef();
  return S_OK;
}
コード例 #2
0
//----------------------------------------------------------------------------
//
STDMETHODIMP CAnchoAddonService::getBrowserActions(VARIANT* aBrowserActionsArray)
{
  ENSURE_RETVAL(aBrowserActionsArray);

  CComVariant tmp(m_BrowserActionInfos.p);
  return tmp.Detach(aBrowserActionsArray);
}
コード例 #3
0
//----------------------------------------------------------------------------
//  GetMemberName
HRESULT CDispExIdManager::GetMemberName(
  DISPID  id,
  BSTR  * pbstrName)
{
  ENSURE_RETVAL(pbstrName);
  CString sName;
#ifdef CDispExIdManager_USE_REVERSELOOKUPMAP
  if (m_Names.Lookup(id, sName))
  {
    (*pbstrName) = sName.AllocSysString();
    return S_OK;
  }
#else
  DISPID dispid;

  POSITION pos = m_IDs.GetStartPosition();
  while(pos)
  {
    m_IDs.GetNextAssoc(pos, sName, dispid);
    if (dispid == id)
    {
      (*pbstrName) = sName.AllocSysString();
      return S_OK;
    }
  }
#endif
  return DISP_E_UNKNOWNNAME;
}
コード例 #4
0
//----------------------------------------------------------------------------
//
HRESULT CAnchoAddonService::queryTabs(LPDISPATCH aQueryInfo, LPDISPATCH aCreator, VARIANT* aRet)
{
  ENSURE_RETVAL(aRet);
  struct QueryTabFunctor
  {
    QueryTabFunctor(VariantVector &aInfos, LPDISPATCH aCreator, CAnchoAddonService &aService ): infos(aInfos), creator(aCreator), service(aService) {}
    void operator()(RuntimeMap::value_type &aRec)
    {
      CComVariant info;
      /*if (S_OK != createIDispatchFromCreator(creator, &info)) {
        return;
      }*/
      if (S_OK == service.getTabInfo(aRec.first, creator, &info)) {
        infos.push_back(info);
      }
    }
    VariantVector &infos;
    LPDISPATCH creator;
    CAnchoAddonService &service;
  };


  VariantVector infos;

  {
    CSLock lock(mRuntimesCriticalSection);
    std::for_each(m_Runtimes.begin(), m_Runtimes.end(), QueryTabFunctor(infos, aCreator, *this));
  }
  return constructSafeArrayFromVector(infos, *aRet);
}
コード例 #5
0
ファイル: MagpieModule.cpp プロジェクト: ondravondra/adobo-ie
//----------------------------------------------------------------------------
//  get_id
STDMETHODIMP CMagpieModule::get_id(
  VARIANT* pVal)
{
  ENSURE_RETVAL(pVal);
  pVal->vt = VT_BSTR;
  pVal->bstrVal = m_sID.AllocSysString();
  return S_OK;
}
コード例 #6
0
ファイル: MagpieModule.cpp プロジェクト: ondravondra/adobo-ie
//----------------------------------------------------------------------------
//  GetExports
HRESULT CMagpieModule::GetExports(VARIANT * pvtExports)
{
  ENSURE_RETVAL(pvtExports);
  ATLASSERT(m_pApplication);
  CIDispatchHelper script;
  IF_FAILED_RET(m_pApplication->GetScriptEngine().GetScriptDispatch(m_sID, &script));
  return script.GetPropertyByName(L"exports", pvtExports);
}
コード例 #7
0
//----------------------------------------------------------------------------
//
STDMETHODIMP CAnchoAddonService::getCurrentWindowId(INT *aWinId)
{
  ENSURE_RETVAL(aWinId);
  HWND hwnd = getCurrentWindowHWND();
  if (hwnd) {
    *aWinId = winHWNDToId(hwnd);
    return S_OK;
  }
  return E_FAIL;
}
コード例 #8
0
//----------------------------------------------------------------------------
//  GetModuleObject
STDMETHODIMP CMagpieApplication::GetModuleObject(const OLECHAR* lpszModuleID, IMagpieModuleRestricted ** ppRet)
{
  ENSURE_RETVAL(ppRet);
  CComPtr<IMagpieModule> module;
  if (!m_Modules.Lookup(lpszModuleID, module))
  {
    return E_FAIL;
  }
  return module.QueryInterface(ppRet);
}
コード例 #9
0
//----------------------------------------------------------------------------
// getToolBar
//  Return toolbar as a variant. Can return empty value with S_FALSE.
HRESULT Proxy::getToolBar(VARIANT * aRetVal) {
  ENSURE_RETVAL(aRetVal);
  VariantInit(aRetVal);
  if (!mPageActionToolbar) {
    return S_FALSE;
  }
  HRESULT hr = mPageActionToolbar.QueryInterface(&aRetVal->pdispVal);
  if (SUCCEEDED(hr)) {
    aRetVal->vt = VT_DISPATCH;
  }
  return hr;
}
コード例 #10
0
//----------------------------------------------------------------------------
//
HRESULT CAnchoAddonService::invokeExternalEventObject(BSTR aExtensionId, BSTR aEventName, LPDISPATCH aArgs, VARIANT* aRet)
{
  ENSURE_RETVAL(aRet);
  CAnchoAddonBackgroundComObject* pObject = NULL;

  BackgroundObjectsMap::iterator it = m_BackgroundObjects.find(std::wstring(aExtensionId, SysStringLen(aExtensionId)));
  if (it != m_BackgroundObjects.end()) {
    ATLASSERT(it->second != NULL);
    return it->second->invokeExternalEventObject(aEventName, aArgs, aRet);
  }
  return S_OK;
}
コード例 #11
0
//----------------------------------------------------------------------------
//
STDMETHODIMP CAnchoAddonService::registerBrowserActionToolbar(INT aFrameTab, BSTR * aUrl, INT*aTabId)
{
  ENSURE_RETVAL(aUrl);

  *aTabId = getFrameTabID(aFrameTab);

  WCHAR   appPath[MAX_PATH] = {0};
  GetModuleFileNameW(NULL, appPath, _countof(appPath));

  CString url;
  url.Format(L"res://%s/BROWSER_ACTION_TOOLBAR.HTML", appPath);
  *aUrl = url.AllocSysString();
  ATLTRACE(L"ANCHO SERVICE: registered browser action toolbar; tab: %d\n", *aTabId);
  return S_OK;
}
コード例 #12
0
ファイル: LogWindow.cpp プロジェクト: digital-carver/ancho
HRESULT CLogWindow::CreateLogWindow(CLogWindowComObject ** ppRet)
{
  ENSURE_RETVAL(ppRet);
  (*ppRet) = NULL;
  CLogWindowComObject * pNewWindow = NULL;
  IF_FAILED_RET(CLogWindowComObject::CreateInstance(&pNewWindow));
  pNewWindow->AddRef();
  if (!pNewWindow->CreateEx())
  {
    pNewWindow->Release();
    return E_FAIL;
  }
  pNewWindow->ShowWindow(SW_SHOW);
  (*ppRet) = pNewWindow;
  return S_OK;
}
コード例 #13
0
STDMETHODIMP CSalsitaFramework::createXMLHTTPRequest(IDispatch** ppVal)
{
  ENSURE_RETVAL(ppVal);

  CComPtr<IXMLHttpRequest> pRequest;
  IF_FAILED_RET(pRequest.CoCreateInstance(__uuidof(XMLHTTPRequest)));

  // try to add the security object
  HRESULT hrAddSecurity = AddCustomInternetSecurity(pRequest);

  IF_FAILED_RET(pRequest->QueryInterface(IID_IDispatch, (void**)ppVal));

  if (FAILED(hrAddSecurity)) // if we fail to add the security object, return the XMLHTTPRequest anyway
  {
    return S_FALSE;
  } else {
    return S_OK;
  }
}
コード例 #14
0
ファイル: BackgroundWindow.cpp プロジェクト: msarvar/ancho
HRESULT CBackgroundWindow::CreateBackgroundWindow(const DispatchMap &aInjectedObjects, LPCWSTR lpszURL, CBackgroundWindowComObject ** ppRet)
{
  ENSURE_RETVAL(ppRet);
  (*ppRet) = NULL;
  CBackgroundWindowComObject * pNewWindow = NULL;
  IF_FAILED_RET(CBackgroundWindowComObject::CreateInstance(&pNewWindow));
  pNewWindow->AddRef();
  pNewWindow->m_sURL = lpszURL;
  pNewWindow->m_InjectedObjects = aInjectedObjects;
  RECT r = {0,0,0,0};
  if (!pNewWindow->Create(NULL, r, NULL, WS_POPUP))
  {
    pNewWindow->Release();
    return E_FAIL;
  }
  pNewWindow->ShowWindow(SW_HIDE);
  (*ppRet) = pNewWindow;
  return S_OK;
}
コード例 #15
0
ファイル: AnchoBackgroundAPI.cpp プロジェクト: bver/ancho
//----------------------------------------------------------------------------
//  
HRESULT CAnchoBackgroundAPI::GetContentAPI(ULONG ulInstanceID, LPDISPATCH* ppDisp)
{
  ENSURE_RETVAL(ppDisp);
  if (!m_Magpie)
  {
    return E_UNEXPECTED;
  }

  CIDispatchHelper script;
  IF_FAILED_RET(GetMainModuleExportsScript(script));

  CComVariant vtRet, vtInstanceID(ulInstanceID);
  DISPPARAMS params = {&vtInstanceID, NULL, 1, 0};
  IF_FAILED_RET(script.Call((LPOLESTR)s_AnchoFnGetContentAPI, &params, &vtRet));
  if (vtRet.vt != VT_DISPATCH)
  {
    return E_FAIL;
  }
  return vtRet.pdispVal->QueryInterface(IID_IDispatch, (void**)ppDisp);
}
コード例 #16
0
//----------------------------------------------------------------------------
//
HRESULT CAnchoAddonService::getTabInfo(INT aTabId, LPDISPATCH aCreator, VARIANT* aRet)
{
  ENSURE_RETVAL(aRet);
  CComVariant result;
  HRESULT hr = createIDispatchFromCreator(aCreator, &result);
  if (hr != S_OK) {
    return hr;
  }
  CSLock lock(mRuntimesCriticalSection);
  RuntimeMap::iterator it = m_Runtimes.find(aTabId);
  if (it != m_Runtimes.end()) {
    ATLASSERT(it->second.runtime);
    hr = it->second.runtime->fillTabInfo(&result);
    if (hr == S_OK) {
      VariantCopy(aRet, &result);
    }
  } else {
    VariantClear(aRet);
  }
  return hr;
}
コード例 #17
0
//----------------------------------------------------------------------------
//
STDMETHODIMP CAnchoAddonService::registerRuntime(INT aFrameTab, IAnchoRuntime * aRuntime, ULONG aHeartBeat, INT *aTabID)
{
  if (aFrameTab == 0) {
    return E_FAIL;
  }
  ENSURE_RETVAL(aTabID);

  *aTabID = getFrameTabID(aFrameTab);

  {
    CSLock lock(mRuntimesCriticalSection);
    m_Runtimes[*aTabID] = RuntimeRecord(aRuntime, aHeartBeat);
  }
  ATLTRACE(L"ADDON SERVICE - registering tab: %d\n", *aTabID);

  if (!mBHOHeartbeatTimer.isRunning()) {
    mBHOHeartbeatTimer.initialize(&CAnchoAddonService::checkBHOConnections, this, 1000);
    mShouldCheckBHOConnections = true;
  }
  return S_OK;
}
コード例 #18
0
//----------------------------------------------------------------------------
//
STDMETHODIMP CAnchoAddonService::GetAddonBackground(BSTR bsID, IAnchoAddonBackground ** ppRet)
{
  ENSURE_RETVAL(ppRet);

  CComPtr<IAnchoAddonBackground> ptr;
  std::wstring id = std::wstring(bsID, SysStringLen(bsID));
  BackgroundObjectsMap::iterator it = m_BackgroundObjects.find(id);
  if (it == m_BackgroundObjects.end()) {
    // not found, create new instance
    ATLTRACE(_T("ADD OBJECT %s\n"), bsID);
    CAnchoAddonBackgroundComObject* pObject = NULL;
    HRESULT hr = CAnchoAddonBackgroundComObject::CreateInstance(&pObject);
    if (FAILED(hr))
    {
      return hr;
    }
    // store to a safepointer
    ptr = pObject;

    ///////////////////////////////////////////////////////
    // Init the whole addon. This will load and init the
    // Ancho api.
    hr = pObject->Init(m_sThisPath, this, static_cast<IAnchoServiceApi*>(this), bsID);
    if (FAILED(hr))
    {
      return hr;
    }
    // store in map
    m_BackgroundObjects[id] = pObject;
  } else {
    ATLTRACE(_T("FOUND OBJECT %s\n"), bsID);
    // found, create a new intance ID
    // store to safepointer
    ptr = it->second;
  }

  // set return value
  (*ppRet) = ptr.Detach();
  return S_OK;
}
コード例 #19
0
//----------------------------------------------------------------------------
//
STDMETHODIMP CAnchoAddonService::getWindow(INT aWindowId, LPDISPATCH aCreator, BOOL aPopulate, VARIANT* aRet)
{
  if (!aCreator) {
    return E_POINTER;
  }
  ENSURE_RETVAL(aRet);

  HWND hwnd = winIdToHWND(aWindowId);

  if (!isIEWindow(hwnd)) {
    return E_INVALIDARG;
  }

  CComVariant info;
  if (S_OK != createIDispatchFromCreator(aCreator, &info)) {
    return E_FAIL;
  }
  CIDispatchHelper infoHelper(info.pdispVal);
  fillWindowInfo(hwnd, infoHelper);
  *aRet = info;
  return S_OK;
}
コード例 #20
0
//----------------------------------------------------------------------------
//
STDMETHODIMP CAnchoAddonService::getAllWindows(LPDISPATCH aCreator, BOOL aPopulate, VARIANT* aRet)
{
  if (!aCreator) {
    return E_POINTER;
  }
  ENSURE_RETVAL(aRet);

  VariantVector windowInfos;
  HWND hIEFrame = NULL;
  do {
    hIEFrame = ::FindWindowEx(NULL, hIEFrame, L"IEFrame", NULL);
    if (hIEFrame) {
      CComVariant info;
      if (S_OK != createIDispatchFromCreator(aCreator, &info)) {
        return E_FAIL;
      }
      CIDispatchHelper infoHelper(info.pdispVal);
      fillWindowInfo(hIEFrame, infoHelper);

      windowInfos.push_back(info);
    }
  }while(hIEFrame);
  return constructSafeArrayFromVector(windowInfos, *aRet);
}
コード例 #21
0
//----------------------------------------------------------------------------
//
STDMETHODIMP CAnchoAddonService::GetModulePath(BSTR * pbsPath)
{
  ENSURE_RETVAL(pbsPath);
  (*pbsPath) = m_sThisPath.AllocSysString();
  return S_OK;
}
コード例 #22
0
ファイル: AnchoBackgroundAPI.cpp プロジェクト: bver/ancho
//----------------------------------------------------------------------------
//  
STDMETHODIMP CAnchoBackgroundAPI::get_guid(BSTR * pVal)
{
  ENSURE_RETVAL(pVal);
  (*pVal) = m_GUID.AllocSysString();
  return S_OK;
}
コード例 #23
0
STDMETHODIMP CMagpieApplication::CreateSalsitaContentApiImplementation(LPUNKNOWN pClientSite, LPDISPATCH *pContentApi)
{
  ENSURE_RETVAL(pContentApi);
  return CSalsitaContentApi::Create(*pContentApi, pClientSite);
}
コード例 #24
0
//----------------------------------------------------------------------------
//
HRESULT CAnchoAddonService::get_cookieManager(LPDISPATCH* ppRet)
{
  ENSURE_RETVAL(ppRet);
  return m_Cookies.QueryInterface(ppRet);
}
コード例 #25
0
ファイル: AnchoBackgroundAPI.cpp プロジェクト: bver/ancho
//----------------------------------------------------------------------------
//  
STDMETHODIMP CAnchoBackgroundAPI::get_id(BSTR * pVal)
{
  ENSURE_RETVAL(pVal);
  return m_bsID.CopyTo(pVal);
}