This source file includes following definitions.
- AddStandardSchemeHelper
- RegisterContentSchemes
#include "content/common/url_schemes.h"
#include <string.h>
#include <algorithm>
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "base/strings/string_util.h"
#include "content/common/savable_url_schemes.h"
#include "content/public/common/content_client.h"
#include "content/public/common/url_constants.h"
#include "url/url_util.h"
namespace {
void AddStandardSchemeHelper(const std::string& scheme) {
url_util::AddStandardScheme(scheme.c_str());
}
}
namespace content {
void RegisterContentSchemes(bool lock_standard_schemes) {
std::vector<std::string> additional_standard_schemes;
std::vector<std::string> additional_savable_schemes;
GetContentClient()->AddAdditionalSchemes(&additional_standard_schemes,
&additional_savable_schemes);
url_util::AddStandardScheme(kChromeDevToolsScheme);
url_util::AddStandardScheme(kChromeUIScheme);
url_util::AddStandardScheme(kGuestScheme);
url_util::AddStandardScheme(kMetadataScheme);
std::for_each(additional_standard_schemes.begin(),
additional_standard_schemes.end(),
AddStandardSchemeHelper);
if (lock_standard_schemes)
url_util::LockStandardSchemes();
if (!additional_savable_schemes.empty()) {
const char* const* default_schemes = GetSavableSchemesInternal();
const char* const* default_schemes_end = NULL;
for (default_schemes_end = default_schemes; *default_schemes_end;
++default_schemes_end) {}
const int default_schemes_count = default_schemes_end - default_schemes;
int schemes = static_cast<int>(additional_savable_schemes.size());
char **savable_schemes = new char*[schemes + default_schemes_count + 1];
memcpy(savable_schemes,
default_schemes,
default_schemes_count * sizeof(default_schemes[0]));
for (int i = 0; i < schemes; ++i) {
savable_schemes[default_schemes_count + i] =
base::strdup(additional_savable_schemes[i].c_str());
}
savable_schemes[default_schemes_count + schemes] = 0;
SetSavableSchemes(savable_schemes);
}
}
}