webengine/osswebengine/WebCore/platform/network/ResourceHandle.cpp
branchRCL_3
changeset 48 79859ed3eea9
parent 47 e1bea15f9a39
child 49 919f36ff910f
equal deleted inserted replaced
47:e1bea15f9a39 48:79859ed3eea9
    31 #include "ResourceHandleClient.h"
    31 #include "ResourceHandleClient.h"
    32 #include "Timer.h"
    32 #include "Timer.h"
    33 #include <algorithm>
    33 #include <algorithm>
    34 
    34 
    35 namespace WebCore {
    35 namespace WebCore {
    36 
       
    37 static const unsigned invalidPortNumber = 0xFFFF;
       
    38 
    36 
    39 ResourceHandle::ResourceHandle(const ResourceRequest& request, ResourceHandleClient* client, bool defersLoading,
    37 ResourceHandle::ResourceHandle(const ResourceRequest& request, ResourceHandleClient* client, bool defersLoading,
    40          bool shouldContentSniff, bool mightDownloadFromHandle)
    38          bool shouldContentSniff, bool mightDownloadFromHandle)
    41     : d(new ResourceHandleInternal(this, request, client, defersLoading, shouldContentSniff, mightDownloadFromHandle))
    39     : d(new ResourceHandleInternal(this, request, client, defersLoading, shouldContentSniff, mightDownloadFromHandle))
    42 {
    40 {
    71     delete timer;
    69     delete timer;
    72 }
    70 }
    73 
    71 
    74 ResourceHandleClient* ResourceHandle::client() const
    72 ResourceHandleClient* ResourceHandle::client() const
    75 {
    73 {
    76     if(d && d->m_client)
    74     return d->m_client;
    77       return d->m_client;
       
    78 	return 0;
       
    79 }
    75 }
    80 
    76 
    81 void ResourceHandle::setClient(ResourceHandleClient* client)
    77 void ResourceHandle::setClient(ResourceHandleClient* client)
    82 {
    78 {
    83     d->m_client = client;
    79     d->m_client = client;
   165         993,  // IMAP+SSL
   161         993,  // IMAP+SSL
   166         995,  // POP3+SSL
   162         995,  // POP3+SSL
   167         2049, // NFS
   163         2049, // NFS
   168         4045, // lockd
   164         4045, // lockd
   169         6000, // X11
   165         6000, // X11
   170         6665, // Alternate IRC [Apple addition] 
       
   171         6666, // Alternate IRC [Apple addition] 
       
   172         6667, // Standard IRC [Apple addition] 
       
   173         6668, // Alternate IRC [Apple addition] 
       
   174         6669, // Alternate IRC [Apple addition] 
       
   175         invalidPortNumber, // Used to block all invalid port numbers
       
   176     };
   166     };
   177     const unsigned short* const blockedPortListEnd = blockedPortList
   167     const unsigned short* const blockedPortListEnd = blockedPortList
   178         + sizeof(blockedPortList) / sizeof(blockedPortList[0]);
   168         + sizeof(blockedPortList) / sizeof(blockedPortList[0]);
   179 
   169 
       
   170 // fixme use the template
   180 #if PLATFORM(SYMBIAN)
   171 #if PLATFORM(SYMBIAN)
   181 	bool found = false;
   172     return true;
   182 
       
   183     for (int i = 0; i < sizeof(blockedPortList) / sizeof(blockedPortList[0]); ++i) {
       
   184         if (blockedPortList[i] == port) {
       
   185            found = true;
       
   186 		   break;
       
   187         }
       
   188 	}
       
   189     // If the port is not in the blocked port list, allow it.
       
   190 	if(!found) return true;
       
   191 
       
   192 #else
   173 #else
   193     // If the port is not in the blocked port list, allow it.
   174     // If the port is not in the blocked port list, allow it.
   194     if (!std::binary_search(blockedPortList, blockedPortListEnd, port))
   175     if (!std::binary_search(blockedPortList, blockedPortListEnd, port))
   195         return true;
   176         return true;
   196 #endif
       
   197 
   177 
   198     // Allow ports 21 and 22 for FTP URLs, as Mozilla does.
   178     // Allow ports 21 and 22 for FTP URLs, as Mozilla does.
   199     if ((port == 21 || port == 22) && request.url().url().startsWith("ftp:", false))
   179     if ((port == 21 || port == 22) && request.url().url().startsWith("ftp:", false))
   200         return true;
   180         return true;
   201 
   181 
   202     // Allow any port number in a file URL, since the port number is ignored.
   182     // Allow any port number in a file URL, since the port number is ignored.
   203     if (request.url().url().startsWith("file:", false))
   183     if (request.url().url().startsWith("file:", false))
   204         return true;
   184         return true;
   205 
   185 
   206     return false;
   186     return false;
       
   187 #endif
   207 }
   188 }
   208   
   189   
   209 } // namespace WebCore
   190 } // namespace WebCore