GURL 
getDjViewDataFile(const char *fname)
{
  GList<GURL> paths = DjVuMessage::GetProfilePaths();
  GUTF8String file = fname;

  // end hack alert
  static const char *osi = "/osi/";
  static const char *djview3 = "/djview3/";
  for (GPosition pos=paths; pos; ++pos)
    {
      GURL url = GURL(file, paths[pos]);
      GUTF8String urls = (const char*)url;
      int pos = urls.search(osi);
      if (pos >= 0)
        {
          GUTF8String urlx;
          urlx += urls.substr(0, pos);
          urlx += djview3;
          urlx += urls.substr(pos+strlen(osi), -1);
          GURL url = GURL::UTF8(urlx);
          if (url.is_file())
            return url;
        }
    }
  // end hack alert
  for (GPosition pos=paths; pos; ++pos)
    {
      GURL url = GURL(file, paths[pos]);
      if(url.is_file())
        return url;
    }
  return GURL();
}
GURL WebStringToGURL(const WebString& webString)
{
    if (webString.isEmpty())
        return GURL();

    String str = webString;
    if (str.is8Bit()) {
        // Ensure the (possibly Latin-1) 8-bit string is UTF-8 for GURL.
        StringUTF8Adaptor utf8(str);
        return GURL(utf8.asStringPiece());
    }

    // GURL can consume UTF-16 directly.
    return GURL(base::StringPiece16(str.characters16(), str.length()));
}
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();
}
Esempio n. 4
0
void TestInterfaces::configureForTestWithURL(const WebURL& testURL, bool generatePixels)
{
    string spec = GURL(testURL).spec();
    m_testRunner->setShouldGeneratePixelResults(generatePixels);
    if (spec.find("loading/") != string::npos)
        m_testRunner->setShouldDumpFrameLoadCallbacks(true);
    if (spec.find("/dumpAsText/") != string::npos) {
        m_testRunner->setShouldDumpAsText(true);
        m_testRunner->setShouldGeneratePixelResults(false);
    }
    if (spec.find("/inspector/") != string::npos
        || spec.find("/inspector-enabled/") != string::npos)
        m_testRunner->clearDevToolsLocalStorage();
    if (spec.find("/inspector/") != string::npos) {
        // Subfolder name determines default panel to open.
        string settings = "";
        string test_path = spec.substr(spec.find("/inspector/") + 11);
        size_t slash_index = test_path.find("/");
        if (slash_index != string::npos) {
            settings = base::StringPrintf(
                "{\"lastActivePanel\":\"\\\"%s\\\"\"}",
                test_path.substr(0, slash_index).c_str());
        }
        m_testRunner->showDevTools(settings, string());
    }
    if (spec.find("/viewsource/") != string::npos) {
        m_testRunner->setShouldEnableViewSource(true);
        m_testRunner->setShouldGeneratePixelResults(false);
        m_testRunner->setShouldDumpAsMarkup(true);
    }
}
Esempio n. 5
0
GURL PhoneEmailDetector::GetIntentURL(const std::string& content_text)
{
    // CAPPFIX_WEB_TRIMINTENTURL
    const unsigned strBegin = content_text.find_first_not_of(" \t\r\n");
    const unsigned strEnd = content_text.find_last_not_of(" \t\r\n");
    if (strBegin != std::string::npos && strEnd != std::string::npos) {
        const unsigned strRange = strEnd - strBegin + 1;
        if (strRange > 0)
            return GURL(m_prefix +
                    EscapeQueryParamValue(content_text.substr(strBegin, strRange), true));
    }
    // CAPPFIX_WEB_TRIMINTENTURL_END

    return GURL(m_prefix +
            EscapeQueryParamValue(content_text, true));
}
Esempio n. 6
0
DjVuNavDir::DjVuNavDir(ByteStream & str, const GURL &dirURL)
{
   if (!dirURL) G_THROW( ERR_MSG("DjVuNavDir.zero_dir") );
   
   baseURL=GURL(dirURL).base();
   
   decode(str);
}
void WebContentsAdapter::load(const QUrl &url)
{
    QString urlString = url.toString();
    GURL gurl(urlString.toStdString());
    if (!gurl.has_scheme())
        gurl = GURL(std::string("http://") + urlString.toStdString());

    content::NavigationController::LoadURLParams params(gurl);
    params.transition_type = content::PageTransitionFromInt(content::PAGE_TRANSITION_TYPED | content::PAGE_TRANSITION_FROM_ADDRESS_BAR);
    webContents()->GetController().LoadURLWithParams(params);
    webContents()->GetView()->Focus();
}
Esempio n. 8
0
LRESULT CMainFrame::OnReturn(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
  CString url = m_addressbar->GetUrl();
  if (-1 == url.Find(L"http://"))
  {
    url = L"http://" + url;
  }
  
  string16 sUrl= url;
  m_web_contents_delegate->LoadURL(GURL(sUrl));
  return 0;
}
Esempio n. 9
0
void TestInterfaces::configureForTestWithURL(const WebURL& testURL, bool generatePixels)
{
    string spec = GURL(testURL).spec();
    m_testRunner->setShouldGeneratePixelResults(generatePixels);
    if (spec.find("loading/") != string::npos)
        m_testRunner->setShouldDumpFrameLoadCallbacks(true);
    if (spec.find("/dumpAsText/") != string::npos) {
        m_testRunner->setShouldDumpAsText(true);
        m_testRunner->setShouldGeneratePixelResults(false);
    }
    if (spec.find("/inspector/") != string::npos)
        m_testRunner->showDevTools();
}
Esempio n. 10
0
void TestRunner::removeOriginAccessWhitelistEntry(const CppArgumentList& arguments, CppVariant* result)
{
    result->setNull();

    if (arguments.size() != 4 || !arguments[0].isString() || !arguments[1].isString()
        || !arguments[2].isString() || !arguments[3].isBool())
        return;

    WebKit::WebURL url(GURL(arguments[0].toString()));
    if (!url.isValid())
        return;

    WebSecurityPolicy::removeOriginAccessWhitelistEntry(
        url,
        cppVariantToWebString(arguments[1]),
        cppVariantToWebString(arguments[2]),
        arguments[3].toBoolean());
}
Esempio n. 11
0
KaminoUpdateStatus::KaminoUpdateStatus(net::URLRequestContextGetter *getter) : net::URLFetcherDelegate(){
	fetcher = NULL;
	fetcher = net::URLFetcher::Create(0, GURL("https://s3-us-west-2.amazonaws.com/voyjor/current_version.txt"), net::URLFetcher::GET, this);	
	fetcher->SetRequestContext(getter);
}
Esempio n. 12
0
GURL
DjVuPort::id_to_url(const DjVuPort *, const GUTF8String &) { return GURL(); }
Esempio n. 13
0
void UserScript::setName(const QString &name)
{
    m_name = name;
    initData();
    scriptData->url = GURL(QStringLiteral("userScript:%1").arg(name).toStdString());
}
GURL PhoneEmailDetector::GetIntentURL(const std::string& content_text)
{
    return GURL(m_prefix +
            EscapeQueryParamValue(content_text, true));
}
bool OperaImporter::ImportWand_ReadEntryAuth(
    std::string::iterator &buffer, std::string::iterator &buffer_end,
    std::vector<autofill::PasswordForm> &passwords, bool ignore_entry) {
  base::string16 guid;
  base::string16 date_used;
  base::string16 url;
  base::string16 domain;
  uint32_t field_count=0;
  std::vector<wand_field_entry> fields;
  uint32_t dummy=0;

  if (wand_version_ == 6) {
    if (!WandReadUint32(buffer, buffer_end, dummy))
      return false;

    if (!WandReadEncryptedField(buffer, buffer_end, guid))
      return false;

    if (!WandReadEncryptedField(buffer, buffer_end, date_used))
      return false;
  }

  if (!WandReadEncryptedField(buffer, buffer_end, url))
    return false;

  std::string url8;
  url8 = base::UTF16ToUTF8(url);

  int first_pass = -1;
  int first_field = -1;

  bool http_auth = (url8[0] == '*');
  bool mail_url = (url8.compare(0,  std::string::npos, "opera:mail") == 0);
  field_count = 2;
  fields.resize(field_count);

  if(!WandReadEncryptedField(buffer, buffer_end,fields[0].fieldvalue))
    return false;

  if (!WandReadEncryptedField(buffer, buffer_end, fields[1].fieldvalue,
                              &master_password_block_))
    return false;

  fields[1].is_password = true;
  first_pass = 1;
  first_field = 0;
  if (mail_url) {
    url8.replace(0, 5, "vivaldi");
  }
  if (http_auth)
    url8.erase(url8.begin());

  GURL::Replacements rep;
  rep.ClearQuery();
  rep.ClearRef();
  rep.ClearUsername();
  rep.ClearPassword();

  autofill::PasswordForm password;

  password.scheme = autofill::PasswordForm::SCHEME_OTHER;
  /*
  if(http_auth)
    password.scheme = autofill::PasswordForm::SCHEME_OTHER;
  else if (mail_url)
    password.scheme = autofill::PasswordForm::SCHEME_OTHER;
    */

  password.origin = GURL(url8).ReplaceComponents(rep);
  password.signon_realm = password.origin.GetOrigin().spec();
  password.blacklisted_by_user = (field_count == 0);
  password.ssl_valid = password.origin.SchemeIs("https");

  if (first_field >= 0) {
    password.username_element = fields[first_field].fieldname;
    password.username_value = fields[first_field].fieldvalue;
  }

  if (first_pass >= 0) {
    password.password_element = fields[first_pass].fieldname;
    password.password_value = fields[first_pass].fieldvalue;
  }

  for (uint32_t i = 0; i < field_count; i++) {
    if (i != first_field && i != first_pass &&
        !fields[first_pass].is_password) {
      password.other_possible_usernames.push_back(
          fields[first_pass].fieldvalue);
    }
  }

  passwords.push_back(password);

  return true;
}
bool OperaImporter::ImportWand_ReadEntryHTML(
    std::string::iterator &buffer, std::string::iterator &buffer_end,
    std::vector<autofill::PasswordForm> &passwords, bool ignore_entry) {
  base::string16 guid;
  base::string16 date_used;
  base::string16 url;
  base::string16 submit_button;
  base::string16 submit_value;
  base::string16 domain;
  uint32_t field_count=0;
  std::vector<wand_field_entry> fields;
  uint32_t dummy=0;

  if (wand_version_ == 6) {
    if (!WandReadUint32(buffer, buffer_end, dummy))
      return false;

    if (!WandReadEncryptedField(buffer, buffer_end, guid))
      return false;

    if (!WandReadEncryptedField(buffer, buffer_end, date_used))
      return false;
  }

  if (!WandReadEncryptedField(buffer, buffer_end, url))
    return false;

  int first_pass = -1;
  int first_field = -1;

  if (!WandReadEncryptedField(buffer, buffer_end, submit_button))
    return false;
  if (!WandReadEncryptedField(buffer, buffer_end, submit_value))
    return false;

  if (!WandReadEncryptedField(buffer, buffer_end, domain))
    return false;

  buffer += 24;
  if (buffer >= buffer_end)
    return false;

  if (!WandReadUint32(buffer, buffer_end, field_count))
    return false;

  fields.resize(field_count);

  for (uint32_t i = 0; i < field_count; i++) {
    if (!WandReadEncryptedNameAndField(
            buffer, buffer_end, fields[i].fieldname, fields[i].fieldvalue,
            fields[i].is_password, &master_password_block_))
      return false;
    if (first_pass < 0 && fields[i].is_password)
      first_pass = (int)i;
    else if (first_field && !fields[i].is_password)
      first_field = (int)i;
  }

  GURL::Replacements rep;
  rep.ClearQuery();
  rep.ClearRef();
  rep.ClearUsername();
  rep.ClearPassword();

  autofill::PasswordForm password;

  password.scheme = autofill::PasswordForm::SCHEME_HTML;

  password.submit_element = submit_button;
  password.origin = GURL(url).ReplaceComponents(rep);
  if (!password.origin.is_valid())
    return true; // Ignore this entry, no URL

  password.signon_realm = password.origin.GetOrigin().spec();
  password.blacklisted_by_user = (field_count == 0);
  password.ssl_valid = password.origin.SchemeIs("https");

  if (first_field >= 0) {
    password.username_element = fields[first_field].fieldname;
    password.username_value = fields[first_field].fieldvalue;
  }

  if (first_pass >= 0) {
    password.password_element = fields[first_pass].fieldname;
    password.password_value = fields[first_pass].fieldvalue;
  }

  for (uint32_t i = 0; i < field_count; i++) {
    if (i != first_field && i != first_pass && !fields[first_pass].is_password)
      password.other_possible_usernames.push_back(
          fields[first_pass].fieldvalue);
  }
  passwords.push_back(password);

  return true;
}
Esempio n. 17
0
void CMainFrame::OpenHomePage()
{
  m_web_contents_delegate = new content::SimpleWebContentsDelegate();
  m_web_contents_delegate->SetHWND(m_hWnd, m_clientview->m_hWnd);
  m_web_contents_delegate->window_ = m_clientview->m_hWnd;
  m_web_contents_delegate->SetBrowserContext((content::BrowserContext*)m_browser_main->browser_context_.get());
  m_web_contents_delegate->Initialize((content::BrowserContext*)m_browser_main->browser_context_.get(), GURL("http://www.baidu.com/"), NULL,MSG_ROUTING_NONE, gfx::Size());
}