WebNavigationData.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Copyright (C) 2009 Apple Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
  14. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
  17. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  18. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  20. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  21. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #include "config.h"
  26. #include "WebKitDLL.h"
  27. #include "WebNavigationData.h"
  28. using namespace WebCore;
  29. // IUnknown -------------------------------------------------------------------
  30. HRESULT STDMETHODCALLTYPE WebNavigationData::QueryInterface(REFIID riid, void** ppvObject)
  31. {
  32. *ppvObject = 0;
  33. if (IsEqualGUID(riid, IID_IUnknown))
  34. *ppvObject = static_cast<IWebNavigationData*>(this);
  35. else if (IsEqualGUID(riid, IID_IWebNavigationData))
  36. *ppvObject = static_cast<IWebNavigationData*>(this);
  37. else
  38. return E_NOINTERFACE;
  39. AddRef();
  40. return S_OK;
  41. }
  42. ULONG STDMETHODCALLTYPE WebNavigationData::AddRef(void)
  43. {
  44. return ++m_refCount;
  45. }
  46. ULONG STDMETHODCALLTYPE WebNavigationData::Release(void)
  47. {
  48. ULONG newRef = --m_refCount;
  49. if (!newRef)
  50. delete(this);
  51. return newRef;
  52. }
  53. // WebNavigationData -------------------------------------------------------------------
  54. WebNavigationData::WebNavigationData(const String& url, const String& title, IWebURLRequest* request, IWebURLResponse* response, bool hasSubstituteData, const String& clientRedirectSource)
  55. : m_refCount(0)
  56. , m_url(url)
  57. , m_title(title)
  58. , m_request(request)
  59. , m_response(response)
  60. , m_hasSubstituteData(hasSubstituteData)
  61. , m_clientRedirectSource(clientRedirectSource)
  62. {
  63. gClassCount++;
  64. gClassNameCount.add("WebNavigationData");
  65. }
  66. WebNavigationData::~WebNavigationData()
  67. {
  68. gClassCount--;
  69. gClassNameCount.remove("WebNavigationData");
  70. }
  71. WebNavigationData* WebNavigationData::createInstance(const String& url, const String& title, IWebURLRequest* request, IWebURLResponse* response, bool hasSubstituteData, const String& clientRedirectSource)
  72. {
  73. WebNavigationData* instance = new WebNavigationData(url, title, request, response, hasSubstituteData, clientRedirectSource);
  74. instance->AddRef();
  75. return instance;
  76. }
  77. // IWebNavigationData -------------------------------------------------------------------
  78. HRESULT WebNavigationData::url(BSTR* url)
  79. {
  80. if (!url)
  81. return E_POINTER;
  82. *url = BString(m_url).release();
  83. return S_OK;
  84. }
  85. HRESULT WebNavigationData::title(BSTR* title)
  86. {
  87. if (!title)
  88. return E_POINTER;
  89. *title = BString(m_title).release();
  90. return S_OK;
  91. }
  92. HRESULT WebNavigationData::originalRequest(IWebURLRequest** request)
  93. {
  94. if (!request)
  95. return E_POINTER;
  96. *request = m_request.get();
  97. m_request->AddRef();
  98. return S_OK;
  99. }
  100. HRESULT WebNavigationData::response(IWebURLResponse** response)
  101. {
  102. if (!response)
  103. return E_POINTER;
  104. *response = m_response.get();
  105. m_response->AddRef();
  106. return S_OK;
  107. }
  108. HRESULT WebNavigationData::hasSubstituteData(BOOL* hasSubstituteData)
  109. {
  110. if (!hasSubstituteData)
  111. return E_POINTER;
  112. *hasSubstituteData = m_hasSubstituteData;
  113. return S_OK;
  114. }
  115. HRESULT WebNavigationData::clientRedirectSource(BSTR* clientRedirectSource)
  116. {
  117. if (!clientRedirectSource)
  118. return E_POINTER;
  119. *clientRedirectSource = BString(m_clientRedirectSource).release();
  120. return S_OK;
  121. }