15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2011 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef PPAPI_CPP_DEV_URL_UTIL_DEV_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PPAPI_CPP_DEV_URL_UTIL_DEV_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_url_util_dev.h" 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/cpp/var.h" 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace pp { 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class InstanceHandle; 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Simple wrapper around the PPB_URLUtil interface. 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class URLUtil_Dev { 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This class is just a collection of random functions that aren't 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // particularly attached to anything. So this getter returns a cached 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // instance of this interface. This may return NULL if the browser doesn't 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // support the URLUtil interface. Since this is a singleton, don't delete the 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // pointer. 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static const URLUtil_Dev* Get(); 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Var Canonicalize(const Var& url, 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PP_URLComponents_Dev* components = NULL) const; 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Var ResolveRelativeToURL(const Var& base_url, 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const Var& relative_string, 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PP_URLComponents_Dev* components = NULL) const; 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Var ResolveRelativeToDocument(const InstanceHandle& instance, 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const Var& relative_string, 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PP_URLComponents_Dev* components = NULL) const; 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool IsSameSecurityOrigin(const Var& url_a, const Var& url_b) const; 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool DocumentCanRequest(const InstanceHandle& instance, const Var& url) const; 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool DocumentCanAccessDocument(const InstanceHandle& active, 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const InstanceHandle& target) const; 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Var GetDocumentURL(const InstanceHandle& instance, 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PP_URLComponents_Dev* components = NULL) const; 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Var GetPluginInstanceURL(const InstanceHandle& instance, 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PP_URLComponents_Dev* components = NULL) const; 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) URLUtil_Dev() : interface_(NULL) {} 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Copy and assignment are disallowed. 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) URLUtil_Dev(const URLUtil_Dev& other); 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) URLUtil_Dev& operator=(const URLUtil_Dev& other); 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const PPB_URLUtil_Dev* interface_; 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace pp 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // PPAPI_CPP_DEV_URL_UTIL_DEV_H_ 58