NS_IMETHODIMP nsMailboxService::OpenAttachment(const char *aContentType, 
                                               const char *aFileName,
                                               const char *aUrl, 
                                               const char *aMessageUri, 
                                               nsISupports *aDisplayConsumer, 
                                               nsIMsgWindow *aMsgWindow, 
                                               nsIUrlListener *aUrlListener)
{
  nsCOMPtr <nsIURI> URL;
  nsCAutoString urlString(aUrl);
  urlString += "&type=";
  urlString += aContentType;
  urlString += "&filename=";
  urlString += aFileName;
  CreateStartupUrl(urlString.get(), getter_AddRefs(URL));
  nsresult rv;
  // try to run the url in the docshell...
  nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aDisplayConsumer, &rv));
  // if we were given a docShell, run the url in the docshell..otherwise just run it normally.
  if (NS_SUCCEEDED(rv) && docShell)
  {
    nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
    // DIRTY LITTLE HACK --> since we are opening an attachment we want the docshell to
    // treat this load as if it were a user click event. Then the dispatching stuff will be much
    // happier.
    docShell->CreateLoadInfo(getter_AddRefs(loadInfo));
    loadInfo->SetLoadType(nsIDocShellLoadInfo::loadLink);
    return docShell->LoadURI(URL, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, PR_FALSE);
  }
  return RunMailboxUrl(URL, aDisplayConsumer); 
  
}
Exemple #2
0
int TestURLChars(void)
{
  // Number of tests
  int errors = 2; 

  CString urlString("http://" MARLIN_HOST "/Marlin Test all/URL?first=abc&second=באהגיטכךםלןמףעצפתש��‎�חסץד");
  CString mustBeUrl("http://" MARLIN_HOST "/Marlin%20Test%20all/URL?first=abc&second=%C3%A1%C3%A0%C3%A4%C3%A2%C3%A9%C3%A8%C3%AB%C3%AA%C3%AD%C3%AC%C3%AF%C3%AE%C3%B3%C3%B2%C3%B6%C3%B4%C3%BA%C3%B9%C3%BC%C3%BB%C3%BD%C3%BF%C3%A7%C3%B1%C3%B5%C3%A3");
  CrackedURL url1(urlString);
  CString encoded = url1.URL();

  // Test if success
  if(encoded == mustBeUrl)
  {
    --errors;
  }

  // Encoding of higher order UTF-8 like the euro signs
  urlString = "http://" MARLIN_HOST "/Een%20Twee%20drie?een=waarde=%3Crequest%3E%3Cpage%3Eklantenkaart%3C%2Fpage%3E%3Crequesttype%3Econtactmemoaanmaken%3C%2Frequesttype%3E%3Ccallback%3EdesktopCallback%3C%2Fcallback%3E%3Cparameters%3E%3Cparameter%3E%3Cname%3Econtactmemogegevens%3C%2Fname%3E%3Cvalue%3E%7B%22contact_id%22:151714,%22eerste_contact_id%22:151714,%22werknemer_id%22:2942,%22werknemer_naam%22:%22N.N.+Bhoera%22,%22beheerorgnaam%22:%22Edwin%22,%22richting%22:%22uit%22,%22onderwerp%22:%22H%C3%AF%C3%ABr+st%C3%A4%C3%A4n+%E2%82%AC+test%22%7D%3C%2Fvalue%3E%3C%2Fparameter%3E%3C%2Fparameters%3E%3C%2Frequest%3E";
  CrackedURL url2(urlString);
  encoded = url2.URL();

  // Test if success
  if(urlString == encoded)
  {
    --errors;
  }

  // SUMMARY OF THE TEST
  // --- "---------------------------------------------- - ------
  printf("Testing URL %% encoding and Unicode chars       : %s\n",errors ? "ERROR" : "OK");

  return errors;
}
QDataStream& WebCore::HistoryItem::saveState(QDataStream& out, int version) const
{
    // we only support version 1 for now.
    if (version != 1)
        return out;

    out << urlString() << title() << alternateTitle() << lastVisitedTime();
    out << originalURLString() << referrer() << target() << parent();
    out << lastVisitWasHTTPNonGet() << lastVisitWasFailure() << isTargetItem();
    out << visitCount() << documentState() << scrollPoint();
    out << dailyVisitCounts() << weeklyVisitCounts();
    /*if (m_formData) {
        out << true;
        out << formContentType();
        out << m_formData->flatten();
    } else {
        out << false;
    }*/
    // save user data
    if (userData().isValid())
        out << true << userData();
    else
        out << false;

    return out;
}
void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
{
    Q_D(WebContentsAdapter);
    QByteArray encodedData = data.toPercentEncoding();
    std::string urlString("data:");
    urlString.append(mimeType.toStdString());
    urlString.append(",");
    urlString.append(encodedData.constData(), encodedData.length());

    GURL dataUrlToLoad(urlString);
    if (dataUrlToLoad.spec().size() > content::GetMaxURLChars()) {
        d->adapterClient->loadFinished(false, baseUrl, false, net::ERR_ABORTED);
        return;
    }
    content::NavigationController::LoadURLParams params((dataUrlToLoad));
    params.load_type = content::NavigationController::LOAD_TYPE_DATA;
    params.base_url_for_data_url = toGurl(baseUrl);
    params.virtual_url_for_data_url = baseUrl.isEmpty() ? GURL(url::kAboutBlankURL) : toGurl(baseUrl);
    params.can_load_local_resources = true;
    params.transition_type = ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_API);
    params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
    d->webContents->GetController().LoadURLWithParams(params);
    d->webContents->Focus();
    d->webContents->Unselect();
}
Exemple #5
0
void IconController::startLoader()
{
    // FIXME: We kick off the icon loader when the frame is done receiving its main resource.
    // But we should instead do it when we're done parsing the head element.
    if (!m_frame->loader()->isLoadingMainFrame())
        return;

    if (!iconDatabase().isEnabled())
        return;

    ASSERT(!m_frame->tree()->parent());
    if (!documentCanHaveIcon(m_frame->document()->url()))
        return;

    KURL iconURL(url());
    String urlString(iconURL.string());
    if (urlString.isEmpty())
        return;

    // People who want to avoid loading images generally want to avoid loading all images, unless an exception has been made for site icons.
    // Now that we've accounted for URL mapping, avoid starting the network load if images aren't set to display automatically.
    Settings* settings = m_frame->settings();
    if (settings && !settings->loadsImagesAutomatically() && !settings->loadsSiteIconsIgnoringImageLoadingSetting())
        return;

    // If we're reloading the page, always start the icon load now.
    // FIXME: How can this condition ever be true?
    if (m_frame->loader()->loadType() == FrameLoadTypeReload && m_frame->loader()->loadType() == FrameLoadTypeReloadFromOrigin) {
        continueLoadWithDecision(IconLoadYes);
        return;
    }

    if (iconDatabase().supportsAsynchronousMode()) {
        //  FIXME (<rdar://problem/9168605>) - We should support in-memory-only private browsing icons in asynchronous icon database mode.
        if (iconDatabase().supportsAsynchronousMode() && m_frame->page()->settings()->privateBrowsingEnabled())
            return;

        m_frame->loader()->documentLoader()->getIconLoadDecisionForIconURL(urlString);
        // Commit the icon url mapping to the database just in case we don't end up loading later.
        commitToDatabase(iconURL);
        return;
    }

    IconLoadDecision decision = iconDatabase().synchronousLoadDecisionForIconURL(urlString, m_frame->loader()->documentLoader());

    if (decision == IconLoadUnknown) {
        // In this case, we may end up loading the icon later, but we still want to commit the icon url mapping to the database
        // just in case we don't end up loading later - if we commit the mapping a second time after the load, that's no big deal
        // We also tell the client to register for the notification that the icon is received now so it isn't missed in case the 
        // icon is later read in from disk
        LOG(IconDatabase, "IconController %p might load icon %s later", this, urlString.ascii().data());
        m_waitingForLoadDecision = true;    
        m_frame->loader()->client()->registerForIconNotification();
        commitToDatabase(iconURL);
        return;
    }

    continueLoadWithDecision(decision);
}
Exemple #6
0
void AddAsyncEntry()
{
	try {
		TDBCachedChannel chan;

		TVTXProcedure insert(chan, DBInsert, 9);

		time_t create_time = time(NULL);
		insert.BindInputVariable(1, TDT_INTEGER, sizeof(int),
								 ":create", &create_time);

		time_t retry_time = time(NULL);
		insert.BindInputVariable(2, TDT_INTEGER, sizeof(int),
								 ":retry", &retry_time);

		RWCString m_Method("GET");
		insert.BindInputVariable(7, TDT_CHAR, m_Method.length() + 1,
								 ":method", (void *)m_Method.data());

	//	RWCString m_Data("data");
		RWCString m_Data;
		int datalen = m_Data.length();
		insert.BindInputVariable(4, TDT_INTEGER, sizeof(int),
								 ":datalen", &datalen);

//		insert.BindInputVariable(5, TDT_CHAR, m_Data.length(),
//								 ":data", (void *)m_Data.data());
		char buf[2];
		buf[0]='c';
		buf[1]='\0';
		insert.BindInputVariable(5, TDT_CHAR, 1,
								 ":data", (void *)buf);

		RWCString hdrString("x-up-hdr:header");
		insert.BindInputVariable(0, TDT_CHAR, hdrString.length() + 1,
								 ":headers", (void *)hdrString.data());

		RWCString m_DataType("datatype");
		//RWCString m_DataType;
		insert.BindInputVariable(6, TDT_CHAR, m_DataType.length() + 1,
								 ":datatype", (void *)m_DataType.data());
		
		RWCString urlString("HTTPJUNK://");
		insert.BindInputVariable(3, TDT_CHAR, urlString.length() + 1,
								 ":url", (void *)urlString.data());
		
		int id;
        insert.BindOutputVariable(8, TDT_INTEGER, sizeof(int),
                                  ":asyncID", &id);

		insert.Execute();
		chan.Commit();
	} catch(xmsg &msg) 
	{ 
		printf("error\n");
	}
}
Exemple #7
0
void escapeURL(const std::string& url, std::string& escaped)
{
    String urlString(url.data(), url.length());
    String escapedString = WebCore::encodeWithURLEscapeSequences(urlString);
    CString utf8 = escapedString.utf8();

    escaped.clear();
    escaped.append(utf8.data(), utf8.length());
}
static JSValueRef getURL(JSContextRef ctx, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
{
    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
        return JSValueMakeUndefined(ctx);

    ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
    JSRetainPtr<JSStringRef> urlString(Adopt, JSStringCreateWithCharacters(profileNode->url().data(), profileNode->url().size()));
    return JSValueMakeString(ctx, urlString.get());
}
/*static*/
bool FrameLoaderClientApollo::unmapFrameUrl(Frame* frame, const KURL& url, KURL* unmappedUrl)
{
	String urlString(url.string());

	while (frame) {
		HTMLFrameOwnerElement* frameElement = frame->ownerElement();
		// If there's no frame owner, then consider the opener hierarchy
		while (!frameElement) {
			WebCore::Frame* const frameOpener = frame->loader()->opener();
			if ((!frameOpener) || (frameOpener == frame))
				break;
			frame = frameOpener;
			frameElement = frame->ownerElement();
		}
		if (!frameElement)
			break;

		String fromURL = frameElement->getAttribute(HTMLNames::sandboxrootAttr);
		String toURL = frameElement->getAttribute(HTMLNames::documentrootAttr);
		if (!fromURL.isEmpty() && !toURL.isEmpty()) {
			if (frameElement->document()->url().string().startsWith("app:/")) {
				int rest = -1;
				if (isUrlPrefixOfUrl(toURL.utf8().data(), urlString.utf8().data(), &rest)) {
					// Ensure that network content does not get treated
					// as local or privileged content.
					// Don't require a / on the toURL; it'll be added if necessary.
					if ((fromURL.find("http:/") == 0 || fromURL.find("https:/") == 0 || fromURL.find("file:/") == 0)
						&& (toURL.find("app:") == 0 || toURL.find("app-storage:") == 0 || toURL.find("file:") == 0)) {
							String newURL = fromURL;
							// may need to insert a slash, or get rid of one
							if (newURL[newURL.length()-1] == '/') {
								if (urlString[rest] == '/')  // already have a slash, skip this one
									rest++;
							}
							else if (urlString[rest] != '/'
								&& urlString[rest] != '#'
								&& urlString[rest] != '?'
								&& urlString[rest] != 0) {
									newURL.append('/');
							}
							newURL.append(urlString.substring(rest));

							// Most header fields not interesting since result is always a local resource.
							*unmappedUrl = KURL(ParsedURLString, newURL);
							return true;
					}
				}
			}
		}
		// Keep looking up the frame hierarchy
		frame = frameElement->document()->frame();
	}

	// use original
	*unmappedUrl = url;
	return false;
}
static String makeURLString(const char* url)
{
    String urlString(url);
    
    // Strip return characters.
    urlString.replace('\r', "");
    urlString.replace('\n', "");

    return urlString;
}
void CSSImageValue::reResolveURL(const Document& document)
{
    KURL url = document.completeURL(m_relativeURL);
    AtomicString urlString(url.string());
    if (urlString == m_absoluteURL)
        return;
    m_absoluteURL = urlString;
    m_isCachePending = true;
    m_cachedImage.clear();
}
// The biggest advantage of schemehandler is that it can handle
// wide range of schemes and is extensible by plugins
static bool handleUrl(const QUrl &url)
{
    if (!url.isValid())
        return false;

    QString urlString(url.toString());
    TPtrC urlPtr(qt_QString2TPtrC(urlString));
    TRAPD( err, handleUrlL(urlPtr));
    return err ? false : true;
}
Exemple #13
0
// Motivated by https://bugs.webkit.org/show_bug.cgi?id=38956. libsoup
// does not add the password to the URL when calling
// soup_uri_to_string, and thus the requests are not properly
// built. Fixing soup_uri_to_string is a no-no as the maintainer does
// not want to break compatibility with previous implementations
KURL soupURIToKURL(SoupURI* soupURI)
{
    GOwnPtr<gchar> urlString(soup_uri_to_string(soupURI, FALSE));
    KURL url(KURL(), String::fromUTF8(urlString.get()));

    if (!soupURI->password)
        return url;

    url.setPass(String::fromUTF8(soupURI->password));
    return url;
}
Exemple #14
0
	void ProxyForURLCallback(const char* url, char* buffer, int bufferLength)
	{
		buffer[bufferLength - 1] = '\0';

		std::string urlString(url);
		SharedProxy proxy(ProxyConfig::GetProxyForURL(urlString));
		if (proxy.isNull())
			strncpy(buffer, "direct://", bufferLength);
		else
			strncpy(buffer, proxy->ToString().c_str(), bufferLength);
	}
//
// FindURLFromLocalFile
//
// we are looking for a URL and couldn't find it, try again with looking for 
// a local file. If we have one, it may either be a normal file or an internet shortcut.
// In both cases, however, we can get a URL (it will be a file:// url in the
// local file case).
//
bool
nsClipboard :: FindURLFromLocalFile ( IDataObject* inDataObject, UINT inIndex, void** outData, PRUint32* outDataLen )
{
  bool dataFound = false;

  nsresult loadResult = GetNativeDataOffClipboard(inDataObject, inIndex, GetFormat(kFileMime), nullptr, outData, outDataLen);
  if ( NS_SUCCEEDED(loadResult) && *outData ) {
    // we have a file path in |data|. Is it an internet shortcut or a normal file?
    const nsDependentString filepath(static_cast<PRUnichar*>(*outData));
    nsCOMPtr<nsIFile> file;
    nsresult rv = NS_NewLocalFile(filepath, true, getter_AddRefs(file));
    if (NS_FAILED(rv)) {
      nsMemory::Free(*outData);
      return dataFound;
    }

    if ( IsInternetShortcut(filepath) ) {
      nsMemory::Free(*outData);
      nsCAutoString url;
      ResolveShortcut( file, url );
      if ( !url.IsEmpty() ) {
        // convert it to unicode and pass it out
        nsDependentString urlString(UTF8ToNewUnicode(url));
        // the internal mozilla URL format, text/x-moz-url, contains
        // URL\ntitle.  We can guess the title from the file's name.
        nsAutoString title;
        file->GetLeafName(title);
        // We rely on IsInternetShortcut check that file has a .url extension.
        title.SetLength(title.Length() - 4);
        if (title.IsEmpty())
          title = urlString;
        *outData = ToNewUnicode(urlString + NS_LITERAL_STRING("\n") + title);
        *outDataLen = NS_strlen(static_cast<PRUnichar*>(*outData)) * sizeof(PRUnichar);

        dataFound = true;
      }
    }
    else {
      // we have a normal file, use some Necko objects to get our file path
      nsCAutoString urlSpec;
      NS_GetURLSpecFromFile(file, urlSpec);

      // convert it to unicode and pass it out
      nsMemory::Free(*outData);
      *outData = UTF8ToNewUnicode(urlSpec);
      *outDataLen = NS_strlen(static_cast<PRUnichar*>(*outData)) * sizeof(PRUnichar);
      dataFound = true;
    } // else regular file
  }

  return dataFound;
} // FindURLFromLocalFile
JSRetainPtr<JSStringRef> TestRunner::pathToLocalResource(JSStringRef url)
{
    size_t urlSize = JSStringGetMaximumUTF8CStringSize(url);
    GOwnPtr<gchar> urlString(static_cast<gchar*>(g_malloc(urlSize)));
    JSStringGetUTF8CString(url, urlString.get(), urlSize);

    if (!g_str_has_prefix(urlString.get(), "file:///tmp/LayoutTests/"))
        return JSStringRetain(url);

    const gchar* layoutTestsSuffix = urlString.get() + strlen("file:///tmp/");
    GOwnPtr<gchar> testPath(g_build_filename(WTR::topLevelPath().data(), layoutTestsSuffix, NULL));
    GOwnPtr<gchar> testURI(g_filename_to_uri(testPath.get(), 0, 0));
    return JSStringCreateWithUTF8CString(testURI.get());
}
//
// FindURLFromNativeURL
//
// we are looking for a URL and couldn't find it using our internal
// URL flavor, so look for it using the native URL flavor,
// CF_INETURLSTRW (We don't handle CF_INETURLSTRA currently)
//
bool
nsClipboard :: FindURLFromNativeURL ( IDataObject* inDataObject, UINT inIndex, void** outData, PRUint32* outDataLen )
{
  bool dataFound = false;

  void* tempOutData = nullptr;
  PRUint32 tempDataLen = 0;

  nsresult loadResult = GetNativeDataOffClipboard(inDataObject, inIndex, ::RegisterClipboardFormat(CFSTR_INETURLW), nullptr, &tempOutData, &tempDataLen);
  if ( NS_SUCCEEDED(loadResult) && tempOutData ) {
    nsDependentString urlString(static_cast<PRUnichar*>(tempOutData));
    // the internal mozilla URL format, text/x-moz-url, contains
    // URL\ntitle.  Since we don't actually have a title here,
    // just repeat the URL to fake it.
    *outData = ToNewUnicode(urlString + NS_LITERAL_STRING("\n") + urlString);
    *outDataLen = NS_strlen(static_cast<PRUnichar*>(*outData)) * sizeof(PRUnichar);
    nsMemory::Free(tempOutData);
    dataFound = true;
  }
  else {
    loadResult = GetNativeDataOffClipboard(inDataObject, inIndex, ::RegisterClipboardFormat(CFSTR_INETURLA), nullptr, &tempOutData, &tempDataLen);
    if ( NS_SUCCEEDED(loadResult) && tempOutData ) {
      // CFSTR_INETURLA is (currently) equal to CFSTR_SHELLURL which is equal to CF_TEXT
      // which is by definition ANSI encoded.
      nsCString urlUnescapedA;
      bool unescaped = NS_UnescapeURL(static_cast<char*>(tempOutData), tempDataLen, esc_OnlyNonASCII | esc_SkipControl, urlUnescapedA);

      nsString urlString;
      if (unescaped)
        NS_CopyNativeToUnicode(urlUnescapedA, urlString);
      else
        NS_CopyNativeToUnicode(nsDependentCString(static_cast<char*>(tempOutData), tempDataLen), urlString);

      // the internal mozilla URL format, text/x-moz-url, contains
      // URL\ntitle.  Since we don't actually have a title here,
      // just repeat the URL to fake it.
      *outData = ToNewUnicode(urlString + NS_LITERAL_STRING("\n") + urlString);
      *outDataLen = NS_strlen(static_cast<PRUnichar*>(*outData)) * sizeof(PRUnichar);
      nsMemory::Free(tempOutData);
      dataFound = true;
    }
  }

  return dataFound;
} // FindURLFromNativeURL
void IconController::continueLoadWithDecision(IconLoadDecision iconLoadDecision)
{
    ASSERT(iconLoadDecision != IconLoadUnknown);

    //  FIXME (<rdar://problem/9168605>) - We should support in-memory-only private browsing icons in asynchronous icon database mode.
    if (iconDatabase().supportsAsynchronousMode() && m_frame->page()->settings()->privateBrowsingEnabled())
        return;

    if (iconLoadDecision == IconLoadNo) {
        KURL iconURL(url());
        String urlString(iconURL.string());
        if (urlString.isEmpty())
            return;

        LOG(IconDatabase, "IconController::startLoader() - Told not to load this icon, committing iconURL %s to database for pageURL mapping", urlString.ascii().data());
        commitToDatabase(iconURL);

        if (iconDatabase().supportsAsynchronousMode()) {
            m_frame->loader()->documentLoader()->getIconDataForIconURL(urlString);
            return;
        }

        // We were told not to load this icon - that means this icon is already known by the database
        // If the icon data hasn't been read in from disk yet, kick off the read of the icon from the database to make sure someone
        // has done it. This is after registering for the notification so the WebView can call the appropriate delegate method.
        // Otherwise if the icon data *is* available, notify the delegate
        if (!iconDatabase().synchronousIconDataKnownForIconURL(urlString)) {
            LOG(IconDatabase, "Told not to load icon %s but icon data is not yet available - registering for notification and requesting load from disk", urlString.ascii().data());
            m_frame->loader()->client()->registerForIconNotification();
            iconDatabase().synchronousIconForPageURL(m_frame->document()->url().string(), IntSize(0, 0));
            iconDatabase().synchronousIconForPageURL(m_frame->loader()->initialRequest().url().string(), IntSize(0, 0));
        } else
            m_frame->loader()->client()->dispatchDidReceiveIcon();

        return;
    } 

    if (!m_iconLoader)
        m_iconLoader = IconLoader::create(m_frame);

    m_iconLoader->startLoading();
}
Exemple #19
0
//
// FindURLFromNativeURL
//
// we are looking for a URL and couldn't find it using our internal
// URL flavor, so look for it using the native URL flavor,
// CF_INETURLSTRW (We don't handle CF_INETURLSTRA currently)
//
PRBool
nsClipboard :: FindURLFromNativeURL ( IDataObject* inDataObject, UINT inIndex, void** outData, PRUint32* outDataLen )
{
  PRBool dataFound = PR_FALSE;

  void* tempOutData = nsnull;
  PRUint32 tempDataLen = 0;
  nsresult loadResult = GetNativeDataOffClipboard(inDataObject, inIndex, ::RegisterClipboardFormat(CFSTR_INETURLW), &tempOutData, &tempDataLen);
  if ( NS_SUCCEEDED(loadResult) && tempOutData ) {
    nsDependentString urlString(static_cast<PRUnichar*>(tempOutData));
    // the internal mozilla URL format, text/x-moz-url, contains
    // URL\ntitle.  Since we don't actually have a title here,
    // just repeat the URL to fake it.
    *outData = ToNewUnicode(urlString + NS_LITERAL_STRING("\n") + urlString);
    *outDataLen = nsCRT::strlen(static_cast<PRUnichar*>(*outData)) * sizeof(PRUnichar);
    nsMemory::Free(tempOutData);
    dataFound = PR_TRUE;
  }

  return dataFound;
} // FindURLFromNativeURL
Exemple #20
0
void
Gecko_SetMozBinding(nsStyleDisplay* aDisplay,
                    const uint8_t* aURLString, uint32_t aURLStringLength,
                    ThreadSafeURIHolder* aBaseURI,
                    ThreadSafeURIHolder* aReferrer,
                    ThreadSafePrincipalHolder* aPrincipal)
{
  MOZ_ASSERT(aDisplay);
  MOZ_ASSERT(aURLString);
  MOZ_ASSERT(aBaseURI);
  MOZ_ASSERT(aReferrer);
  MOZ_ASSERT(aPrincipal);

  nsString url;
  nsDependentCSubstring urlString(reinterpret_cast<const char*>(aURLString),
                                  aURLStringLength);
  AppendUTF8toUTF16(urlString, url);
  RefPtr<nsStringBuffer> urlBuffer = nsCSSValue::BufferFromString(url);

  aDisplay->mBinding =
    new css::URLValue(urlBuffer, do_AddRef(aBaseURI),
                      do_AddRef(aReferrer), do_AddRef(aPrincipal));
}
Exemple #21
0
void ViewClientEfl::webProcessCrashed(WKViewRef, WKURLRef url, const void* clientInfo)
{
    EwkView* ewkView = toEwkView(clientInfo);

    // Check if loading was ongoing, when web process crashed.
    double loadProgress = WKPageGetEstimatedProgress(ewkView->wkPage());
    if (loadProgress >= 0 && loadProgress < 1) {
        loadProgress = 1;
        ewkView->smartCallback<LoadProgress>().call(&loadProgress);
    }

    ewkView->smartCallback<TooltipTextUnset>().call();

    bool handled = false;
    ewkView->smartCallback<WebProcessCrashed>().call(&handled);

    if (!handled) {
        WKEinaSharedString urlString(url);
        WARN("WARNING: The web process experienced a crash on '%s'.\n", static_cast<const char*>(urlString));

        // Display an error page
        ewk_view_html_string_load(ewkView->evasObject(), "The web process has crashed.", 0, urlString);
    }
}
nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent,
                                      nsIAppShell* aShell, nsIURI* aUrl, 
                                      PRInt32 aInitialWidth,
                                      PRInt32 aInitialHeight,
                                      PRBool aIsHiddenWindow,
                                      nsWidgetInitData& widgetInitData)
{
  nsresult rv;
  nsCOMPtr<nsIWidget> parentWidget;

  mIsHiddenWindow = aIsHiddenWindow;
  
  // XXX: need to get the default window size from prefs...
  // Doesn't come from prefs... will come from CSS/XUL/RDF
  nsRect r(0, 0, aInitialWidth, aInitialHeight);
  
  // Create top level window
  mWindow = do_CreateInstance(kWindowCID, &rv);
  if (NS_OK != rv) {
    return rv;
  }

  /* This next bit is troublesome. We carry two different versions of a pointer
     to our parent window. One is the parent window's widget, which is passed
     to our own widget. The other is a weak reference we keep here to our
     parent WebShellWindow. The former is useful to the widget, and we can't
     trust its treatment of the parent reference because they're platform-
     specific. The latter is useful to this class.
       A better implementation would be one in which the parent keeps strong
     references to its children and closes them before it allows itself
     to be closed. This would mimic the behaviour of OSes that support
     top-level child windows in OSes that do not. Later.
  */
  nsCOMPtr<nsIBaseWindow> parentAsWin(do_QueryInterface(aParent));
  if (parentAsWin) {
    parentAsWin->GetMainWidget(getter_AddRefs(parentWidget));
    mParentWindow = do_GetWeakReference(aParent);
  }

  mWindow->SetClientData(this);
  mWindow->Create((nsIWidget *)parentWidget,          // Parent nsIWidget
                  r,                                  // Widget dimensions
                  nsWebShellWindow::HandleEvent,      // Event handler function
                  nsnull,                             // Device context
                  aShell,                             // Application shell
                  nsnull,                             // nsIToolkit
                  &widgetInitData);                   // Widget initialization data
  mWindow->GetClientBounds(r);
  mWindow->SetBackgroundColor(NS_RGB(192,192,192));

  // Create web shell
  mDocShell = do_CreateInstance("@mozilla.org/webshell;1");
  NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);

  // Make sure to set the item type on the docshell _before_ calling
  // Create() so it knows what type it is.
  nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
  NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
  NS_ENSURE_SUCCESS(EnsureChromeTreeOwner(), NS_ERROR_FAILURE);

  docShellAsItem->SetTreeOwner(mChromeTreeOwner);
  docShellAsItem->SetItemType(nsIDocShellTreeItem::typeChrome);

  r.x = r.y = 0;
  nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
  NS_ENSURE_SUCCESS(docShellAsWin->InitWindow(nsnull, mWindow, 
   r.x, r.y, r.width, r.height), NS_ERROR_FAILURE);
  NS_ENSURE_SUCCESS(docShellAsWin->Create(), NS_ERROR_FAILURE);

  // Attach a WebProgress listener.during initialization...
  nsCOMPtr<nsIWebProgress> webProgress(do_GetInterface(mDocShell, &rv));
  if (webProgress) {
    webProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_NETWORK);
  }

  if (nsnull != aUrl)  {
    nsCAutoString tmpStr;

    rv = aUrl->GetSpec(tmpStr);
    if (NS_FAILED(rv)) return rv;

    NS_ConvertUTF8toUCS2 urlString(tmpStr);
    nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
    NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
    rv = webNav->LoadURI(urlString.get(),
                         nsIWebNavigation::LOAD_FLAGS_NONE,
                         nsnull,
                         nsnull,
                         nsnull);
    NS_ENSURE_SUCCESS(rv, rv);
  }
                     
  return rv;
}
void CMSDNForumHelper::RevealHiddenLinks(IHTMLDocument2* pDocument)
{
	CComBSTR url;
	HRESULT hr=pDocument->get_URL(&url);
	if(hr==S_OK)
	{
		url.ToLower();
		CString urlString(url);
		if(urlString.Find(_T("microsoft.com"))==-1)
			return;
		if(urlString.Find(_T("social"))==1)
			return;
		
	}
    CComPtr<IHTMLElementCollection> linkElementCollection;

    // Get the collection of images from the DOM.
	 hr = pDocument->get_links(&linkElementCollection);
    if (hr == S_OK && linkElementCollection != NULL)
    {
        // Get the number of images in the collection.
        long linkCount = 0;
        hr = linkElementCollection->get_length(&linkCount);
        if (hr == S_OK && linkCount > 0)
        {
            for (int i = 0; i < linkCount; i++)
            {
                CComVariant varItemIndex(i);
                CComVariant varEmpty;
                CComPtr<IDispatch> linkDispatch;
                // Get the link out of the collection by index.
                hr = linkElementCollection->item(varItemIndex, varEmpty, &linkDispatch);
                if (hr == S_OK && linkDispatch != NULL)
                {
					//filter out hot spot on images
					CComQIPtr<IHTMLAnchorElement> anchorElement(linkDispatch);
					if(anchorElement==NULL) continue;
                    //query for the generic HTML element interface
					CComQIPtr<IHTMLElement> linkElement(linkDispatch);					
                    if (linkElement)
                    {
                        // ...then ask for the style interface.
                        CComPtr<IHTMLStyle> linkStyle;
						hr = linkElement->get_style(&linkStyle);

                        // Set display="none" to hide the image.
                        if (hr == S_OK && linkStyle != NULL)
                        {                            
							CComVariant linkCollor;
							hr=linkStyle->get_color(&linkCollor);
							if(linkCollor.vt==VT_BSTR)
							{
								CComBSTR linkCollorString(linkCollor.bstrVal);
								if (hr == S_OK && linkCollorString.Length()>0)
								{
									linkStyle->put_backgroundColor(CComVariant(_T("red")));
									linkStyle->put_color(CComVariant(_T("")));
									CComBSTR href,text;
									anchorElement->get_href(&href);
									linkElement->get_innerText(&text);
									CString newText;
									newText.Format(_T("hidden link, possible spam: text: %s, url: %s"),text,href);
									linkElement->put_innerText(CComBSTR(newText));
								}
							}
                        }
                    }
                }
            }
        }
    }
}
Exemple #24
0
bool HistoryItem::isCurrentDocument(Document* doc) const
{
    // FIXME: We should find a better way to check if this is the current document.
    return urlString() == doc->url();
}