Commit 400d6397 authored by Oscar Johansson's avatar Oscar Johansson Committed by Commit Bot

Resolve conflict for namespace "errors"

In Jumbo build, the local redefinition of the namespace
errors, for example "namespace errors = manifest_errors",
causes conflicts between files. This is resolved by removing the local
redefinition and using the full name instead.

Bug: 850484
Change-Id: I5b8aecd3dc5b7c922bef515b82f11c5bfdf19515
Reviewed-on: https://chromium-review.googlesource.com/1095075Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Commit-Queue: Oscar Johansson <oscarj@opera.com>
Cr-Commit-Position: refs/heads/master@{#565999}
parent e9a371b1
...@@ -126,7 +126,6 @@ const char kUserGesture[] = "User gesture required"; ...@@ -126,7 +126,6 @@ const char kUserGesture[] = "User gesture required";
} // namespace download_extension_errors } // namespace download_extension_errors
namespace errors = download_extension_errors;
namespace extensions { namespace extensions {
...@@ -509,7 +508,7 @@ void CompileDownloadQueryOrderBy( ...@@ -509,7 +508,7 @@ void CompileDownloadQueryOrderBy(
SortTypeMap::const_iterator sorter_type = SortTypeMap::const_iterator sorter_type =
sorter_types.Get().find(term_str); sorter_types.Get().find(term_str);
if (sorter_type == sorter_types.Get().end()) { if (sorter_type == sorter_types.Get().end()) {
*error = errors::kInvalidOrderBy; *error = download_extension_errors::kInvalidOrderBy;
return; return;
} }
query->AddSorter(sorter_type->second, direction); query->AddSorter(sorter_type->second, direction);
...@@ -534,7 +533,7 @@ void RunDownloadQuery( ...@@ -534,7 +533,7 @@ void RunDownloadQuery(
size_t limit = 1000; size_t limit = 1000;
if (query_in.limit.get()) { if (query_in.limit.get()) {
if (*query_in.limit < 0) { if (*query_in.limit < 0) {
*error = errors::kInvalidQueryLimit; *error = download_extension_errors::kInvalidQueryLimit;
return; return;
} }
limit = *query_in.limit; limit = *query_in.limit;
...@@ -547,7 +546,7 @@ void RunDownloadQuery( ...@@ -547,7 +546,7 @@ void RunDownloadQuery(
if (!state_string.empty()) { if (!state_string.empty()) {
DownloadItem::DownloadState state = StateEnumFromString(state_string); DownloadItem::DownloadState state = StateEnumFromString(state_string);
if (state == DownloadItem::MAX_DOWNLOAD_STATE) { if (state == DownloadItem::MAX_DOWNLOAD_STATE) {
*error = errors::kInvalidState; *error = download_extension_errors::kInvalidState;
return; return;
} }
query_out.AddFilter(state); query_out.AddFilter(state);
...@@ -558,7 +557,7 @@ void RunDownloadQuery( ...@@ -558,7 +557,7 @@ void RunDownloadQuery(
download::DownloadDangerType danger_type = download::DownloadDangerType danger_type =
DangerEnumFromString(danger_string); DangerEnumFromString(danger_string);
if (danger_type == download::DOWNLOAD_DANGER_TYPE_MAX) { if (danger_type == download::DOWNLOAD_DANGER_TYPE_MAX) {
*error = errors::kInvalidDangerType; *error = download_extension_errors::kInvalidDangerType;
return; return;
} }
query_out.AddFilter(danger_type); query_out.AddFilter(danger_type);
...@@ -576,7 +575,7 @@ void RunDownloadQuery( ...@@ -576,7 +575,7 @@ void RunDownloadQuery(
filter_types.Get().find(query_json_field.key()); filter_types.Get().find(query_json_field.key());
if (filter_type != filter_types.Get().end()) { if (filter_type != filter_types.Get().end()) {
if (!query_out.AddFilter(filter_type->second, query_json_field.value())) { if (!query_out.AddFilter(filter_type->second, query_json_field.value())) {
*error = errors::kInvalidFilter; *error = download_extension_errors::kInvalidFilter;
return; return;
} }
} }
...@@ -951,7 +950,7 @@ bool Fault(bool error, ...@@ -951,7 +950,7 @@ bool Fault(bool error,
} }
bool InvalidId(DownloadItem* valid_item, std::string* message_out) { bool InvalidId(DownloadItem* valid_item, std::string* message_out) {
return Fault(!valid_item, errors::kInvalidId, message_out); return Fault(!valid_item, download_extension_errors::kInvalidId, message_out);
} }
bool IsDownloadDeltaField(const std::string& field) { bool IsDownloadDeltaField(const std::string& field) {
...@@ -1000,7 +999,8 @@ bool DownloadsDownloadFunction::RunAsync() { ...@@ -1000,7 +999,8 @@ bool DownloadsDownloadFunction::RunAsync() {
EXTENSION_FUNCTION_VALIDATE(params.get()); EXTENSION_FUNCTION_VALIDATE(params.get());
const downloads::DownloadOptions& options = params->options; const downloads::DownloadOptions& options = params->options;
GURL download_url(options.url); GURL download_url(options.url);
if (Fault(!download_url.is_valid(), errors::kInvalidURL, &error_)) if (Fault(!download_url.is_valid(), download_extension_errors::kInvalidURL,
&error_))
return false; return false;
content::StoragePartition* storage_partition = content::StoragePartition* storage_partition =
...@@ -1058,7 +1058,7 @@ bool DownloadsDownloadFunction::RunAsync() { ...@@ -1058,7 +1058,7 @@ bool DownloadsDownloadFunction::RunAsync() {
creator_suggested_filename = base::FilePath(*options.filename); creator_suggested_filename = base::FilePath(*options.filename);
#endif #endif
if (!net::IsSafePortableRelativePath(creator_suggested_filename)) { if (!net::IsSafePortableRelativePath(creator_suggested_filename)) {
error_ = errors::kInvalidFilename; error_ = download_extension_errors::kInvalidFilename;
return false; return false;
} }
} }
...@@ -1069,15 +1069,15 @@ bool DownloadsDownloadFunction::RunAsync() { ...@@ -1069,15 +1069,15 @@ bool DownloadsDownloadFunction::RunAsync() {
if (options.headers.get()) { if (options.headers.get()) {
for (const downloads::HeaderNameValuePair& name_value : *options.headers) { for (const downloads::HeaderNameValuePair& name_value : *options.headers) {
if (!net::HttpUtil::IsValidHeaderName(name_value.name)) { if (!net::HttpUtil::IsValidHeaderName(name_value.name)) {
error_ = errors::kInvalidHeaderName; error_ = download_extension_errors::kInvalidHeaderName;
return false; return false;
} }
if (!net::HttpUtil::IsSafeHeader(name_value.name)) { if (!net::HttpUtil::IsSafeHeader(name_value.name)) {
error_ = errors::kInvalidHeaderUnsafe; error_ = download_extension_errors::kInvalidHeaderUnsafe;
return false; return false;
} }
if (!net::HttpUtil::IsValidHeaderValue(name_value.value)) { if (!net::HttpUtil::IsValidHeaderValue(name_value.value)) {
error_ = errors::kInvalidHeaderValue; error_ = download_extension_errors::kInvalidHeaderValue;
return false; return false;
} }
download_params->add_request_header(name_value.name, name_value.value); download_params->add_request_header(name_value.name, name_value.value);
...@@ -1200,7 +1200,7 @@ ExtensionFunction::ResponseAction DownloadsPauseFunction::Run() { ...@@ -1200,7 +1200,7 @@ ExtensionFunction::ResponseAction DownloadsPauseFunction::Run() {
std::string error; std::string error;
if (InvalidId(download_item, &error) || if (InvalidId(download_item, &error) ||
Fault(download_item->GetState() != DownloadItem::IN_PROGRESS, Fault(download_item->GetState() != DownloadItem::IN_PROGRESS,
errors::kNotInProgress, &error)) { download_extension_errors::kNotInProgress, &error)) {
return RespondNow(Error(error)); return RespondNow(Error(error));
} }
// If the item is already paused, this is a no-op and the operation will // If the item is already paused, this is a no-op and the operation will
...@@ -1223,7 +1223,7 @@ ExtensionFunction::ResponseAction DownloadsResumeFunction::Run() { ...@@ -1223,7 +1223,7 @@ ExtensionFunction::ResponseAction DownloadsResumeFunction::Run() {
std::string error; std::string error;
if (InvalidId(download_item, &error) || if (InvalidId(download_item, &error) ||
Fault(download_item->IsPaused() && !download_item->CanResume(), Fault(download_item->IsPaused() && !download_item->CanResume(),
errors::kNotResumable, &error)) { download_extension_errors::kNotResumable, &error)) {
return RespondNow(Error(error)); return RespondNow(Error(error));
} }
// Note that if the item isn't paused, this will be a no-op, and the extension // Note that if the item isn't paused, this will be a no-op, and the extension
...@@ -1293,9 +1293,9 @@ bool DownloadsRemoveFileFunction::RunAsync() { ...@@ -1293,9 +1293,9 @@ bool DownloadsRemoveFileFunction::RunAsync() {
browser_context(), include_incognito_information(), params->download_id); browser_context(), include_incognito_information(), params->download_id);
if (InvalidId(download_item, &error_) || if (InvalidId(download_item, &error_) ||
Fault((download_item->GetState() != DownloadItem::COMPLETE), Fault((download_item->GetState() != DownloadItem::COMPLETE),
errors::kNotComplete, &error_) || download_extension_errors::kNotComplete, &error_) ||
Fault(download_item->GetFileExternallyRemoved(), Fault(download_item->GetFileExternallyRemoved(),
errors::kFileAlreadyDeleted, &error_)) download_extension_errors::kFileAlreadyDeleted, &error_))
return false; return false;
RecordApiFunctions(DOWNLOADS_FUNCTION_REMOVE_FILE); RecordApiFunctions(DOWNLOADS_FUNCTION_REMOVE_FILE);
download_item->DeleteFile( download_item->DeleteFile(
...@@ -1306,7 +1306,7 @@ bool DownloadsRemoveFileFunction::RunAsync() { ...@@ -1306,7 +1306,7 @@ bool DownloadsRemoveFileFunction::RunAsync() {
void DownloadsRemoveFileFunction::Done(bool success) { void DownloadsRemoveFileFunction::Done(bool success) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!success) { if (!success) {
error_ = errors::kFileNotRemoved; error_ = download_extension_errors::kFileNotRemoved;
} }
SendResponse(error_.empty()); SendResponse(error_.empty());
} }
...@@ -1332,9 +1332,11 @@ void DownloadsAcceptDangerFunction::PromptOrWait(int download_id, int retries) { ...@@ -1332,9 +1332,11 @@ void DownloadsAcceptDangerFunction::PromptOrWait(int download_id, int retries) {
content::WebContents* web_contents = dispatcher()->GetVisibleWebContents(); content::WebContents* web_contents = dispatcher()->GetVisibleWebContents();
if (InvalidId(download_item, &error_) || if (InvalidId(download_item, &error_) ||
Fault(download_item->GetState() != DownloadItem::IN_PROGRESS, Fault(download_item->GetState() != DownloadItem::IN_PROGRESS,
errors::kNotInProgress, &error_) || download_extension_errors::kNotInProgress, &error_) ||
Fault(!download_item->IsDangerous(), errors::kNotDangerous, &error_) || Fault(!download_item->IsDangerous(),
Fault(!web_contents, errors::kInvisibleContext, &error_)) { download_extension_errors::kNotDangerous, &error_) ||
Fault(!web_contents, download_extension_errors::kInvisibleContext,
&error_)) {
SendResponse(error_.empty()); SendResponse(error_.empty());
return; return;
} }
...@@ -1348,7 +1350,7 @@ void DownloadsAcceptDangerFunction::PromptOrWait(int download_id, int retries) { ...@@ -1348,7 +1350,7 @@ void DownloadsAcceptDangerFunction::PromptOrWait(int download_id, int retries) {
base::TimeDelta::FromMilliseconds(100)); base::TimeDelta::FromMilliseconds(100));
return; return;
} }
error_ = errors::kInvisibleContext; error_ = download_extension_errors::kInvisibleContext;
SendResponse(false); SendResponse(false);
return; return;
} }
...@@ -1374,7 +1376,7 @@ void DownloadsAcceptDangerFunction::DangerPromptCallback( ...@@ -1374,7 +1376,7 @@ void DownloadsAcceptDangerFunction::DangerPromptCallback(
browser_context(), include_incognito_information(), download_id); browser_context(), include_incognito_information(), download_id);
if (InvalidId(download_item, &error_) || if (InvalidId(download_item, &error_) ||
Fault(download_item->GetState() != DownloadItem::IN_PROGRESS, Fault(download_item->GetState() != DownloadItem::IN_PROGRESS,
errors::kNotInProgress, &error_)) download_extension_errors::kNotInProgress, &error_))
return; return;
switch (action) { switch (action) {
case DownloadDangerPrompt::ACCEPT: case DownloadDangerPrompt::ACCEPT:
...@@ -1439,20 +1441,21 @@ ExtensionFunction::ResponseAction DownloadsOpenFunction::Run() { ...@@ -1439,20 +1441,21 @@ ExtensionFunction::ResponseAction DownloadsOpenFunction::Run() {
browser_context(), include_incognito_information(), params->download_id); browser_context(), include_incognito_information(), params->download_id);
std::string error; std::string error;
if (InvalidId(download_item, &error) || if (InvalidId(download_item, &error) ||
Fault(!user_gesture(), errors::kUserGesture, &error) || Fault(!user_gesture(), download_extension_errors::kUserGesture, &error) ||
Fault(download_item->GetState() != DownloadItem::COMPLETE, Fault(download_item->GetState() != DownloadItem::COMPLETE,
errors::kNotComplete, &error) || download_extension_errors::kNotComplete, &error) ||
Fault(!extension()->permissions_data()->HasAPIPermission( Fault(!extension()->permissions_data()->HasAPIPermission(
APIPermission::kDownloadsOpen), APIPermission::kDownloadsOpen),
errors::kOpenPermission, &error)) { download_extension_errors::kOpenPermission, &error)) {
return RespondNow(Error(error)); return RespondNow(Error(error));
} }
Browser* browser = ChromeExtensionFunctionDetails(this).GetCurrentBrowser(); Browser* browser = ChromeExtensionFunctionDetails(this).GetCurrentBrowser();
if (Fault(!browser, errors::kInvisibleContext, &error)) if (Fault(!browser, download_extension_errors::kInvisibleContext, &error))
return RespondNow(Error(error)); return RespondNow(Error(error));
content::WebContents* web_contents = content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents(); browser->tab_strip_model()->GetActiveWebContents();
if (Fault(!web_contents, errors::kInvisibleContext, &error)) if (Fault(!web_contents, download_extension_errors::kInvisibleContext,
&error))
return RespondNow(Error(error)); return RespondNow(Error(error));
if (GetSenderWebContents() && if (GetSenderWebContents() &&
GetSenderWebContents()->HasRecentInteractiveInputEvent()) { GetSenderWebContents()->HasRecentInteractiveInputEvent()) {
...@@ -1477,13 +1480,14 @@ ExtensionFunction::ResponseAction DownloadsOpenFunction::Run() { ...@@ -1477,13 +1480,14 @@ ExtensionFunction::ResponseAction DownloadsOpenFunction::Run() {
void DownloadsOpenFunction::OpenPromptDone(int download_id, bool accept) { void DownloadsOpenFunction::OpenPromptDone(int download_id, bool accept) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
std::string error; std::string error;
if (Fault(!accept, errors::kOpenPermission, &error)) { if (Fault(!accept, download_extension_errors::kOpenPermission, &error)) {
Respond(Error(error)); Respond(Error(error));
return; return;
} }
DownloadItem* download_item = GetDownload( DownloadItem* download_item = GetDownload(
browser_context(), include_incognito_information(), download_id); browser_context(), include_incognito_information(), download_id);
if (Fault(!download_item, errors::kFileAlreadyDeleted, &error)) { if (Fault(!download_item, download_extension_errors::kFileAlreadyDeleted,
&error)) {
Respond(Error(error)); Respond(Error(error));
return; return;
} }
...@@ -1505,7 +1509,8 @@ ExtensionFunction::ResponseAction DownloadsDragFunction::Run() { ...@@ -1505,7 +1509,8 @@ ExtensionFunction::ResponseAction DownloadsDragFunction::Run() {
dispatcher()->GetVisibleWebContents(); dispatcher()->GetVisibleWebContents();
std::string error; std::string error;
if (InvalidId(download_item, &error) || if (InvalidId(download_item, &error) ||
Fault(!web_contents, errors::kInvisibleContext, &error)) { Fault(!web_contents, download_extension_errors::kInvisibleContext,
&error)) {
return RespondNow(Error(error)); return RespondNow(Error(error));
} }
RecordApiFunctions(DOWNLOADS_FUNCTION_DRAG); RecordApiFunctions(DOWNLOADS_FUNCTION_DRAG);
...@@ -1603,7 +1608,7 @@ bool DownloadsGetFileIconFunction::RunAsync() { ...@@ -1603,7 +1608,7 @@ bool DownloadsGetFileIconFunction::RunAsync() {
browser_context(), include_incognito_information(), params->download_id); browser_context(), include_incognito_information(), params->download_id);
if (InvalidId(download_item, &error_) || if (InvalidId(download_item, &error_) ||
Fault(download_item->GetTargetFilePath().empty(), Fault(download_item->GetTargetFilePath().empty(),
errors::kEmptyFile, &error_)) download_extension_errors::kEmptyFile, &error_))
return false; return false;
// In-progress downloads return the intermediate filename for GetFullPath() // In-progress downloads return the intermediate filename for GetFullPath()
// which doesn't have the final extension. Therefore a good file icon can't be // which doesn't have the final extension. Therefore a good file icon can't be
...@@ -1625,7 +1630,7 @@ bool DownloadsGetFileIconFunction::RunAsync() { ...@@ -1625,7 +1630,7 @@ bool DownloadsGetFileIconFunction::RunAsync() {
void DownloadsGetFileIconFunction::OnIconURLExtracted(const std::string& url) { void DownloadsGetFileIconFunction::OnIconURLExtracted(const std::string& url) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (Fault(url.empty(), errors::kIconNotFound, &error_)) { if (Fault(url.empty(), download_extension_errors::kIconNotFound, &error_)) {
SendResponse(false); SendResponse(false);
return; return;
} }
...@@ -1801,10 +1806,10 @@ bool ExtensionDownloadsEventRouter::DetermineFilename( ...@@ -1801,10 +1806,10 @@ bool ExtensionDownloadsEventRouter::DetermineFilename(
// renderer, so don't DCHECK(!reported). // renderer, so don't DCHECK(!reported).
if (InvalidId(item, error) || if (InvalidId(item, error) ||
Fault(item->GetState() != DownloadItem::IN_PROGRESS, Fault(item->GetState() != DownloadItem::IN_PROGRESS,
errors::kNotInProgress, error) || download_extension_errors::kNotInProgress, error) ||
Fault(!data, errors::kUnexpectedDeterminer, error) || Fault(!data, download_extension_errors::kUnexpectedDeterminer, error) ||
Fault(data->DeterminerAlreadyReported(ext_id), Fault(data->DeterminerAlreadyReported(ext_id),
errors::kTooManyListeners, error)) download_extension_errors::kTooManyListeners, error))
return false; return false;
base::FilePath::StringType filename_str(const_filename.value()); base::FilePath::StringType filename_str(const_filename.value());
// Allow windows-style directory separators on all platforms. // Allow windows-style directory separators on all platforms.
...@@ -1818,9 +1823,9 @@ bool ExtensionDownloadsEventRouter::DetermineFilename( ...@@ -1818,9 +1823,9 @@ bool ExtensionDownloadsEventRouter::DetermineFilename(
// it will block forever waiting for this ext_id to report. // it will block forever waiting for this ext_id to report.
if (Fault(!data->DeterminerCallback(browser_context, ext_id, filename, if (Fault(!data->DeterminerCallback(browser_context, ext_id, filename,
conflict_action), conflict_action),
errors::kUnexpectedDeterminer, error) || download_extension_errors::kUnexpectedDeterminer, error) ||
Fault((!const_filename.empty() && !valid_filename), Fault((!const_filename.empty() && !valid_filename),
errors::kInvalidFilename, error)) download_extension_errors::kInvalidFilename, error))
return false; return false;
return true; return true;
} }
......
...@@ -13,8 +13,6 @@ ...@@ -13,8 +13,6 @@
namespace extensions { namespace extensions {
namespace errors = manifest_errors;
namespace { namespace {
SpellcheckDictionaryInfo* GetSpellcheckDictionaryInfo( SpellcheckDictionaryInfo* GetSpellcheckDictionaryInfo(
......
...@@ -47,8 +47,6 @@ using content::BrowserThread; ...@@ -47,8 +47,6 @@ using content::BrowserThread;
namespace extensions { namespace extensions {
namespace errors = manifest_errors;
namespace { namespace {
// The following enumeration is used in histograms matching // The following enumeration is used in histograms matching
...@@ -189,7 +187,7 @@ void InstalledLoader::Load(const ExtensionInfo& info, bool write_to_prefs) { ...@@ -189,7 +187,7 @@ void InstalledLoader::Load(const ExtensionInfo& info, bool write_to_prefs) {
GetCreationFlags(&info), GetCreationFlags(&info),
&error); &error);
} else { } else {
error = errors::kManifestUnreadable; error = manifest_errors::kManifestUnreadable;
} }
// Once installed, non-unpacked extensions cannot change their IDs (e.g., by // Once installed, non-unpacked extensions cannot change their IDs (e.g., by
...@@ -197,7 +195,7 @@ void InstalledLoader::Load(const ExtensionInfo& info, bool write_to_prefs) { ...@@ -197,7 +195,7 @@ void InstalledLoader::Load(const ExtensionInfo& info, bool write_to_prefs) {
// TODO(jstritar): migrate preferences when unpacked extensions change IDs. // TODO(jstritar): migrate preferences when unpacked extensions change IDs.
if (extension.get() && !Manifest::IsUnpackedLocation(extension->location()) && if (extension.get() && !Manifest::IsUnpackedLocation(extension->location()) &&
info.extension_id != extension->id()) { info.extension_id != extension->id()) {
error = errors::kCannotChangeExtensionID; error = manifest_errors::kCannotChangeExtensionID;
extension = nullptr; extension = nullptr;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment