Ejemplo n.º 1
0
void
HttpRequest::Open (const char *verb, Uri *uri, DownloaderAccessPolicy policy)
{
    Surface *surface;
    Application *application;
    const char *source_location;
    Uri *src_uri = NULL;

    VERIFY_MAIN_THREAD;
    LOG_DOWNLOADER ("HttpRequest::Open (%s, %p = %s, %i)\n", verb, uri, uri == NULL ? NULL : uri->ToString (), policy);

    g_free (this->verb);
    delete original_uri;
    g_free (this->uri);

    this->verb = g_strdup (verb);
    this->original_uri = new Uri (*uri);
    this->uri = uri->ToString ();

    access_policy = policy;

    surface = GetDeployment ()->GetSurface ();
    application = GetDeployment ()->GetCurrentApplication ();

    if (application->IsRunningOutOfBrowser ()) {
        source_location = surface->GetSourceLocation ();
    } else {
        source_location = GetDeployment ()->GetXapLocation ();
        if (source_location == NULL)
            source_location = surface->GetSourceLocation ();
    }

    // FIXME: ONLY VALIDATE IF USED FROM THE PLUGIN
    if (!Downloader::ValidateDownloadPolicy (source_location, uri, policy)) {
        LOG_DOWNLOADER ("HttpRequest::Open (): aborting due to security policy violation\n");
        Failed ("Security Policy Violation");
        Abort ();
        return;
    }

    /* Make the uri we request to the derived http request an absolute uri */
    if (!uri->isAbsolute && source_location) {
        src_uri = new Uri ();
        if (!src_uri->Parse (source_location, true)) {
            Failed ("Could not parse source location");
            delete src_uri;
            return;
        }

        src_uri->Combine (uri);
        g_free (this->uri);
        this->uri = src_uri->ToString ();
        delete src_uri;
        LOG_DOWNLOADER ("HttpRequest::Open (%s, %p = %s, %i) Url was absolutified to '%s' using source location '%s'\n", verb, uri, uri == NULL ? NULL : uri->ToString (), policy, this->uri, source_location);
    }

    OpenImpl ();
}
Ejemplo n.º 2
0
bool
BitmapImage::ValidateDownloadPolicy ()
{
	Surface *surface = Deployment::GetCurrent ()->GetSurface ();
	Uri *uri = GetUriSource ();
	const char *location;
	
	if (!uri)
		return true;
	
	if (!(location = GetDeployment ()->GetXapLocation ()))
		location = surface ? surface->GetSourceLocation () : NULL;
	
	return Downloader::ValidateDownloadPolicy (location, uri, policy);
}
Ejemplo n.º 3
0
bool
Consent::PromptUserFor (MoonConsentType consent)
{
	Surface *surface = Deployment::GetCurrent ()->GetSurface ();
	const char *source = surface->GetSourceLocation ();

	Uri *uri = new Uri ();
	uri->Parse (source);

	char *website = ((uri->GetPort () > 0)
			 ? g_strdup_printf ("%s://%s:%d",
					    uri->GetScheme(),
					    uri->GetHost(),
					    uri->GetPort())
			 : g_strdup_printf ("%s://%s",
					    uri->GetScheme(),
					    uri->GetHost()));

	const char *question, *detail;

	switch (consent) {
	case MOON_CONSENT_CLIPBOARD:
		question = "Do you want to allow this application to access your clipboard?";
		detail = "If you allow this, the application can copy data to and from the Clipboard as long as the application is running.";
		break;
	case MOON_CONSENT_FULLSCREEN_PINNING:
		question = "[fullscreen question here]"; // FIXME
		detail = "[fullscreen detail here]"; // FIXME
		break;
	case MOON_CONSENT_CAPTURE:
		question = "Do you want to allow this application to access your webcam and microphone?";
		detail = "If you allow this, the application can capture video and audio as long as the application is running.";
		break;
	case MOON_CONSENT_LAST:
		// should't be reached...
		question = detail = NULL;
		break;
	}

	return PromptUserFor (consent, question, detail, website);
}