summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRDevlin.Cronin@gmail.com <RDevlin.Cronin@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-17 09:33:49 +0000
committerRDevlin.Cronin@gmail.com <RDevlin.Cronin@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-17 09:33:49 +0000
commitfc670829eda3698d0385e1d6cffd4a5b63128383 (patch)
tree33f34d0aee29dc1caa17bfb0d07a3f842ccbb0ab
parent1d1b4a34f25746bb8d645051bf5aedff31781c0f (diff)
downloadchromium_src-fc670829eda3698d0385e1d6cffd4a5b63128383.zip
chromium_src-fc670829eda3698d0385e1d6cffd4a5b63128383.tar.gz
chromium_src-fc670829eda3698d0385e1d6cffd4a5b63128383.tar.bz2
Updating extensions code to use UTF16
Changes std::string error to string16 in various locations of the Extensions file, spanning up the tree from ExtensionErrorReporter and Extension::InitFromValue, with conversion to string16 beginning at extension_l10n_util::LocalizeExtension and Extension::Create. Later patches can continue/expand the conversion. BUG=71980 TEST=Run existing unit tests and browser tests, which have been adjusted for string16s. Review URL: http://codereview.chromium.org/8890086 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114917 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--AUTHORS2
-rw-r--r--chrome/browser/download/download_browsertest.cc4
-rw-r--r--chrome/browser/extensions/convert_user_script.cc23
-rw-r--r--chrome/browser/extensions/convert_user_script.h3
-rw-r--r--chrome/browser/extensions/convert_user_script_unittest.cc25
-rw-r--r--chrome/browser/extensions/crx_installer.cc50
-rw-r--r--chrome/browser/extensions/crx_installer.h8
-rw-r--r--chrome/browser/extensions/crx_installer_browsertest.cc2
-rw-r--r--chrome/browser/extensions/extension_browsertest.cc6
-rw-r--r--chrome/browser/extensions/extension_error_reporter.cc6
-rw-r--r--chrome/browser/extensions/extension_error_reporter.h10
-rw-r--r--chrome/browser/extensions/extension_install_ui.cc4
-rw-r--r--chrome/browser/extensions/extension_install_ui.h2
-rw-r--r--chrome/browser/extensions/extension_service.cc4
-rw-r--r--chrome/browser/extensions/extension_service_unittest.cc43
-rw-r--r--chrome/browser/extensions/sandboxed_extension_unpacker.cc84
-rw-r--r--chrome/browser/extensions/sandboxed_extension_unpacker.h6
-rw-r--r--chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc2
-rw-r--r--chrome/browser/extensions/webstore_installer.cc9
-rw-r--r--chrome/common/chrome_utility_messages.h2
-rw-r--r--chrome/common/extensions/extension.cc368
-rw-r--r--chrome/common/extensions/extension.h28
-rw-r--r--chrome/common/extensions/extension_error_utils.cc34
-rw-r--r--chrome/common/extensions/extension_error_utils.h28
-rw-r--r--chrome/common/extensions/extension_unpacker.cc2
-rw-r--r--chrome/common/extensions/extension_unpacker.h4
-rw-r--r--chrome/common/extensions/extension_unpacker_unittest.cc19
-rw-r--r--chrome/common/extensions/manifest.cc4
-rw-r--r--chrome/common/extensions/manifest.h2
-rw-r--r--chrome/common/extensions/manifest_unittest.cc25
30 files changed, 449 insertions, 360 deletions
diff --git a/AUTHORS b/AUTHORS
index eac1b5b..1b013b3 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -148,4 +148,4 @@ Intel Corporation <*@intel.com>
Halton Huo <halton.huo@gmail.com>
Shiliu Wang <aofdwsl@gmail.com>
Gao Chun <gaochun.dev@gmail.com>
-Devlin Cronin <RDevlin.Cronin@gmail.com>
+Devlin Cronin <rdevlin.cronin@gmail.com>
diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc
index 96b0401..5096eb2 100644
--- a/chrome/browser/download/download_browsertest.cc
+++ b/chrome/browser/download/download_browsertest.cc
@@ -225,7 +225,7 @@ class MockAbortExtensionInstallUI : public ExtensionInstallUI {
}
virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {}
- virtual void OnInstallFailure(const std::string& error) {}
+ virtual void OnInstallFailure(const string16& error) {}
};
// Mock that simulates a permissions dialog where the user allows
@@ -241,7 +241,7 @@ class MockAutoConfirmExtensionInstallUI : public ExtensionInstallUI {
}
virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {}
- virtual void OnInstallFailure(const std::string& error) {}
+ virtual void OnInstallFailure(const string16& error) {}
};
static DownloadManager* DownloadManagerForBrowser(Browser* browser) {
diff --git a/chrome/browser/extensions/convert_user_script.cc b/chrome/browser/extensions/convert_user_script.cc
index b7b3b8f..dea6035 100644
--- a/chrome/browser/extensions/convert_user_script.cc
+++ b/chrome/browser/extensions/convert_user_script.cc
@@ -14,6 +14,7 @@
#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/extensions/user_script_master.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/extension.h"
@@ -28,34 +29,34 @@ namespace values = extension_manifest_values;
scoped_refptr<Extension> ConvertUserScriptToExtension(
const FilePath& user_script_path, const GURL& original_url,
- std::string* error) {
+ string16* error) {
std::string content;
if (!file_util::ReadFileToString(user_script_path, &content)) {
- *error = "Could not read source file.";
+ *error = ASCIIToUTF16("Could not read source file.");
return NULL;
}
if (!IsStringUTF8(content)) {
- *error = "User script must be UTF8 encoded.";
+ *error = ASCIIToUTF16("User script must be UTF8 encoded.");
return NULL;
}
UserScript script;
if (!UserScriptMaster::ScriptReloader::ParseMetadataHeader(content,
&script)) {
- *error = "Invalid script header.";
+ *error = ASCIIToUTF16("Invalid script header.");
return NULL;
}
FilePath user_data_temp_dir = extension_file_util::GetUserDataTempDir();
if (user_data_temp_dir.empty()) {
- *error = "Could not get path to profile temporary directory.";
+ *error = ASCIIToUTF16("Could not get path to profile temporary directory.");
return NULL;
}
ScopedTempDir temp_dir;
if (!temp_dir.CreateUniqueTempDirUnderPath(user_data_temp_dir)) {
- *error = "Could not create temporary directory.";
+ *error = ASCIIToUTF16("Could not create temporary directory.");
return NULL;
}
@@ -144,23 +145,27 @@ scoped_refptr<Extension> ConvertUserScriptToExtension(
Extension::kManifestFilename);
JSONFileValueSerializer serializer(manifest_path);
if (!serializer.Serialize(*root)) {
- *error = "Could not write JSON.";
+ *error = ASCIIToUTF16("Could not write JSON.");
return NULL;
}
// Write the script file.
if (!file_util::CopyFile(user_script_path,
temp_dir.path().AppendASCII("script.js"))) {
- *error = "Could not copy script file.";
+ *error = ASCIIToUTF16("Could not copy script file.");
return NULL;
}
+ // TODO(rdevlin.cronin): Continue removing std::string errors and replacing
+ // with string16
+ std::string utf8_error;
scoped_refptr<Extension> extension = Extension::Create(
temp_dir.path(),
Extension::INTERNAL,
*root,
Extension::NO_FLAGS,
- error);
+ &utf8_error);
+ *error = UTF8ToUTF16(utf8_error);
if (!extension) {
NOTREACHED() << "Could not init extension " << *error;
return NULL;
diff --git a/chrome/browser/extensions/convert_user_script.h b/chrome/browser/extensions/convert_user_script.h
index ee502f8..8a8933a 100644
--- a/chrome/browser/extensions/convert_user_script.h
+++ b/chrome/browser/extensions/convert_user_script.h
@@ -9,6 +9,7 @@
#include <string>
#include "base/memory/ref_counted.h"
+#include "base/string16.h"
class Extension;
class FilePath;
@@ -22,6 +23,6 @@ class GURL;
// NOTE: The caller takes ownership of the directory at extension->path() on the
// returned object.
scoped_refptr<Extension> ConvertUserScriptToExtension(
- const FilePath& user_script, const GURL& original_url, std::string* error);
+ const FilePath& user_script, const GURL& original_url, string16* error);
#endif // CHROME_BROWSER_EXTENSIONS_CONVERT_USER_SCRIPT_H_
diff --git a/chrome/browser/extensions/convert_user_script_unittest.cc b/chrome/browser/extensions/convert_user_script_unittest.cc
index 38b106a..a11056e 100644
--- a/chrome/browser/extensions/convert_user_script_unittest.cc
+++ b/chrome/browser/extensions/convert_user_script_unittest.cc
@@ -10,6 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/extensions/convert_user_script.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/extension.h"
@@ -30,12 +31,12 @@ TEST(ExtensionFromUserScript, Basic) {
test_file = test_file.AppendASCII("extensions")
.AppendASCII("user_script_basic.user.js");
- std::string error;
+ string16 error;
scoped_refptr<Extension> extension(ConvertUserScriptToExtension(
test_file, GURL("http://www.google.com/foo"), &error));
ASSERT_TRUE(extension.get());
- EXPECT_EQ("", error);
+ EXPECT_EQ(ASCIIToUTF16(""), error);
// Use a temp dir so that the extensions dir will clean itself up.
ScopedTempDir ext_dir;
@@ -73,12 +74,12 @@ TEST(ExtensionFromUserScript, NoMetdata) {
test_file = test_file.AppendASCII("extensions")
.AppendASCII("user_script_no_metadata.user.js");
- std::string error;
+ string16 error;
scoped_refptr<Extension> extension(ConvertUserScriptToExtension(
test_file, GURL("http://www.google.com/foo/bar.user.js?monkey"), &error));
ASSERT_TRUE(extension.get());
- EXPECT_EQ("", error);
+ EXPECT_EQ(ASCIIToUTF16(""), error);
// Use a temp dir so that the extensions dir will clean itself up.
ScopedTempDir ext_dir;
@@ -116,12 +117,12 @@ TEST(ExtensionFromUserScript, NotUTF8) {
test_file = test_file.AppendASCII("extensions")
.AppendASCII("user_script_not_utf8.user.js");
- std::string error;
+ string16 error;
scoped_refptr<Extension> extension(ConvertUserScriptToExtension(
test_file, GURL("http://www.google.com/foo/bar.user.js?monkey"), &error));
ASSERT_FALSE(extension.get());
- EXPECT_EQ("User script must be UTF8 encoded.", error);
+ EXPECT_EQ(ASCIIToUTF16("User script must be UTF8 encoded."), error);
}
TEST(ExtensionFromUserScript, RunAtDocumentStart) {
@@ -130,12 +131,12 @@ TEST(ExtensionFromUserScript, RunAtDocumentStart) {
test_file = test_file.AppendASCII("extensions")
.AppendASCII("user_script_run_at_start.user.js");
- std::string error;
+ string16 error;
scoped_refptr<Extension> extension(ConvertUserScriptToExtension(
test_file, GURL("http://www.google.com/foo"), &error));
ASSERT_TRUE(extension.get());
- EXPECT_EQ("", error);
+ EXPECT_EQ(ASCIIToUTF16(""), error);
// Use a temp dir so that the extensions dir will clean itself up.
ScopedTempDir ext_dir;
@@ -159,12 +160,12 @@ TEST(ExtensionFromUserScript, RunAtDocumentEnd) {
test_file = test_file.AppendASCII("extensions")
.AppendASCII("user_script_run_at_end.user.js");
- std::string error;
+ string16 error;
scoped_refptr<Extension> extension(ConvertUserScriptToExtension(
test_file, GURL("http://www.google.com/foo"), &error));
ASSERT_TRUE(extension.get());
- EXPECT_EQ("", error);
+ EXPECT_EQ(ASCIIToUTF16(""), error);
// Use a temp dir so that the extensions dir will clean itself up.
ScopedTempDir ext_dir;
@@ -189,12 +190,12 @@ TEST(ExtensionFromUserScript, RunAtDocumentIdle) {
.AppendASCII("user_script_run_at_idle.user.js");
ASSERT_TRUE(file_util::PathExists(test_file)) << test_file.value();
- std::string error;
+ string16 error;
scoped_refptr<Extension> extension(ConvertUserScriptToExtension(
test_file, GURL("http://www.google.com/foo"), &error));
ASSERT_TRUE(extension.get());
- EXPECT_EQ("", error);
+ EXPECT_EQ(ASCIIToUTF16(""), error);
// Use a temp dir so that the extensions dir will clean itself up.
ScopedTempDir ext_dir;
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc
index 48f1155..d2fe1c9 100644
--- a/chrome/browser/extensions/crx_installer.cc
+++ b/chrome/browser/extensions/crx_installer.cc
@@ -193,7 +193,7 @@ void CrxInstaller::InstallUserScript(const FilePath& source_file,
}
void CrxInstaller::ConvertUserScriptOnFileThread() {
- std::string error;
+ string16 error;
scoped_refptr<Extension> extension =
ConvertUserScriptToExtension(source_file_, download_url_, &error);
if (!extension) {
@@ -213,7 +213,7 @@ void CrxInstaller::InstallWebApp(const WebApplicationInfo& web_app) {
void CrxInstaller::ConvertWebAppOnFileThread(
const WebApplicationInfo& web_app) {
- std::string error;
+ string16 error;
scoped_refptr<Extension> extension(
ConvertWebAppToExtension(web_app, base::Time::Now()));
if (!extension) {
@@ -228,27 +228,27 @@ void CrxInstaller::ConvertWebAppOnFileThread(
}
bool CrxInstaller::AllowInstall(const Extension* extension,
- std::string* error) {
+ string16* error) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK(error);
// Make sure the expected id matches.
if (!expected_id_.empty() && expected_id_ != extension->id()) {
- *error = base::StringPrintf(
+ *error = ASCIIToUTF16(base::StringPrintf(
"ID in new CRX manifest (%s) does not match expected id (%s)",
extension->id().c_str(),
- expected_id_.c_str());
+ expected_id_.c_str()));
return false;
}
if (expected_version_.get() &&
!expected_version_->Equals(*extension->version())) {
- *error = base::StringPrintf(
+ *error = ASCIIToUTF16(base::StringPrintf(
"Version in new CRX %s manifest (%s) does not match expected "
"version (%s)",
extension->id().c_str(),
expected_version_->GetString().c_str(),
- extension->version()->GetString().c_str());
+ extension->version()->GetString().c_str()));
return false;
}
@@ -257,7 +257,7 @@ bool CrxInstaller::AllowInstall(const Extension* extension,
return true;
if (!extensions_enabled_) {
- *error = "Extensions are not enabled.";
+ *error = ASCIIToUTF16("Extensions are not enabled.");
return false;
}
@@ -269,9 +269,9 @@ bool CrxInstaller::AllowInstall(const Extension* extension,
if (!download_url_.SchemeIsFile() &&
apps_require_extension_mime_type_ &&
original_mime_type_ != Extension::kMimeType) {
- *error = base::StringPrintf(
+ *error = ASCIIToUTF16(base::StringPrintf(
"Apps must be served with content type %s.",
- Extension::kMimeType);
+ Extension::kMimeType));
return false;
}
@@ -283,7 +283,7 @@ bool CrxInstaller::AllowInstall(const Extension* extension,
// from the gallery.
// TODO(erikkay) Apply this rule for paid extensions and themes as well.
if (extension->UpdatesFromGallery()) {
- *error = l10n_util::GetStringFUTF8(
+ *error = l10n_util::GetStringFUTF16(
IDS_EXTENSION_DISALLOW_NON_DOWNLOADED_GALLERY_INSTALLS,
l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE));
return false;
@@ -301,8 +301,8 @@ bool CrxInstaller::AllowInstall(const Extension* extension,
for (URLPatternSet::const_iterator i = patterns.begin();
i != patterns.end(); ++i) {
if (!pattern.MatchesHost(i->host())) {
- *error = base::StringPrintf(
- "Apps must be served from the host that they affect.");
+ *error = ASCIIToUTF16(base::StringPrintf(
+ "Apps must be served from the host that they affect."));
return false;
}
}
@@ -312,7 +312,7 @@ bool CrxInstaller::AllowInstall(const Extension* extension,
return true;
}
-void CrxInstaller::OnUnpackFailure(const std::string& error_message) {
+void CrxInstaller::OnUnpackFailure(const string16& error_message) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
UMA_HISTOGRAM_ENUMERATION("Extensions.UnpackFailureInstallSource",
@@ -351,7 +351,7 @@ void CrxInstaller::OnUnpackSuccess(const FilePath& temp_dir,
// the temp dir.
unpacked_extension_root_ = extension_dir;
- std::string error;
+ string16 error;
if (!AllowInstall(extension, &error)) {
ReportFailureFromFileThread(error);
return;
@@ -378,14 +378,14 @@ void CrxInstaller::ConfirmInstall() {
VLOG(1) << "This extension: " << extension_->id()
<< " is blacklisted. Install failed.";
ReportFailureFromUIThread(
- l10n_util::GetStringUTF8(IDS_EXTENSION_CANT_INSTALL_BLACKLISTED));
+ l10n_util::GetStringUTF16(IDS_EXTENSION_CANT_INSTALL_BLACKLISTED));
return;
}
if (!frontend_weak_->extension_prefs()->IsExtensionAllowedByPolicy(
extension_->id(), install_source_)) {
ReportFailureFromUIThread(
- l10n_util::GetStringUTF8(IDS_EXTENSION_CANT_INSTALL_POLICY_BLACKLIST));
+ l10n_util::GetStringUTF16(IDS_EXTENSION_CANT_INSTALL_POLICY_BLACKLIST));
return;
}
@@ -395,7 +395,7 @@ void CrxInstaller::ConfirmInstall() {
GetHostedAppByOverlappingWebExtent(extension_->web_extent());
if (overlapping_extension &&
overlapping_extension->id() != extension_->id()) {
- ReportFailureFromUIThread(l10n_util::GetStringFUTF8(
+ ReportFailureFromUIThread(l10n_util::GetStringFUTF16(
IDS_EXTENSION_OVERLAPPING_WEB_EXTENT,
UTF8ToUTF16(overlapping_extension->name())));
return;
@@ -413,7 +413,7 @@ void CrxInstaller::ConfirmInstall() {
if (is_gallery_install() && entry.get() && original_manifest_.get()) {
if (!(original_manifest_->Equals(entry->parsed_manifest.get()))) {
ReportFailureFromUIThread(
- l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_INVALID));
+ l10n_util::GetStringUTF16(IDS_EXTENSION_MANIFEST_INVALID));
return;
}
whitelisted = true;
@@ -474,7 +474,7 @@ void CrxInstaller::CompleteInstall() {
Version::GetVersionFromString(current_version_));
if (current_version->CompareTo(*(extension_->version())) > 0) {
ReportFailureFromFileThread(
- l10n_util::GetStringUTF8(IDS_EXTENSION_CANT_DOWNGRADE_VERSION));
+ l10n_util::GetStringUTF16(IDS_EXTENSION_CANT_DOWNGRADE_VERSION));
return;
}
}
@@ -493,7 +493,7 @@ void CrxInstaller::CompleteInstall() {
install_directory_);
if (version_dir.empty()) {
ReportFailureFromFileThread(
- l10n_util::GetStringUTF8(
+ l10n_util::GetStringUTF16(
IDS_EXTENSION_MOVE_DIRECTORY_TO_PROFILE_FAILED));
return;
}
@@ -503,6 +503,8 @@ void CrxInstaller::CompleteInstall() {
// just moved the extension.
// TODO(aa): All paths to resources inside extensions should be created
// lazily and based on the Extension's root path at that moment.
+ // TODO(rdevlin.cronin): Continue removing std::string errors and replacing
+ // with string16
std::string error;
extension_ = extension_file_util::LoadExtension(
version_dir,
@@ -514,7 +516,7 @@ void CrxInstaller::CompleteInstall() {
ReportSuccessFromFileThread();
}
-void CrxInstaller::ReportFailureFromFileThread(const std::string& error) {
+void CrxInstaller::ReportFailureFromFileThread(const string16& error) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
if (!BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
@@ -522,14 +524,14 @@ void CrxInstaller::ReportFailureFromFileThread(const std::string& error) {
NOTREACHED();
}
-void CrxInstaller::ReportFailureFromUIThread(const std::string& error) {
+void CrxInstaller::ReportFailureFromUIThread(const string16& error) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
content::NotificationService* service =
content::NotificationService::current();
service->Notify(chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR,
content::Source<CrxInstaller>(this),
- content::Details<const std::string>(&error));
+ content::Details<const string16>(&error));
// This isn't really necessary, it is only used because unit tests expect to
// see errors get reported via this interface.
diff --git a/chrome/browser/extensions/crx_installer.h b/chrome/browser/extensions/crx_installer.h
index 192ef50..8f6584a 100644
--- a/chrome/browser/extensions/crx_installer.h
+++ b/chrome/browser/extensions/crx_installer.h
@@ -199,10 +199,10 @@ class CrxInstaller
// Called after OnUnpackSuccess as a last check to see whether the install
// should complete.
- bool AllowInstall(const Extension* extension, std::string* error);
+ bool AllowInstall(const Extension* extension, string16* error);
// SandboxedExtensionUnpackerClient
- virtual void OnUnpackFailure(const std::string& error_message) OVERRIDE;
+ virtual void OnUnpackFailure(const string16& error_message) OVERRIDE;
virtual void OnUnpackSuccess(const FilePath& temp_dir,
const FilePath& extension_dir,
const base::DictionaryValue* original_manifest,
@@ -221,8 +221,8 @@ class CrxInstaller
void CompleteInstall();
// Result reporting.
- void ReportFailureFromFileThread(const std::string& error);
- void ReportFailureFromUIThread(const std::string& error);
+ void ReportFailureFromFileThread(const string16& error);
+ void ReportFailureFromUIThread(const string16& error);
void ReportSuccessFromFileThread();
void ReportSuccessFromUIThread();
void NotifyCrxInstallComplete(const Extension* extension);
diff --git a/chrome/browser/extensions/crx_installer_browsertest.cc b/chrome/browser/extensions/crx_installer_browsertest.cc
index 1151822..c3aa49c 100644
--- a/chrome/browser/extensions/crx_installer_browsertest.cc
+++ b/chrome/browser/extensions/crx_installer_browsertest.cc
@@ -31,7 +31,7 @@ class MockInstallUI : public ExtensionInstallUI {
void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {
MessageLoopForUI::current()->Quit();
}
- void OnInstallFailure(const std::string& error) {
+ void OnInstallFailure(const string16& error) {
ADD_FAILURE() << "install failed";
MessageLoopForUI::current()->Quit();
}
diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc
index 6a0173f..f660393 100644
--- a/chrome/browser/extensions/extension_browsertest.cc
+++ b/chrome/browser/extensions/extension_browsertest.cc
@@ -216,7 +216,7 @@ class MockAbortExtensionInstallUI : public ExtensionInstallUI {
virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {}
- virtual void OnInstallFailure(const std::string& error) {}
+ virtual void OnInstallFailure(const string16& error) {}
};
class MockAutoConfirmExtensionInstallUI : public ExtensionInstallUI {
@@ -302,9 +302,9 @@ const Extension* ExtensionBrowserTest::InstallOrUpdateExtension(
VLOG(1) << " " << (*it)->id();
VLOG(1) << "Errors follow:";
- const std::vector<std::string>* errors =
+ const std::vector<string16>* errors =
ExtensionErrorReporter::GetInstance()->GetErrors();
- for (std::vector<std::string>::const_iterator iter = errors->begin();
+ for (std::vector<string16>::const_iterator iter = errors->begin();
iter != errors->end(); ++iter)
VLOG(1) << *iter;
diff --git a/chrome/browser/extensions/extension_error_reporter.cc b/chrome/browser/extensions/extension_error_reporter.cc
index 0cfb883..1c2b8d1 100644
--- a/chrome/browser/extensions/extension_error_reporter.cc
+++ b/chrome/browser/extensions/extension_error_reporter.cc
@@ -35,7 +35,7 @@ ExtensionErrorReporter::ExtensionErrorReporter(bool enable_noisy_errors)
ExtensionErrorReporter::~ExtensionErrorReporter() {}
-void ExtensionErrorReporter::ReportError(const std::string& message,
+void ExtensionErrorReporter::ReportError(const string16& message,
bool be_noisy) {
// NOTE: There won't be a ui_loop_ in the unit test environment.
if (ui_loop_ && MessageLoop::current() != ui_loop_) {
@@ -58,11 +58,11 @@ void ExtensionErrorReporter::ReportError(const std::string& message,
if (enable_noisy_errors_ && be_noisy) {
browser::ShowErrorBox(NULL,
UTF8ToUTF16("Extension error"),
- UTF8ToUTF16(message));
+ message);
}
}
-const std::vector<std::string>* ExtensionErrorReporter::GetErrors() {
+const std::vector<string16>* ExtensionErrorReporter::GetErrors() {
return &errors_;
}
diff --git a/chrome/browser/extensions/extension_error_reporter.h b/chrome/browser/extensions/extension_error_reporter.h
index 8753c39..c49968b 100644
--- a/chrome/browser/extensions/extension_error_reporter.h
+++ b/chrome/browser/extensions/extension_error_reporter.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,6 +9,8 @@
#include <string>
#include <vector>
+#include "base/string16.h"
+
class MessageLoop;
// Exposes an easy way for the various components of the extension system to
@@ -30,10 +32,10 @@ class ExtensionErrorReporter {
// Report an error. Errors always go to VLOG(1). Optionally, they can also
// cause a noisy alert box. This method can be called from any thread.
- void ReportError(const std::string& message, bool be_noisy);
+ void ReportError(const string16& message, bool be_noisy);
// Get the errors that have been reported so far.
- const std::vector<std::string>* GetErrors();
+ const std::vector<string16>* GetErrors();
// Clear the list of errors reported so far.
void ClearErrors();
@@ -45,7 +47,7 @@ class ExtensionErrorReporter {
~ExtensionErrorReporter();
MessageLoop* ui_loop_;
- std::vector<std::string> errors_;
+ std::vector<string16> errors_;
bool enable_noisy_errors_;
};
diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc
index c1fb827..0491d6a 100644
--- a/chrome/browser/extensions/extension_install_ui.cc
+++ b/chrome/browser/extensions/extension_install_ui.cc
@@ -304,7 +304,7 @@ bool disable_failure_ui_for_tests = false;
} // namespace
-void ExtensionInstallUI::OnInstallFailure(const std::string& error) {
+void ExtensionInstallUI::OnInstallFailure(const string16& error) {
DCHECK(ui_loop_ == MessageLoop::current());
Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
@@ -313,7 +313,7 @@ void ExtensionInstallUI::OnInstallFailure(const std::string& error) {
browser::ShowErrorBox(
browser ? browser->window()->GetNativeHandle() : NULL,
l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALL_FAILURE_TITLE),
- UTF8ToUTF16(error));
+ error);
}
void ExtensionInstallUI::SetIcon(SkBitmap* image) {
diff --git a/chrome/browser/extensions/extension_install_ui.h b/chrome/browser/extensions/extension_install_ui.h
index e434029..b85c7b2 100644
--- a/chrome/browser/extensions/extension_install_ui.h
+++ b/chrome/browser/extensions/extension_install_ui.h
@@ -145,7 +145,7 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer {
virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon);
// Installation failed. This is declared virtual for testing.
- virtual void OnInstallFailure(const std::string& error);
+ virtual void OnInstallFailure(const string16& error);
// ImageLoadingTracker::Observer:
virtual void OnImageLoaded(
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 8460e02..1a0febe 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -2277,9 +2277,9 @@ void ExtensionService::ReportExtensionLoadError(
content::Details<const std::string>(&error));
std::string path_str = UTF16ToUTF8(extension_path.LossyDisplayName());
- std::string message = base::StringPrintf(
+ string16 message = ASCIIToUTF16(base::StringPrintf(
"Could not load extension from '%s'. %s",
- path_str.c_str(), error.c_str());
+ path_str.c_str(), error.c_str()));
ExtensionErrorReporter::GetInstance()->ReportError(message, be_noisy);
}
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index f276497..0e95e5e 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -101,14 +101,15 @@ struct ExtensionsOrder {
}
};
-static std::vector<std::string> GetErrors() {
- const std::vector<std::string>* errors =
+static std::vector<string16> GetErrors() {
+ const std::vector<string16>* errors =
ExtensionErrorReporter::GetInstance()->GetErrors();
- std::vector<std::string> ret_val;
+ std::vector<string16> ret_val;
- for (std::vector<std::string>::const_iterator iter = errors->begin();
+ for (std::vector<string16>::const_iterator iter = errors->begin();
iter != errors->end(); ++iter) {
- if (iter->find(".svn") == std::string::npos) {
+ std::string utf8_error = UTF16ToUTF8(*iter);
+ if (utf8_error.find(".svn") == std::string::npos) {
ret_val.push_back(*iter);
}
}
@@ -652,7 +653,7 @@ class ExtensionServiceTest
const Extension* WaitForCrxInstall(const FilePath& path,
InstallState install_state) {
loop_.RunAllPending();
- std::vector<std::string> errors = GetErrors();
+ std::vector<string16> errors = GetErrors();
const Extension* extension = NULL;
if (install_state != INSTALL_FAILED) {
if (install_state == INSTALL_NEW)
@@ -667,7 +668,7 @@ class ExtensionServiceTest
extension = loaded_[0];
EXPECT_TRUE(service_->GetExtensionById(extension->id(), false)) <<
path.value();
- for (std::vector<std::string>::iterator err = errors.begin();
+ for (std::vector<string16>::iterator err = errors.begin();
err != errors.end(); ++err) {
LOG(ERROR) << *err;
}
@@ -710,7 +711,7 @@ class ExtensionServiceTest
service_->UpdateExtension(id, path, GURL(), NULL);
loop_.RunAllPending();
- std::vector<std::string> errors = GetErrors();
+ std::vector<string16> errors = GetErrors();
int error_count = errors.size();
int enabled_extension_count =
service_->extensions()->size();
@@ -1129,21 +1130,25 @@ TEST_F(ExtensionServiceTest, LoadAllExtensionsFromDirectoryFail) {
ASSERT_EQ(4u, GetErrors().size());
ASSERT_EQ(0u, loaded_.size());
- EXPECT_TRUE(MatchPattern(GetErrors()[0],
+ EXPECT_TRUE(MatchPattern(UTF16ToUTF8(GetErrors()[0]),
std::string("Could not load extension from '*'. ") +
- extension_manifest_errors::kManifestUnreadable)) << GetErrors()[0];
+ extension_manifest_errors::kManifestUnreadable)) <<
+ UTF16ToUTF8(GetErrors()[0]);
- EXPECT_TRUE(MatchPattern(GetErrors()[1],
+ EXPECT_TRUE(MatchPattern(UTF16ToUTF8(GetErrors()[1]),
std::string("Could not load extension from '*'. ") +
- extension_manifest_errors::kManifestUnreadable)) << GetErrors()[1];
+ extension_manifest_errors::kManifestUnreadable)) <<
+ UTF16ToUTF8(GetErrors()[1]);
- EXPECT_TRUE(MatchPattern(GetErrors()[2],
+ EXPECT_TRUE(MatchPattern(UTF16ToUTF8(GetErrors()[2]),
std::string("Could not load extension from '*'. ") +
- extension_manifest_errors::kMissingFile)) << GetErrors()[2];
+ extension_manifest_errors::kMissingFile)) <<
+ UTF16ToUTF8(GetErrors()[2]);
- EXPECT_TRUE(MatchPattern(GetErrors()[3],
+ EXPECT_TRUE(MatchPattern(UTF16ToUTF8(GetErrors()[3]),
std::string("Could not load extension from '*'. ") +
- extension_manifest_errors::kManifestUnreadable)) << GetErrors()[3];
+ extension_manifest_errors::kManifestUnreadable)) <<
+ UTF16ToUTF8(GetErrors()[3]);
};
// Test that partially deleted extensions are cleaned up during startup
@@ -1419,7 +1424,7 @@ TEST_F(ExtensionServiceTest, InstallUserScript) {
GURL("http://www.aaronboodman.com/scripts/user_script_basic.user.js"));
loop_.RunAllPending();
- std::vector<std::string> errors = GetErrors();
+ std::vector<string16> errors = GetErrors();
EXPECT_TRUE(installed_) << "Nothing was installed.";
ASSERT_EQ(1u, loaded_.size()) << "Nothing was loaded.";
EXPECT_EQ(0u, errors.size()) << "There were errors: "
@@ -2523,8 +2528,8 @@ TEST_F(ExtensionServiceTest, WillNotLoadBlacklistedExtensionsFromDirectory) {
// Load extensions.
service_->Init();
- std::vector<std::string> errors = GetErrors();
- for (std::vector<std::string>::iterator err = errors.begin();
+ std::vector<string16> errors = GetErrors();
+ for (std::vector<string16>::iterator err = errors.begin();
err != errors.end(); ++err) {
LOG(ERROR) << *err;
}
diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker.cc b/chrome/browser/extensions/sandboxed_extension_unpacker.cc
index c031f97..4178bda 100644
--- a/chrome/browser/extensions/sandboxed_extension_unpacker.cc
+++ b/chrome/browser/extensions/sandboxed_extension_unpacker.cc
@@ -129,7 +129,7 @@ bool SandboxedExtensionUnpacker::CreateTempDirectory() {
if (user_data_temp_dir.empty()) {
ReportFailure(
COULD_NOT_GET_TEMP_DIRECTORY,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
ASCIIToUTF16("COULD_NOT_GET_TEMP_DIRECTORY")));
return false;
@@ -138,7 +138,7 @@ bool SandboxedExtensionUnpacker::CreateTempDirectory() {
if (!temp_dir_.CreateUniqueTempDirUnderPath(user_data_temp_dir)) {
ReportFailure(
COULD_NOT_CREATE_TEMP_DIRECTORY,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
ASCIIToUTF16("COULD_NOT_CREATE_TEMP_DIRECTORY")));
return false;
@@ -178,7 +178,7 @@ void SandboxedExtensionUnpacker::Start() {
// Failed to copy extension file to temporary directory.
ReportFailure(
FAILED_TO_COPY_EXTENSION_FILE_TO_TEMP_DIRECTORY,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
ASCIIToUTF16("FAILED_TO_COPY_EXTENSION_FILE_TO_TEMP_DIRECTORY")));
return;
@@ -202,7 +202,7 @@ void SandboxedExtensionUnpacker::Start() {
<< temp_crx_path.value();
ReportFailure(
COULD_NOT_GET_SANDBOX_FRIENDLY_PATH,
- l10n_util::GetStringUTF8(IDS_EXTENSION_UNPACK_FAILED));
+ l10n_util::GetStringUTF16(IDS_EXTENSION_UNPACK_FAILED));
return;
}
PATH_LENGTH_HISTOGRAM("Extensions.SandboxUnpackLinkFreeCrxPathLength",
@@ -253,7 +253,7 @@ void SandboxedExtensionUnpacker::OnProcessCrashed(int exit_code) {
// Utility process crashed while trying to install.
ReportFailure(
UTILITY_PROCESS_CRASHED_WHILE_TRYING_TO_INSTALL,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
ASCIIToUTF16("UTILITY_PROCESS_CRASHED_WHILE_TRYING_TO_INSTALL")));
}
@@ -286,15 +286,18 @@ void SandboxedExtensionUnpacker::OnUnpackExtensionSucceeded(
// extension.
// Localize manifest now, so confirm UI gets correct extension name.
- std::string error;
+
+ // TODO(rdevlin.cronin): Continue removing std::string errors and replacing
+ // with string16
+ std::string utf8_error;
if (!extension_l10n_util::LocalizeExtension(extension_root_,
final_manifest.get(),
- &error)) {
+ &utf8_error)) {
ReportFailure(
COULD_NOT_LOCALIZE_EXTENSION,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_ERROR_MESSAGE,
- ASCIIToUTF16(error)));
+ UTF8ToUTF16(utf8_error)));
return;
}
@@ -303,12 +306,13 @@ void SandboxedExtensionUnpacker::OnUnpackExtensionSucceeded(
location_,
*final_manifest,
Extension::REQUIRE_KEY | creation_flags_,
- &error);
+ &utf8_error);
+
if (!extension_.get()) {
ReportFailure(
INVALID_MANIFEST,
- std::string("Manifest is invalid: ") + error);
+ ASCIIToUTF16("Manifest is invalid: " + utf8_error));
return;
}
@@ -322,14 +326,14 @@ void SandboxedExtensionUnpacker::OnUnpackExtensionSucceeded(
}
void SandboxedExtensionUnpacker::OnUnpackExtensionFailed(
- const std::string& error) {
+ const string16& error) {
CHECK(BrowserThread::CurrentlyOn(thread_identifier_));
got_response_ = true;
ReportFailure(
UNPACKER_CLIENT_FAILED,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_ERROR_MESSAGE,
- ASCIIToUTF16(error)));
+ error));
}
bool SandboxedExtensionUnpacker::ValidateSignature() {
@@ -356,7 +360,7 @@ bool SandboxedExtensionUnpacker::ValidateSignature() {
ReportFailure(
CRX_FILE_NOT_READABLE,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_ERROR_CODE,
ASCIIToUTF16("CRX_FILE_NOT_READABLE")));
return false;
@@ -376,7 +380,7 @@ bool SandboxedExtensionUnpacker::ValidateSignature() {
// Invalid crx header
ReportFailure(
CRX_HEADER_INVALID,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_ERROR_CODE,
ASCIIToUTF16("CRX_HEADER_INVALID")));
return false;
@@ -386,7 +390,7 @@ bool SandboxedExtensionUnpacker::ValidateSignature() {
// Bad magic number
ReportFailure(
CRX_MAGIC_NUMBER_INVALID,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_ERROR_CODE,
ASCIIToUTF16("CRX_MAGIC_NUMBER_INVALID")));
return false;
@@ -394,7 +398,7 @@ bool SandboxedExtensionUnpacker::ValidateSignature() {
if (header.version != kCurrentVersion) {
// Bad version numer
ReportFailure(CRX_VERSION_NUMBER_INVALID,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_ERROR_CODE,
ASCIIToUTF16("CRX_VERSION_NUMBER_INVALID")));
return false;
@@ -404,7 +408,7 @@ bool SandboxedExtensionUnpacker::ValidateSignature() {
// Excessively large key or signature
ReportFailure(
CRX_EXCESSIVELY_LARGE_KEY_OR_SIGNATURE,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_ERROR_CODE,
ASCIIToUTF16("CRX_EXCESSIVELY_LARGE_KEY_OR_SIGNATURE")));
return false;
@@ -413,7 +417,7 @@ bool SandboxedExtensionUnpacker::ValidateSignature() {
// Key length is zero
ReportFailure(
CRX_ZERO_KEY_LENGTH,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_ERROR_CODE,
ASCIIToUTF16("CRX_ZERO_KEY_LENGTH")));
return false;
@@ -422,7 +426,7 @@ bool SandboxedExtensionUnpacker::ValidateSignature() {
// Signature length is zero
ReportFailure(
CRX_ZERO_SIGNATURE_LENGTH,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_ERROR_CODE,
ASCIIToUTF16("CRX_ZERO_SIGNATURE_LENGTH")));
return false;
@@ -435,7 +439,7 @@ bool SandboxedExtensionUnpacker::ValidateSignature() {
// Invalid public key
ReportFailure(
CRX_PUBLIC_KEY_INVALID,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_ERROR_CODE,
ASCIIToUTF16("CRX_PUBLIC_KEY_INVALID")));
return false;
@@ -449,7 +453,7 @@ bool SandboxedExtensionUnpacker::ValidateSignature() {
// Invalid signature
ReportFailure(
CRX_SIGNATURE_INVALID,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_ERROR_CODE,
ASCIIToUTF16("CRX_SIGNATURE_INVALID")));
return false;
@@ -466,7 +470,7 @@ bool SandboxedExtensionUnpacker::ValidateSignature() {
// caused by a public key in the wrong format (should encode algorithm).
ReportFailure(
CRX_SIGNATURE_VERIFICATION_INITIALIZATION_FAILED,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_ERROR_CODE,
ASCIIToUTF16("CRX_SIGNATURE_VERIFICATION_INITIALIZATION_FAILED")));
return false;
@@ -480,7 +484,7 @@ bool SandboxedExtensionUnpacker::ValidateSignature() {
// Signature verification failed
ReportFailure(
CRX_SIGNATURE_VERIFICATION_FAILED,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_ERROR_CODE,
ASCIIToUTF16("CRX_SIGNATURE_VERIFICATION_FAILED")));
return false;
@@ -492,7 +496,7 @@ bool SandboxedExtensionUnpacker::ValidateSignature() {
}
void SandboxedExtensionUnpacker::ReportFailure(FailureReason reason,
- const std::string& error) {
+ const string16& error) {
UMA_HISTOGRAM_ENUMERATION("Extensions.SandboxUnpackFailureReason",
reason, NUM_FAILURE_REASONS);
UMA_HISTOGRAM_TIMES("Extensions.SandboxUnpackFailureTime",
@@ -531,7 +535,7 @@ DictionaryValue* SandboxedExtensionUnpacker::RewriteManifestFile(
// Error serializing manifest.json.
ReportFailure(
ERROR_SERIALIZING_MANIFEST_JSON,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
ASCIIToUTF16("ERROR_SERIALIZING_MANIFEST_JSON")));
return NULL;
@@ -544,7 +548,7 @@ DictionaryValue* SandboxedExtensionUnpacker::RewriteManifestFile(
// Error saving manifest.json.
ReportFailure(
ERROR_SAVING_MANIFEST_JSON,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
ASCIIToUTF16("ERROR_SAVING_MANIFEST_JSON")));
return NULL;
@@ -559,7 +563,7 @@ bool SandboxedExtensionUnpacker::RewriteImageFiles() {
// Couldn't read image data from disk.
ReportFailure(
COULD_NOT_READ_IMAGE_DATA_FROM_DISK,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
ASCIIToUTF16("COULD_NOT_READ_IMAGE_DATA_FROM_DISK")));
return false;
@@ -573,7 +577,7 @@ bool SandboxedExtensionUnpacker::RewriteImageFiles() {
// Decoded images don't match what's in the manifest.
ReportFailure(
DECODED_IMAGES_DO_NOT_MATCH_THE_MANIFEST,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
ASCIIToUTF16("DECODED_IMAGES_DO_NOT_MATCH_THE_MANIFEST")));
return false;
@@ -586,7 +590,7 @@ bool SandboxedExtensionUnpacker::RewriteImageFiles() {
// Invalid path for browser image.
ReportFailure(
INVALID_PATH_FOR_BROWSER_IMAGE,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
ASCIIToUTF16("INVALID_PATH_FOR_BROWSER_IMAGE")));
return false;
@@ -595,7 +599,7 @@ bool SandboxedExtensionUnpacker::RewriteImageFiles() {
// Error removing old image file.
ReportFailure(
ERROR_REMOVING_OLD_IMAGE_FILE,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
ASCIIToUTF16("ERROR_REMOVING_OLD_IMAGE_FILE")));
return false;
@@ -610,7 +614,7 @@ bool SandboxedExtensionUnpacker::RewriteImageFiles() {
// Invalid path for bitmap image.
ReportFailure(
INVALID_PATH_FOR_BITMAP_IMAGE,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
ASCIIToUTF16("INVALID_PATH_FOR_BITMAP_IMAGE")));
return false;
@@ -625,7 +629,7 @@ bool SandboxedExtensionUnpacker::RewriteImageFiles() {
// Error re-encoding theme image.
ReportFailure(
ERROR_RE_ENCODING_THEME_IMAGE,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
ASCIIToUTF16("ERROR_RE_ENCODING_THEME_IMAGE")));
return false;
@@ -638,7 +642,7 @@ bool SandboxedExtensionUnpacker::RewriteImageFiles() {
// Error saving theme image.
ReportFailure(
ERROR_SAVING_THEME_IMAGE,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
ASCIIToUTF16("ERROR_SAVING_THEME_IMAGE")));
return false;
@@ -655,7 +659,7 @@ bool SandboxedExtensionUnpacker::RewriteCatalogFiles() {
// Could not read catalog data from disk.
ReportFailure(
COULD_NOT_READ_CATALOG_DATA_FROM_DISK,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
ASCIIToUTF16("COULD_NOT_READ_CATALOG_DATA_FROM_DISK")));
return false;
@@ -669,7 +673,7 @@ bool SandboxedExtensionUnpacker::RewriteCatalogFiles() {
// Invalid catalog data.
ReportFailure(
INVALID_CATALOG_DATA,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
ASCIIToUTF16("INVALID_CATALOG_DATA")));
return false;
@@ -683,7 +687,7 @@ bool SandboxedExtensionUnpacker::RewriteCatalogFiles() {
// Invalid path for catalog.
ReportFailure(
INVALID_PATH_FOR_CATALOG,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
ASCIIToUTF16("INVALID_PATH_FOR_CATALOG")));
return false;
@@ -697,7 +701,7 @@ bool SandboxedExtensionUnpacker::RewriteCatalogFiles() {
// Error serializing catalog.
ReportFailure(
ERROR_SERIALIZING_CATALOG,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
ASCIIToUTF16("ERROR_SERIALIZING_CATALOG")));
return false;
@@ -711,7 +715,7 @@ bool SandboxedExtensionUnpacker::RewriteCatalogFiles() {
// Error saving catalog.
ReportFailure(
ERROR_SAVING_CATALOG,
- l10n_util::GetStringFUTF8(
+ l10n_util::GetStringFUTF16(
IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
ASCIIToUTF16("ERROR_SAVING_CATALOG")));
return false;
diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker.h b/chrome/browser/extensions/sandboxed_extension_unpacker.h
index f99542e..2fdc59f 100644
--- a/chrome/browser/extensions/sandboxed_extension_unpacker.h
+++ b/chrome/browser/extensions/sandboxed_extension_unpacker.h
@@ -38,7 +38,7 @@ class SandboxedExtensionUnpackerClient
const FilePath& extension_root,
const base::DictionaryValue* original_manifest,
const Extension* extension) = 0;
- virtual void OnUnpackFailure(const std::string& error) = 0;
+ virtual void OnUnpackFailure(const string16& error) = 0;
protected:
friend class base::RefCountedThreadSafe<SandboxedExtensionUnpackerClient>;
@@ -199,9 +199,9 @@ class SandboxedExtensionUnpacker : public UtilityProcessHost::Client {
// IPC message handlers.
void OnUnpackExtensionSucceeded(const base::DictionaryValue& manifest);
- void OnUnpackExtensionFailed(const std::string& error_message);
+ void OnUnpackExtensionFailed(const string16& error_message);
- void ReportFailure(FailureReason reason, const std::string& message);
+ void ReportFailure(FailureReason reason, const string16& message);
void ReportSuccess(const base::DictionaryValue& original_manifest);
// Overwrites original manifest with safe result from utility process.
diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc b/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc
index b5cf742..68bc2e9 100644
--- a/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc
+++ b/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc
@@ -49,7 +49,7 @@ class MockSandboxedExtensionUnpackerClient
const Extension* extension));
MOCK_METHOD1(OnUnpackFailure,
- void(const std::string& error));
+ void(const string16& error));
void DelegateToFake() {
ON_CALL(*this, OnUnpackSuccess(_, _, _, _))
diff --git a/chrome/browser/extensions/webstore_installer.cc b/chrome/browser/extensions/webstore_installer.cc
index 6b8f00f..7cf63d0 100644
--- a/chrome/browser/extensions/webstore_installer.cc
+++ b/chrome/browser/extensions/webstore_installer.cc
@@ -9,6 +9,7 @@
#include "base/file_util.h"
#include "base/stringprintf.h"
#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/download_util.h"
#include "chrome/browser/extensions/crx_installer.h"
@@ -139,10 +140,12 @@ void WebstoreInstaller::Observe(int type,
if (!profile_->IsSameProfile(crx_installer->profile()))
return;
- const std::string* error =
- content::Details<const std::string>(details).ptr();
+ // TODO(rdevlin.cronin): Continue removing std::string errors and
+ // replacing with string16
+ const string16* error = content::Details<const string16>(details).ptr();
+ const std::string utf8_error = UTF16ToUTF8(*error);
if (download_url_ == crx_installer->original_download_url())
- ReportFailure(*error);
+ ReportFailure(utf8_error);
break;
}
diff --git a/chrome/common/chrome_utility_messages.h b/chrome/common/chrome_utility_messages.h
index 7b7fcb6..8d79732 100644
--- a/chrome/common/chrome_utility_messages.h
+++ b/chrome/common/chrome_utility_messages.h
@@ -109,7 +109,7 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackExtension_Succeeded,
// Reply when the utility process has failed while unpacking an extension.
// |error_message| is a user-displayable explanation of what went wrong.
IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackExtension_Failed,
- std::string /* error_message, if any */)
+ string16 /* error_message, if any */)
// Reply when the utility process is done unpacking and parsing JSON data
// from a web resource.
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 38b7ec5..4b790f0 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -227,13 +227,16 @@ scoped_refptr<Extension> Extension::Create(const FilePath& path,
Location location,
const DictionaryValue& value,
int flags,
- std::string* error) {
- DCHECK(error);
+ std::string* utf8_error) {
+ DCHECK(utf8_error);
+ string16 error;
scoped_refptr<Extension> extension = new Extension(path, location);
if (!extension->InitFromValue(new extensions::Manifest(value.DeepCopy()),
- flags, error))
+ flags, &error)) {
+ *utf8_error = UTF16ToUTF8(error);
return NULL;
+ }
return extension;
}
@@ -384,7 +387,7 @@ bool Extension::GenerateId(const std::string& input, std::string* output) {
bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
int definition_index,
int flags,
- std::string* error,
+ string16* error,
UserScript* result) {
// When strict error checks are enabled, make URL pattern parsing strict.
URLPattern::ParseOption parse_option =
@@ -395,7 +398,8 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
if (content_script->HasKey(keys::kRunAt)) {
std::string run_location;
if (!content_script->GetString(keys::kRunAt, &run_location)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidRunAt,
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
+ errors::kInvalidRunAt,
base::IntToString(definition_index));
return false;
}
@@ -407,7 +411,8 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
} else if (run_location == values::kRunAtDocumentIdle) {
result->set_run_location(UserScript::DOCUMENT_IDLE);
} else {
- *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidRunAt,
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
+ errors::kInvalidRunAt,
base::IntToString(definition_index));
return false;
}
@@ -417,7 +422,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
if (content_script->HasKey(keys::kAllFrames)) {
bool all_frames = false;
if (!content_script->GetBoolean(keys::kAllFrames, &all_frames)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidAllFrames, base::IntToString(definition_index));
return false;
}
@@ -427,20 +432,22 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
// matches (required)
ListValue* matches = NULL;
if (!content_script->GetList(keys::kMatches, &matches)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidMatches,
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
+ errors::kInvalidMatches,
base::IntToString(definition_index));
return false;
}
if (matches->GetSize() == 0) {
- *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidMatchCount,
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
+ errors::kInvalidMatchCount,
base::IntToString(definition_index));
return false;
}
for (size_t j = 0; j < matches->GetSize(); ++j) {
std::string match_str;
if (!matches->GetString(j, &match_str)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidMatch,
base::IntToString(definition_index),
base::IntToString(j),
@@ -454,7 +461,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
URLPattern::ParseResult parse_result = pattern.Parse(match_str);
if (parse_result != URLPattern::PARSE_SUCCESS) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidMatch,
base::IntToString(definition_index),
base::IntToString(j),
@@ -477,7 +484,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
if (content_script->HasKey(keys::kExcludeMatches)) { // optional
ListValue* exclude_matches = NULL;
if (!content_script->GetList(keys::kExcludeMatches, &exclude_matches)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidExcludeMatches,
base::IntToString(definition_index));
return false;
@@ -486,7 +493,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
for (size_t j = 0; j < exclude_matches->GetSize(); ++j) {
std::string match_str;
if (!exclude_matches->GetString(j, &match_str)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidExcludeMatch,
base::IntToString(definition_index),
base::IntToString(j),
@@ -499,7 +506,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
pattern.SetValidSchemes(URLPattern::SCHEME_ALL);
URLPattern::ParseResult parse_result = pattern.Parse(match_str);
if (parse_result != URLPattern::PARSE_SUCCESS) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidExcludeMatch,
base::IntToString(definition_index), base::IntToString(j),
URLPattern::GetParseResultString(parse_result));
@@ -525,7 +532,8 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
ListValue* js = NULL;
if (content_script->HasKey(keys::kJs) &&
!content_script->GetList(keys::kJs, &js)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidJsList,
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
+ errors::kInvalidJsList,
base::IntToString(definition_index));
return false;
}
@@ -533,14 +541,16 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
ListValue* css = NULL;
if (content_script->HasKey(keys::kCss) &&
!content_script->GetList(keys::kCss, &css)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidCssList,
+ *error = ExtensionErrorUtils::
+ FormatErrorMessageUTF16(errors::kInvalidCssList,
base::IntToString(definition_index));
return false;
}
// The manifest needs to have at least one js or css user script definition.
if (((js ? js->GetSize() : 0) + (css ? css->GetSize() : 0)) == 0) {
- *error = ExtensionErrorUtils::FormatErrorMessage(errors::kMissingFile,
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
+ errors::kMissingFile,
base::IntToString(definition_index));
return false;
}
@@ -551,7 +561,8 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
Value* value;
std::string relative;
if (!js->Get(script_index, &value) || !value->GetAsString(&relative)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidJs,
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
+ errors::kInvalidJs,
base::IntToString(definition_index),
base::IntToString(script_index));
return false;
@@ -569,7 +580,8 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
Value* value;
std::string relative;
if (!css->Get(script_index, &value) || !value->GetAsString(&relative)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidCss,
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
+ errors::kInvalidCss,
base::IntToString(definition_index),
base::IntToString(script_index));
return false;
@@ -588,7 +600,7 @@ bool Extension::LoadGlobsHelper(
const DictionaryValue* content_script,
int content_script_index,
const char* globs_property_name,
- std::string* error,
+ string16* error,
void(UserScript::*add_method)(const std::string& glob),
UserScript *instance) {
if (!content_script->HasKey(globs_property_name))
@@ -596,7 +608,8 @@ bool Extension::LoadGlobsHelper(
ListValue* list = NULL;
if (!content_script->GetList(globs_property_name, &list)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidGlobList,
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
+ errors::kInvalidGlobList,
base::IntToString(content_script_index),
globs_property_name);
return false;
@@ -605,7 +618,8 @@ bool Extension::LoadGlobsHelper(
for (size_t i = 0; i < list->GetSize(); ++i) {
std::string glob;
if (!list->GetString(i, &glob)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidGlob,
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
+ errors::kInvalidGlob,
base::IntToString(content_script_index),
globs_property_name,
base::IntToString(i));
@@ -619,7 +633,7 @@ bool Extension::LoadGlobsHelper(
}
ExtensionAction* Extension::LoadExtensionActionHelper(
- const DictionaryValue* extension_action, std::string* error) {
+ const DictionaryValue* extension_action, string16* error) {
scoped_ptr<ExtensionAction> result(new ExtensionAction());
result->set_extension_id(id());
@@ -635,7 +649,7 @@ ExtensionAction* Extension::LoadExtensionActionHelper(
iter != icons->end(); ++iter) {
std::string path;
if (!(*iter)->GetAsString(&path) || path.empty()) {
- *error = errors::kInvalidPageActionIconPath;
+ *error = ASCIIToUTF16(errors::kInvalidPageActionIconPath);
return NULL;
}
@@ -647,7 +661,7 @@ ExtensionAction* Extension::LoadExtensionActionHelper(
std::string id;
if (extension_action->HasKey(keys::kPageActionId)) {
if (!extension_action->GetString(keys::kPageActionId, &id)) {
- *error = errors::kInvalidPageActionId;
+ *error = ASCIIToUTF16(errors::kInvalidPageActionId);
return NULL;
}
result->set_id(id);
@@ -659,7 +673,7 @@ ExtensionAction* Extension::LoadExtensionActionHelper(
if (!extension_action->GetString(keys::kPageActionDefaultIcon,
&default_icon) ||
default_icon.empty()) {
- *error = errors::kInvalidPageActionIconPath;
+ *error = ASCIIToUTF16(errors::kInvalidPageActionIconPath);
return NULL;
}
result->set_default_icon_path(default_icon);
@@ -670,12 +684,12 @@ ExtensionAction* Extension::LoadExtensionActionHelper(
std::string title;
if (extension_action->HasKey(keys::kPageActionDefaultTitle)) {
if (!extension_action->GetString(keys::kPageActionDefaultTitle, &title)) {
- *error = errors::kInvalidPageActionDefaultTitle;
+ *error = ASCIIToUTF16(errors::kInvalidPageActionDefaultTitle);
return NULL;
}
} else if (extension_action->HasKey(keys::kName)) {
if (!extension_action->GetString(keys::kName, &title)) {
- *error = errors::kInvalidPageActionName;
+ *error = ASCIIToUTF16(errors::kInvalidPageActionName);
return NULL;
}
}
@@ -690,7 +704,7 @@ ExtensionAction* Extension::LoadExtensionActionHelper(
// key "default_popup".
if (extension_action->HasKey(keys::kPageActionPopup)) {
if (popup_key) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidPageActionOldAndNewKeys,
keys::kPageActionDefaultPopup,
keys::kPageActionPopup);
@@ -709,12 +723,12 @@ ExtensionAction* Extension::LoadExtensionActionHelper(
// TODO(EXTENSIONS_DEPRECATED): popup is now a string only.
// Support the old dictionary format for backward compatibility.
if (!popup->GetString(keys::kPageActionPopupPath, &url_str)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidPageActionPopupPath, "<missing>");
return NULL;
}
} else {
- *error = errors::kInvalidPageActionPopup;
+ *error = ASCIIToUTF16(errors::kInvalidPageActionPopup);
return NULL;
}
@@ -722,7 +736,7 @@ ExtensionAction* Extension::LoadExtensionActionHelper(
// An empty string is treated as having no popup.
GURL url = GetResourceURL(url_str);
if (!url.is_valid()) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidPageActionPopupPath, url_str);
return NULL;
}
@@ -737,14 +751,14 @@ ExtensionAction* Extension::LoadExtensionActionHelper(
}
Extension::FileBrowserHandlerList* Extension::LoadFileBrowserHandlers(
- const ListValue* extension_actions, std::string* error) {
+ const ListValue* extension_actions, string16* error) {
scoped_ptr<FileBrowserHandlerList> result(
new FileBrowserHandlerList());
for (ListValue::const_iterator iter = extension_actions->begin();
iter != extension_actions->end();
++iter) {
if (!(*iter)->IsType(Value::TYPE_DICTIONARY)) {
- *error = errors::kInvalidFileBrowserHandler;
+ *error = ASCIIToUTF16(errors::kInvalidFileBrowserHandler);
return NULL;
}
scoped_ptr<FileBrowserHandler> action(
@@ -758,7 +772,7 @@ Extension::FileBrowserHandlerList* Extension::LoadFileBrowserHandlers(
}
FileBrowserHandler* Extension::LoadFileBrowserHandler(
- const DictionaryValue* file_browser_handler, std::string* error) {
+ const DictionaryValue* file_browser_handler, string16* error) {
scoped_ptr<FileBrowserHandler> result(
new FileBrowserHandler());
result->set_extension_id(id());
@@ -767,7 +781,7 @@ FileBrowserHandler* Extension::LoadFileBrowserHandler(
// Read the file action |id| (mandatory).
if (!file_browser_handler->HasKey(keys::kPageActionId) ||
!file_browser_handler->GetString(keys::kPageActionId, &id)) {
- *error = errors::kInvalidPageActionId;
+ *error = ASCIIToUTF16(errors::kInvalidPageActionId);
return NULL;
}
result->set_id(id);
@@ -776,7 +790,7 @@ FileBrowserHandler* Extension::LoadFileBrowserHandler(
std::string title;
if (!file_browser_handler->HasKey(keys::kPageActionDefaultTitle) ||
!file_browser_handler->GetString(keys::kPageActionDefaultTitle, &title)) {
- *error = errors::kInvalidPageActionDefaultTitle;
+ *error = ASCIIToUTF16(errors::kInvalidPageActionDefaultTitle);
return NULL;
}
result->set_title(title);
@@ -786,20 +800,20 @@ FileBrowserHandler* Extension::LoadFileBrowserHandler(
if (!file_browser_handler->HasKey(keys::kFileFilters) ||
!file_browser_handler->GetList(keys::kFileFilters, &list_value) ||
list_value->empty()) {
- *error = errors::kInvalidFileFiltersList;
+ *error = ASCIIToUTF16(errors::kInvalidFileFiltersList);
return NULL;
}
for (size_t i = 0; i < list_value->GetSize(); ++i) {
std::string filter;
if (!list_value->GetString(i, &filter)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidFileFilterValue, base::IntToString(i));
return NULL;
}
StringToLowerASCII(&filter);
URLPattern pattern(URLPattern::USE_PORTS, URLPattern::SCHEME_FILESYSTEM);
if (pattern.Parse(filter) != URLPattern::PARSE_SUCCESS) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidURLPatternError, filter);
return NULL;
}
@@ -808,7 +822,7 @@ FileBrowserHandler* Extension::LoadFileBrowserHandler(
(path.compare(0, 2, "*.") == 0 &&
path.find_first_of('*', 2) == std::string::npos);
if (!allowed) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidURLPatternError, filter);
return NULL;
}
@@ -821,7 +835,7 @@ FileBrowserHandler* Extension::LoadFileBrowserHandler(
if (!file_browser_handler->GetString(
keys::kPageActionDefaultIcon,&default_icon) ||
default_icon.empty()) {
- *error = errors::kInvalidPageActionIconPath;
+ *error = ASCIIToUTF16(errors::kInvalidPageActionIconPath);
return NULL;
}
result->set_icon_path(default_icon);
@@ -831,7 +845,7 @@ FileBrowserHandler* Extension::LoadFileBrowserHandler(
}
ExtensionSidebarDefaults* Extension::LoadExtensionSidebarDefaults(
- const DictionaryValue* extension_sidebar, std::string* error) {
+ const DictionaryValue* extension_sidebar, string16* error) {
scoped_ptr<ExtensionSidebarDefaults> result(new ExtensionSidebarDefaults());
std::string default_icon;
@@ -840,7 +854,7 @@ ExtensionSidebarDefaults* Extension::LoadExtensionSidebarDefaults(
if (!extension_sidebar->GetString(keys::kSidebarDefaultIcon,
&default_icon) ||
default_icon.empty()) {
- *error = errors::kInvalidSidebarDefaultIconPath;
+ *error = ASCIIToUTF16(errors::kInvalidSidebarDefaultIconPath);
return NULL;
}
result->set_default_icon_path(default_icon);
@@ -851,23 +865,27 @@ ExtensionSidebarDefaults* Extension::LoadExtensionSidebarDefaults(
if (extension_sidebar->HasKey(keys::kSidebarDefaultTitle)) {
if (!extension_sidebar->GetString(keys::kSidebarDefaultTitle,
&default_title)) {
- *error = errors::kInvalidSidebarDefaultTitle;
+ *error = ASCIIToUTF16(errors::kInvalidSidebarDefaultTitle);
return NULL;
}
}
result->set_default_title(default_title);
// Read sidebar's |default_page| (optional).
+ // TODO(rdevlin.cronin): Continue removing std::string errors and replace
+ // with string16
std::string default_page;
+ std::string utf8_error;
if (extension_sidebar->HasKey(keys::kSidebarDefaultPage)) {
if (!extension_sidebar->GetString(keys::kSidebarDefaultPage,
&default_page) ||
default_page.empty()) {
- *error = errors::kInvalidSidebarDefaultPage;
+ *error = ASCIIToUTF16(errors::kInvalidSidebarDefaultPage);
return NULL;
}
GURL url = extension_sidebar_utils::ResolveRelativePath(
- default_page, this, error);
+ default_page, this, &utf8_error);
+ *error = UTF8ToUTF16(utf8_error);
if (!url.is_valid())
return NULL;
result->set_default_page(url);
@@ -882,13 +900,13 @@ bool Extension::LoadExtent(const extensions::Manifest* manifest,
const char* list_error,
const char* value_error,
URLPattern::ParseOption parse_option,
- std::string* error) {
+ string16* error) {
Value* temp = NULL;
if (!manifest->Get(key, &temp))
return true;
if (temp->GetType() != Value::TYPE_LIST) {
- *error = list_error;
+ *error = ASCIIToUTF16(list_error);
return false;
}
@@ -896,7 +914,7 @@ bool Extension::LoadExtent(const extensions::Manifest* manifest,
for (size_t i = 0; i < pattern_list->GetSize(); ++i) {
std::string pattern_string;
if (!pattern_list->GetString(i, &pattern_string)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(value_error,
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(value_error,
base::UintToString(i),
errors::kExpectString);
return false;
@@ -910,7 +928,7 @@ bool Extension::LoadExtent(const extensions::Manifest* manifest,
}
if (parse_result != URLPattern::PARSE_SUCCESS) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
value_error,
base::UintToString(i),
URLPattern::GetParseResultString(parse_result));
@@ -919,7 +937,7 @@ bool Extension::LoadExtent(const extensions::Manifest* manifest,
// Do not allow authors to claim "<all_urls>".
if (pattern.match_all_urls()) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
value_error,
base::UintToString(i),
errors::kCannotClaimAllURLsInExtent);
@@ -928,7 +946,7 @@ bool Extension::LoadExtent(const extensions::Manifest* manifest,
// Do not allow authors to claim "*" for host.
if (pattern.host().empty()) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
value_error,
base::UintToString(i),
errors::kCannotClaimAllHostsInExtent);
@@ -938,7 +956,7 @@ bool Extension::LoadExtent(const extensions::Manifest* manifest,
// We do not allow authors to put wildcards in their paths. Instead, we
// imply one at the end.
if (pattern.path().find('*') != std::string::npos) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
value_error,
base::UintToString(i),
errors::kNoWildCardsInPaths);
@@ -953,32 +971,32 @@ bool Extension::LoadExtent(const extensions::Manifest* manifest,
}
bool Extension::LoadLaunchURL(const extensions::Manifest* manifest,
- std::string* error) {
+ string16* error) {
Value* temp = NULL;
// launch URL can be either local (to chrome-extension:// root) or an absolute
// web URL.
if (manifest->Get(keys::kLaunchLocalPath, &temp)) {
if (manifest->Get(keys::kLaunchWebURL, NULL)) {
- *error = errors::kLaunchPathAndURLAreExclusive;
+ *error = ASCIIToUTF16(errors::kLaunchPathAndURLAreExclusive);
return false;
}
if (manifest->Get(keys::kWebURLs, NULL)) {
- *error = errors::kLaunchPathAndExtentAreExclusive;
+ *error = ASCIIToUTF16(errors::kLaunchPathAndExtentAreExclusive);
return false;
}
std::string launch_path;
if (!temp->GetAsString(&launch_path)) {
- *error = errors::kInvalidLaunchLocalPath;
+ *error = ASCIIToUTF16(errors::kInvalidLaunchLocalPath);
return false;
}
// Ensure the launch path is a valid relative URL.
GURL resolved = url().Resolve(launch_path);
if (!resolved.is_valid() || resolved.GetOrigin() != url()) {
- *error = errors::kInvalidLaunchLocalPath;
+ *error = ASCIIToUTF16(errors::kInvalidLaunchLocalPath);
return false;
}
@@ -986,7 +1004,7 @@ bool Extension::LoadLaunchURL(const extensions::Manifest* manifest,
} else if (manifest->Get(keys::kLaunchWebURL, &temp)) {
std::string launch_url;
if (!temp->GetAsString(&launch_url)) {
- *error = errors::kInvalidLaunchWebURL;
+ *error = ASCIIToUTF16(errors::kInvalidLaunchWebURL);
return false;
}
@@ -994,13 +1012,13 @@ bool Extension::LoadLaunchURL(const extensions::Manifest* manifest,
GURL url(launch_url);
URLPattern pattern(URLPattern::USE_PORTS, kValidWebExtentSchemes);
if (!url.is_valid() || !pattern.SetScheme(url.scheme())) {
- *error = errors::kInvalidLaunchWebURL;
+ *error = ASCIIToUTF16(errors::kInvalidLaunchWebURL);
return false;
}
launch_web_url_ = launch_url;
} else if (is_app()) {
- *error = errors::kLaunchURLRequired;
+ *error = ASCIIToUTF16(errors::kLaunchURLRequired);
return false;
}
@@ -1009,7 +1027,7 @@ bool Extension::LoadLaunchURL(const extensions::Manifest* manifest,
GURL launch_url(launch_web_url());
URLPattern pattern(URLPattern::USE_PORTS, kValidWebExtentSchemes);
if (!pattern.SetScheme("*")) {
- *error = errors::kInvalidLaunchWebURL;
+ *error = ASCIIToUTF16(errors::kInvalidLaunchWebURL);
return false;
}
pattern.SetHost(launch_url.host());
@@ -1051,14 +1069,14 @@ bool Extension::LoadLaunchURL(const extensions::Manifest* manifest,
}
bool Extension::LoadLaunchContainer(const extensions::Manifest* manifest,
- std::string* error) {
+ string16* error) {
Value* temp = NULL;
if (!manifest->Get(keys::kLaunchContainer, &temp))
return true;
std::string launch_container_string;
if (!temp->GetAsString(&launch_container_string)) {
- *error = errors::kInvalidLaunchContainer;
+ *error = ASCIIToUTF16(errors::kInvalidLaunchContainer);
return false;
}
@@ -1069,7 +1087,7 @@ bool Extension::LoadLaunchContainer(const extensions::Manifest* manifest,
} else if (launch_container_string == values::kLaunchContainerTab) {
launch_container_ = extension_misc::LAUNCH_TAB;
} else {
- *error = errors::kInvalidLaunchContainer;
+ *error = ASCIIToUTF16(errors::kInvalidLaunchContainer);
return false;
}
@@ -1077,13 +1095,13 @@ bool Extension::LoadLaunchContainer(const extensions::Manifest* manifest,
if (manifest->Get(keys::kLaunchWidth, &temp)) {
if (launch_container() != extension_misc::LAUNCH_PANEL &&
launch_container() != extension_misc::LAUNCH_WINDOW) {
- *error = errors::kInvalidLaunchWidthContainer;
+ *error = ASCIIToUTF16(errors::kInvalidLaunchWidthContainer);
return false;
}
if (!temp->GetAsInteger(&launch_width_) ||
launch_width_ < 0) {
launch_width_ = 0;
- *error = errors::kInvalidLaunchWidth;
+ *error = ASCIIToUTF16(errors::kInvalidLaunchWidth);
return false;
}
}
@@ -1092,12 +1110,12 @@ bool Extension::LoadLaunchContainer(const extensions::Manifest* manifest,
if (manifest->Get(keys::kLaunchHeight, &temp)) {
if (launch_container() != extension_misc::LAUNCH_PANEL &&
launch_container() != extension_misc::LAUNCH_WINDOW) {
- *error = errors::kInvalidLaunchHeightContainer;
+ *error = ASCIIToUTF16(errors::kInvalidLaunchHeightContainer);
return false;
}
if (!temp->GetAsInteger(&launch_height_) || launch_height_ < 0) {
launch_height_ = 0;
- *error = errors::kInvalidLaunchHeight;
+ *error = ASCIIToUTF16(errors::kInvalidLaunchHeight);
return false;
}
}
@@ -1106,13 +1124,13 @@ bool Extension::LoadLaunchContainer(const extensions::Manifest* manifest,
}
bool Extension::LoadAppIsolation(const extensions::Manifest* manifest,
- std::string* error) {
+ string16* error) {
Value* temp = NULL;
if (!manifest->Get(keys::kIsolation, &temp))
return true;
if (temp->GetType() != Value::TYPE_LIST) {
- *error = errors::kInvalidIsolation;
+ *error = ASCIIToUTF16(errors::kInvalidIsolation);
return false;
}
@@ -1120,7 +1138,7 @@ bool Extension::LoadAppIsolation(const extensions::Manifest* manifest,
for (size_t i = 0; i < isolation_list->GetSize(); ++i) {
std::string isolation_string;
if (!isolation_list->GetString(i, &isolation_string)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidIsolationValue,
base::UintToString(i));
return false;
@@ -1138,7 +1156,7 @@ bool Extension::LoadAppIsolation(const extensions::Manifest* manifest,
}
bool Extension::LoadWebIntentServices(const extensions::Manifest* manifest,
- std::string* error) {
+ string16* error) {
DCHECK(error);
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents))
@@ -1149,7 +1167,7 @@ bool Extension::LoadWebIntentServices(const extensions::Manifest* manifest,
DictionaryValue* all_services = NULL;
if (!manifest->GetDictionary(keys::kIntents, &all_services)) {
- *error = errors::kInvalidIntents;
+ *error = ASCIIToUTF16(errors::kInvalidIntents);
return false;
}
@@ -1160,7 +1178,7 @@ bool Extension::LoadWebIntentServices(const extensions::Manifest* manifest,
DictionaryValue* one_service = NULL;
if (!all_services->GetDictionaryWithoutPathExpansion(*iter, &one_service)) {
- *error = errors::kInvalidIntent;
+ *error = ASCIIToUTF16(errors::kInvalidIntent);
return false;
}
service.action = UTF8ToUTF16(*iter);
@@ -1168,13 +1186,13 @@ bool Extension::LoadWebIntentServices(const extensions::Manifest* manifest,
// TODO(groby): Support an array of types.
if (one_service->HasKey(keys::kIntentType) &&
!one_service->GetString(keys::kIntentType, &service.type)) {
- *error = errors::kInvalidIntentType;
+ *error = ASCIIToUTF16(errors::kInvalidIntentType);
return false;
}
if (one_service->HasKey(keys::kIntentPath)) {
if (!one_service->GetString(keys::kIntentPath, &value)) {
- *error = errors::kInvalidIntentPath;
+ *error = ASCIIToUTF16(errors::kInvalidIntentPath);
return false;
}
service.service_url = GetResourceURL(value);
@@ -1182,7 +1200,7 @@ bool Extension::LoadWebIntentServices(const extensions::Manifest* manifest,
if (one_service->HasKey(keys::kIntentTitle) &&
!one_service->GetString(keys::kIntentTitle, &service.title)) {
- *error = errors::kInvalidIntentTitle;
+ *error = ASCIIToUTF16(errors::kInvalidIntentTitle);
return false;
}
@@ -1190,7 +1208,7 @@ bool Extension::LoadWebIntentServices(const extensions::Manifest* manifest,
if (!one_service->GetString(keys::kIntentDisposition, &value) ||
(value != values::kIntentDispositionWindow &&
value != values::kIntentDispositionInline)) {
- *error = errors::kInvalidIntentDisposition;
+ *error = ASCIIToUTF16(errors::kInvalidIntentDisposition);
return false;
}
if (value == values::kIntentDispositionInline) {
@@ -1378,7 +1396,7 @@ GURL Extension::GetBaseURLFromExtensionId(const std::string& extension_id) {
}
bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
- std::string* error) {
+ string16* error) {
DCHECK(error);
base::AutoLock auto_lock(runtime_data_lock_);
manifest_.reset(manifest);
@@ -1400,7 +1418,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
int manifest_version = 0;
if (!manifest->GetInteger(keys::kManifestVersion, &manifest_version) ||
manifest_version < 1) {
- *error = errors::kInvalidManifestVersion;
+ *error = ASCIIToUTF16(errors::kInvalidManifestVersion);
return false;
}
manifest_version_ = manifest_version;
@@ -1413,7 +1431,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
manifest_version() < kModernManifestVersion &&
!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAllowLegacyExtensionManifests)) {
- *error = errors::kInvalidManifestVersion;
+ *error = ASCIIToUTF16(errors::kInvalidManifestVersion);
return false;
}
@@ -1424,11 +1442,11 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
!ParsePEMKeyBytes(public_key_,
&public_key_bytes) ||
!GenerateId(public_key_bytes, &id_)) {
- *error = errors::kInvalidKey;
+ *error = ASCIIToUTF16(errors::kInvalidKey);
return false;
}
} else if (flags & REQUIRE_KEY) {
- *error = errors::kInvalidKey;
+ *error = ASCIIToUTF16(errors::kInvalidKey);
return false;
} else {
// If there is a path, we generate the ID from it. This is useful for
@@ -1449,20 +1467,20 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
// Initialize version.
std::string version_str;
if (!manifest->GetString(keys::kVersion, &version_str)) {
- *error = errors::kInvalidVersion;
+ *error = ASCIIToUTF16(errors::kInvalidVersion);
return false;
}
version_.reset(Version::GetVersionFromString(version_str));
if (!version_.get() ||
version_->components().size() > 4) {
- *error = errors::kInvalidVersion;
+ *error = ASCIIToUTF16(errors::kInvalidVersion);
return false;
}
// Initialize name.
string16 localized_name;
if (!manifest->GetString(keys::kName, &localized_name)) {
- *error = errors::kInvalidName;
+ *error = ASCIIToUTF16(errors::kInvalidName);
return false;
}
base::i18n::AdjustStringForLocaleDirection(&localized_name);
@@ -1483,11 +1501,11 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (is_platform_app()) {
if (launch_container() != extension_misc::LAUNCH_SHELL) {
- *error = errors::kInvalidLaunchContainerForPlatform;
+ *error = ASCIIToUTF16(errors::kInvalidLaunchContainerForPlatform);
return false;
}
} else if (launch_container() == extension_misc::LAUNCH_SHELL) {
- *error = errors::kInvalidLaunchContainerForNonPlatform;
+ *error = ASCIIToUTF16(errors::kInvalidLaunchContainerForNonPlatform);
return false;
}
@@ -1519,7 +1537,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kDescription)) {
if (!manifest->GetString(keys::kDescription,
&description_)) {
- *error = errors::kInvalidDescription;
+ *error = ASCIIToUTF16(errors::kInvalidDescription);
return false;
}
}
@@ -1528,7 +1546,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kHomepageURL)) {
std::string tmp;
if (!manifest->GetString(keys::kHomepageURL, &tmp)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidHomepageURL, "");
return false;
}
@@ -1536,7 +1554,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (!homepage_url_.is_valid() ||
(!homepage_url_.SchemeIs("http") &&
!homepage_url_.SchemeIs("https"))) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidHomepageURL, tmp);
return false;
}
@@ -1546,14 +1564,14 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kUpdateURL)) {
std::string tmp;
if (!manifest->GetString(keys::kUpdateURL, &tmp)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidUpdateURL, "");
return false;
}
update_url_ = GURL(tmp);
if (!update_url_.is_valid() ||
update_url_.has_ref()) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidUpdateURL, tmp);
return false;
}
@@ -1565,14 +1583,14 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
std::string minimum_version_string;
if (!manifest->GetString(keys::kMinimumChromeVersion,
&minimum_version_string)) {
- *error = errors::kInvalidMinimumChromeVersion;
+ *error = ASCIIToUTF16(errors::kInvalidMinimumChromeVersion);
return false;
}
scoped_ptr<Version> minimum_version(
Version::GetVersionFromString(minimum_version_string));
if (!minimum_version.get()) {
- *error = errors::kInvalidMinimumChromeVersion;
+ *error = ASCIIToUTF16(errors::kInvalidMinimumChromeVersion);
return false;
}
@@ -1590,7 +1608,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
}
if (current_version->CompareTo(*minimum_version) < 0) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kChromeVersionTooLow,
l10n_util::GetStringUTF8(IDS_PRODUCT_NAME),
minimum_version_string);
@@ -1607,7 +1625,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kIcons)) {
DictionaryValue* icons_value = NULL;
if (!manifest->GetDictionary(keys::kIcons, &icons_value)) {
- *error = errors::kInvalidIcons;
+ *error = ASCIIToUTF16(errors::kInvalidIcons);
return false;
}
@@ -1616,7 +1634,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (icons_value->HasKey(key)) {
std::string icon_path;
if (!icons_value->GetString(key, &icon_path)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidIconPath, key);
return false;
}
@@ -1625,7 +1643,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
icon_path = icon_path.substr(1);
if (icon_path.empty()) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidIconPath, key);
return false;
}
@@ -1639,7 +1657,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kTheme)) {
DictionaryValue* theme_value = NULL;
if (!manifest->GetDictionary(keys::kTheme, &theme_value)) {
- *error = errors::kInvalidTheme;
+ *error = ASCIIToUTF16(errors::kInvalidTheme);
return false;
}
@@ -1650,7 +1668,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
iter != images_value->end_keys(); ++iter) {
std::string val;
if (!images_value->GetString(*iter, &val)) {
- *error = errors::kInvalidThemeImages;
+ *error = ASCIIToUTF16(errors::kInvalidThemeImages);
return false;
}
}
@@ -1677,7 +1695,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
!color_list->GetInteger(0, &color) ||
!color_list->GetInteger(1, &color) ||
!color_list->GetInteger(2, &color)) {
- *error = errors::kInvalidThemeColors;
+ *error = ASCIIToUTF16(errors::kInvalidThemeColors);
return false;
}
}
@@ -1696,7 +1714,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
!tint_list->GetDouble(0, &v) ||
!tint_list->GetDouble(1, &v) ||
!tint_list->GetDouble(2, &v)) {
- *error = errors::kInvalidThemeTints;
+ *error = ASCIIToUTF16(errors::kInvalidThemeTints);
return false;
}
}
@@ -1717,7 +1735,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kPlugins)) {
ListValue* list_value = NULL;
if (!manifest->GetList(keys::kPlugins, &list_value)) {
- *error = errors::kInvalidPlugins;
+ *error = ASCIIToUTF16(errors::kInvalidPlugins);
return false;
}
@@ -1727,13 +1745,13 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
bool is_public = false;
if (!list_value->GetDictionary(i, &plugin_value)) {
- *error = errors::kInvalidPlugins;
+ *error = ASCIIToUTF16(errors::kInvalidPlugins);
return false;
}
// Get plugins[i].path.
if (!plugin_value->GetString(keys::kPluginsPath, &path_str)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidPluginsPath, base::IntToString(i));
return false;
}
@@ -1741,7 +1759,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
// Get plugins[i].content (optional).
if (plugin_value->HasKey(keys::kPluginsPublic)) {
if (!plugin_value->GetBoolean(keys::kPluginsPublic, &is_public)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidPluginsPublic, base::IntToString(i));
return false;
}
@@ -1761,7 +1779,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kNaClModules)) {
ListValue* list_value = NULL;
if (!manifest->GetList(keys::kNaClModules, &list_value)) {
- *error = errors::kInvalidNaClModules;
+ *error = ASCIIToUTF16(errors::kInvalidNaClModules);
return false;
}
@@ -1771,20 +1789,20 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
std::string mime_type;
if (!list_value->GetDictionary(i, &module_value)) {
- *error = errors::kInvalidNaClModules;
+ *error = ASCIIToUTF16(errors::kInvalidNaClModules);
return false;
}
// Get nacl_modules[i].path.
if (!module_value->GetString(keys::kNaClModulesPath, &path_str)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidNaClModulesPath, base::IntToString(i));
return false;
}
// Get nacl_modules[i].mime_type.
if (!module_value->GetString(keys::kNaClModulesMIMEType, &mime_type)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidNaClModulesMIMEType, base::IntToString(i));
return false;
}
@@ -1799,14 +1817,14 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kContentScripts)) {
ListValue* list_value;
if (!manifest->GetList(keys::kContentScripts, &list_value)) {
- *error = errors::kInvalidContentScriptsList;
+ *error = ASCIIToUTF16(errors::kInvalidContentScriptsList);
return false;
}
for (size_t i = 0; i < list_value->GetSize(); ++i) {
DictionaryValue* content_script = NULL;
if (!list_value->GetDictionary(i, &content_script)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidContentScript, base::IntToString(i));
return false;
}
@@ -1829,7 +1847,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kPageActions)) {
ListValue* list_value = NULL;
if (!manifest->GetList(keys::kPageActions, &list_value)) {
- *error = errors::kInvalidPageActionsList;
+ *error = ASCIIToUTF16(errors::kInvalidPageActionsList);
return false;
}
@@ -1840,16 +1858,16 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
// a page_actions key in the manifest. Don't set |page_action_value|.
} else if (list_value_length == 1u) {
if (!list_value->GetDictionary(0, &page_action_value)) {
- *error = errors::kInvalidPageAction;
+ *error = ASCIIToUTF16(errors::kInvalidPageAction);
return false;
}
} else { // list_value_length > 1u.
- *error = errors::kInvalidPageActionsListSize;
+ *error = ASCIIToUTF16(errors::kInvalidPageActionsListSize);
return false;
}
} else if (manifest->HasKey(keys::kPageAction)) {
if (!manifest->GetDictionary(keys::kPageAction, &page_action_value)) {
- *error = errors::kInvalidPageAction;
+ *error = ASCIIToUTF16(errors::kInvalidPageAction);
return false;
}
}
@@ -1866,7 +1884,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kBrowserAction)) {
DictionaryValue* browser_action_value = NULL;
if (!manifest->GetDictionary(keys::kBrowserAction, &browser_action_value)) {
- *error = errors::kInvalidBrowserAction;
+ *error = ASCIIToUTF16(errors::kInvalidBrowserAction);
return false;
}
@@ -1881,7 +1899,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
ListValue* file_browser_handlers_value = NULL;
if (!manifest->GetList(keys::kFileBrowserHandlers,
&file_browser_handlers_value)) {
- *error = errors::kInvalidFileBrowserHandler;
+ *error = ASCIIToUTF16(errors::kInvalidFileBrowserHandler);
return false;
}
@@ -1901,7 +1919,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kOptionsPage)) {
std::string options_str;
if (!manifest->GetString(keys::kOptionsPage, &options_str)) {
- *error = errors::kInvalidOptionsPage;
+ *error = ASCIIToUTF16(errors::kInvalidOptionsPage);
return false;
}
@@ -1910,19 +1928,19 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
GURL options_url(options_str);
if (!options_url.is_valid() ||
!(options_url.SchemeIs("http") || options_url.SchemeIs("https"))) {
- *error = errors::kInvalidOptionsPageInHostedApp;
+ *error = ASCIIToUTF16(errors::kInvalidOptionsPageInHostedApp);
return false;
}
options_url_ = options_url;
} else {
GURL absolute(options_str);
if (absolute.is_valid()) {
- *error = errors::kInvalidOptionsPageExpectUrlInPackage;
+ *error = ASCIIToUTF16(errors::kInvalidOptionsPageExpectUrlInPackage);
return false;
}
options_url_ = GetResourceURL(options_str);
if (!options_url_.is_valid()) {
- *error = errors::kInvalidOptionsPage;
+ *error = ASCIIToUTF16(errors::kInvalidOptionsPage);
return false;
}
}
@@ -1932,20 +1950,20 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kBackground)) {
std::string background_str;
if (!manifest->GetString(keys::kBackground, &background_str)) {
- *error = errors::kInvalidBackground;
+ *error = ASCIIToUTF16(errors::kInvalidBackground);
return false;
}
if (is_hosted_app()) {
// Make sure "background" permission is set.
if (!api_permissions.count(ExtensionAPIPermission::kBackground)) {
- *error = errors::kBackgroundPermissionNeeded;
+ *error = ASCIIToUTF16(errors::kBackgroundPermissionNeeded);
return false;
}
// Hosted apps require an absolute URL.
GURL bg_page(background_str);
if (!bg_page.is_valid()) {
- *error = errors::kInvalidBackgroundInHostedApp;
+ *error = ASCIIToUTF16(errors::kInvalidBackgroundInHostedApp);
return false;
}
@@ -1953,7 +1971,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
(CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAllowHTTPBackgroundPage) &&
bg_page.SchemeIs("http")))) {
- *error = errors::kInvalidBackgroundInHostedApp;
+ *error = ASCIIToUTF16(errors::kInvalidBackgroundInHostedApp);
return false;
}
background_url_ = bg_page;
@@ -1965,7 +1983,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kDefaultLocale)) {
if (!manifest->GetString(keys::kDefaultLocale, &default_locale_) ||
!l10n_util::IsValidLocaleSyntax(default_locale_)) {
- *error = errors::kInvalidDefaultLocale;
+ *error = ASCIIToUTF16(errors::kInvalidDefaultLocale);
return false;
}
}
@@ -1974,7 +1992,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kChromeURLOverrides)) {
DictionaryValue* overrides = NULL;
if (!manifest->GetDictionary(keys::kChromeURLOverrides, &overrides)) {
- *error = errors::kInvalidChromeURLOverrides;
+ *error = ASCIIToUTF16(errors::kInvalidChromeURLOverrides);
return false;
}
@@ -2000,7 +2018,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
#endif
) ||
!overrides->GetStringWithoutPathExpansion(*iter, &val)) {
- *error = errors::kInvalidChromeURLOverrides;
+ *error = ASCIIToUTF16(errors::kInvalidChromeURLOverrides);
return false;
}
// Replace the entry with a fully qualified chrome-extension:// URL.
@@ -2009,7 +2027,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
// An extension may override at most one page.
if (overrides->size() > 1) {
- *error = errors::kMultipleOverrides;
+ *error = ASCIIToUTF16(errors::kMultipleOverrides);
return false;
}
}
@@ -2018,7 +2036,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
manifest->HasKey(keys::kInputComponents)) {
ListValue* list_value = NULL;
if (!manifest->GetList(keys::kInputComponents, &list_value)) {
- *error = errors::kInvalidInputComponents;
+ *error = ASCIIToUTF16(errors::kInvalidInputComponents);
return false;
}
@@ -2036,13 +2054,13 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
bool shortcut_shift = false;
if (!list_value->GetDictionary(i, &module_value)) {
- *error = errors::kInvalidInputComponents;
+ *error = ASCIIToUTF16(errors::kInvalidInputComponents);
return false;
}
// Get input_components[i].name.
if (!module_value->GetString(keys::kName, &name_str)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidInputComponentName, base::IntToString(i));
return false;
}
@@ -2055,12 +2073,12 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
} else if (type_str == "virtual_keyboard") {
type = INPUT_COMPONENT_TYPE_VIRTUAL_KEYBOARD;
} else {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidInputComponentType, base::IntToString(i));
return false;
}
} else {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidInputComponentType, base::IntToString(i));
return false;
}
@@ -2072,7 +2090,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
// Get input_components[i].description.
if (!module_value->GetString(keys::kDescription, &description_str)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidInputComponentDescription, base::IntToString(i));
return false;
}
@@ -2085,14 +2103,14 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
// Get input_components[i].layouts.
ListValue* layouts_value = NULL;
if (!module_value->GetList(keys::kLayouts, &layouts_value)) {
- *error = errors::kInvalidInputComponentLayouts;
+ *error = ASCIIToUTF16(errors::kInvalidInputComponentLayouts);
return false;
}
for (size_t j = 0; j < layouts_value->GetSize(); ++j) {
std::string layout_name_str;
if (!layouts_value->GetString(j, &layout_name_str)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidInputComponentLayoutName, base::IntToString(i),
base::IntToString(j));
return false;
@@ -2103,14 +2121,14 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (module_value->HasKey(keys::kShortcutKey)) {
DictionaryValue* shortcut_value = NULL;
if (!module_value->GetDictionary(keys::kShortcutKey, &shortcut_value)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidInputComponentShortcutKey, base::IntToString(i));
return false;
}
// Get input_components[i].shortcut_keycode.
if (!shortcut_value->GetString(keys::kKeycode, &shortcut_keycode_str)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidInputComponentShortcutKeycode,
base::IntToString(i));
return false;
@@ -2149,7 +2167,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kOmnibox)) {
if (!manifest->GetString(keys::kOmniboxKeyword, &omnibox_keyword_) ||
omnibox_keyword_.empty()) {
- *error = errors::kInvalidOmniboxKeyword;
+ *error = ASCIIToUTF16(errors::kInvalidOmniboxKeyword);
return false;
}
}
@@ -2158,16 +2176,16 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
std::string content_security_policy;
if (!manifest->GetString(keys::kContentSecurityPolicy,
&content_security_policy)) {
- *error = errors::kInvalidContentSecurityPolicy;
+ *error = ASCIIToUTF16(errors::kInvalidContentSecurityPolicy);
return false;
}
if (!ContentSecurityPolicyIsLegal(content_security_policy)) {
- *error = errors::kInvalidContentSecurityPolicy;
+ *error = ASCIIToUTF16(errors::kInvalidContentSecurityPolicy);
return false;
}
if (manifest_version_ >= 2 &&
!ContentSecurityPolicyIsSecure(content_security_policy)) {
- *error = errors::kInvalidContentSecurityPolicy;
+ *error = ASCIIToUTF16(errors::kInvalidContentSecurityPolicy);
return false;
}
@@ -2184,11 +2202,11 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kDevToolsPage)) {
std::string devtools_str;
if (!manifest->GetString(keys::kDevToolsPage, &devtools_str)) {
- *error = errors::kInvalidDevToolsPage;
+ *error = ASCIIToUTF16(errors::kInvalidDevToolsPage);
return false;
}
if (!api_permissions.count(ExtensionAPIPermission::kExperimental)) {
- *error = errors::kDevToolsExperimental;
+ *error = ASCIIToUTF16(errors::kDevToolsExperimental);
return false;
}
devtools_url_ = GetResourceURL(devtools_str);
@@ -2198,11 +2216,11 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kSidebar)) {
DictionaryValue* sidebar_value = NULL;
if (!manifest->GetDictionary(keys::kSidebar, &sidebar_value)) {
- *error = errors::kInvalidSidebar;
+ *error = ASCIIToUTF16(errors::kInvalidSidebar);
return false;
}
if (!api_permissions.count(ExtensionAPIPermission::kExperimental)) {
- *error = errors::kSidebarExperimental;
+ *error = ASCIIToUTF16(errors::kSidebarExperimental);
return false;
}
sidebar_defaults_.reset(LoadExtensionSidebarDefaults(sidebar_value, error));
@@ -2214,21 +2232,21 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kTtsEngine)) {
DictionaryValue* tts_dict = NULL;
if (!manifest->GetDictionary(keys::kTtsEngine, &tts_dict)) {
- *error = errors::kInvalidTts;
+ *error = ASCIIToUTF16(errors::kInvalidTts);
return false;
}
if (tts_dict->HasKey(keys::kTtsVoices)) {
ListValue* tts_voices = NULL;
if (!tts_dict->GetList(keys::kTtsVoices, &tts_voices)) {
- *error = errors::kInvalidTtsVoices;
+ *error = ASCIIToUTF16(errors::kInvalidTtsVoices);
return false;
}
for (size_t i = 0; i < tts_voices->GetSize(); i++) {
DictionaryValue* one_tts_voice = NULL;
if (!tts_voices->GetDictionary(i, &one_tts_voice)) {
- *error = errors::kInvalidTtsVoices;
+ *error = ASCIIToUTF16(errors::kInvalidTtsVoices);
return false;
}
@@ -2236,7 +2254,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (one_tts_voice->HasKey(keys::kTtsVoicesVoiceName)) {
if (!one_tts_voice->GetString(
keys::kTtsVoicesVoiceName, &voice_data.voice_name)) {
- *error = errors::kInvalidTtsVoicesVoiceName;
+ *error = ASCIIToUTF16(errors::kInvalidTtsVoicesVoiceName);
return false;
}
}
@@ -2244,7 +2262,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (!one_tts_voice->GetString(
keys::kTtsVoicesLang, &voice_data.lang) ||
!l10n_util::IsValidLocaleSyntax(voice_data.lang)) {
- *error = errors::kInvalidTtsVoicesLang;
+ *error = ASCIIToUTF16(errors::kInvalidTtsVoicesLang);
return false;
}
}
@@ -2253,7 +2271,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
keys::kTtsVoicesGender, &voice_data.gender) ||
(voice_data.gender != keys::kTtsGenderMale &&
voice_data.gender != keys::kTtsGenderFemale)) {
- *error = errors::kInvalidTtsVoicesGender;
+ *error = ASCIIToUTF16(errors::kInvalidTtsVoicesGender);
return false;
}
}
@@ -2261,13 +2279,13 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
ListValue* event_types_list;
if (!one_tts_voice->GetList(
keys::kTtsVoicesEventTypes, &event_types_list)) {
- *error = errors::kInvalidTtsVoicesEventTypes;
+ *error = ASCIIToUTF16(errors::kInvalidTtsVoicesEventTypes);
return false;
}
for (size_t i = 0; i < event_types_list->GetSize(); i++) {
std::string event_type;
if (!event_types_list->GetString(i, &event_type)) {
- *error = errors::kInvalidTtsVoicesEventTypes;
+ *error = ASCIIToUTF16(errors::kInvalidTtsVoicesEventTypes);
return false;
}
if (event_type != keys::kTtsVoicesEventTypeEnd &&
@@ -2276,12 +2294,12 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
event_type != keys::kTtsVoicesEventTypeSentence &&
event_type != keys::kTtsVoicesEventTypeStart &&
event_type != keys::kTtsVoicesEventTypeWord) {
- *error = errors::kInvalidTtsVoicesEventTypes;
+ *error = ASCIIToUTF16(errors::kInvalidTtsVoicesEventTypes);
return false;
}
if (voice_data.event_types.find(event_type) !=
voice_data.event_types.end()) {
- *error = errors::kInvalidTtsVoicesEventTypes;
+ *error = ASCIIToUTF16(errors::kInvalidTtsVoicesEventTypes);
return false;
}
voice_data.event_types.insert(event_type);
@@ -2303,7 +2321,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kIncognito)) {
std::string value;
if (!manifest->GetString(keys::kIncognito, &value)) {
- *error = errors::kInvalidIncognitoBehavior;
+ *error = ASCIIToUTF16(errors::kInvalidIncognitoBehavior);
return false;
}
if (value == values::kIncognitoSpanning) {
@@ -2311,7 +2329,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
} else if (value == values::kIncognitoSplit) {
incognito_split_mode_ = true;
} else {
- *error = errors::kInvalidIncognitoBehavior;
+ *error = ASCIIToUTF16(errors::kInvalidIncognitoBehavior);
return false;
}
}
@@ -2319,7 +2337,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
// Initialize offline-enabled status. Defaults to false.
if (manifest->HasKey(keys::kOfflineEnabled)) {
if (!manifest->GetBoolean(keys::kOfflineEnabled, &offline_enabled_)) {
- *error = errors::kInvalidOfflineEnabled;
+ *error = ASCIIToUTF16(errors::kInvalidOfflineEnabled);
return false;
}
}
@@ -2329,7 +2347,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
if (manifest->HasKey(keys::kRequirements)) {
DictionaryValue* requirements_value = NULL;
if (!manifest->GetDictionary(keys::kRequirements, &requirements_value)) {
- *error = errors::kInvalidRequirements;
+ *error = ASCIIToUTF16(errors::kInvalidRequirements);
return false;
}
@@ -2338,7 +2356,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
DictionaryValue* requirement_value;
if (!requirements_value->GetDictionaryWithoutPathExpansion(
*it, &requirement_value)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidRequirement, *it);
return false;
}
@@ -2346,7 +2364,7 @@ bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
}
if (HasMultipleUISurfaces()) {
- *error = errors::kOneUISurfaceOnly;
+ *error = ASCIIToUTF16(errors::kOneUISurfaceOnly);
return false;
}
@@ -2515,7 +2533,7 @@ GURL Extension::GetIconURL(int size,
bool Extension::ParsePermissions(const extensions::Manifest* source,
const char* key,
int flags,
- std::string* error,
+ string16* error,
ExtensionAPIPermissionSet* api_permissions,
URLPatternSet* host_permissions) {
if (source->HasKey(key)) {
@@ -2525,7 +2543,7 @@ bool Extension::ParsePermissions(const extensions::Manifest* source,
: URLPattern::IGNORE_PORTS);
ListValue* permissions = NULL;
if (!source->GetList(key, &permissions)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidPermissions, "");
return false;
}
@@ -2533,7 +2551,7 @@ bool Extension::ParsePermissions(const extensions::Manifest* source,
for (size_t i = 0; i < permissions->GetSize(); ++i) {
std::string permission_str;
if (!permissions->GetString(i, &permission_str)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidPermission, base::IntToString(i));
return false;
}
@@ -2557,7 +2575,7 @@ bool Extension::ParsePermissions(const extensions::Manifest* source,
URLPattern::ParseResult parse_result = pattern.Parse(permission_str);
if (parse_result == URLPattern::PARSE_SUCCESS) {
if (!CanSpecifyHostPermission(pattern, *api_permissions)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidPermissionScheme, base::IntToString(i));
return false;
}
@@ -2761,10 +2779,10 @@ bool Extension::ImplicitlyDelaysNetworkStartup() const {
bool Extension::CanSpecifyAPIPermission(
const ExtensionAPIPermission* permission,
- std::string* error) const {
+ string16* error) const {
if (permission->is_component_only()) {
if (!CanSpecifyComponentOnlyPermission()) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kPermissionNotAllowed, permission->name());
return false;
}
@@ -2772,7 +2790,7 @@ bool Extension::CanSpecifyAPIPermission(
if (permission->id() == ExtensionAPIPermission::kExperimental) {
if (!CanSpecifyExperimentalPermission()) {
- *error = errors::kExperimentalFlagRequired;
+ *error = ASCIIToUTF16(errors::kExperimentalFlagRequired);
return false;
}
}
@@ -2810,7 +2828,7 @@ bool Extension::CanSpecifyAPIPermission(
// we won't have to maintain all these tricky backward compat issues:
// crbug.com/102328.
if (!is_hosted_app() || creation_flags_ & STRICT_ERROR_CHECKS) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kPermissionNotAllowed, permission->name());
}
return false;
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index f76429e..0ac4fd2 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -381,7 +381,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
bool ParsePermissions(const extensions::Manifest* source,
const char* key,
int flags,
- std::string* error,
+ string16* error,
ExtensionAPIPermissionSet* api_permissions,
URLPatternSet* host_permissions);
@@ -622,7 +622,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
// Initialize the extension from a parsed manifest.
// Takes ownership of the manifest |value|.
bool InitFromValue(extensions::Manifest* value, int flags,
- std::string* error);
+ string16* error);
// Helper function for implementing HasCachedImage/GetCachedImage. A return
// value of NULL means there is no matching image cached (we allow caching an
@@ -635,7 +635,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
bool LoadUserScriptHelper(const base::DictionaryValue* content_script,
int definition_index,
int flags,
- std::string* error,
+ string16* error,
UserScript* result);
// Helper method that loads either the include_globs or exclude_globs list
@@ -643,7 +643,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
bool LoadGlobsHelper(const base::DictionaryValue* content_script,
int content_script_index,
const char* globs_property_name,
- std::string* error,
+ string16* error,
void(UserScript::*add_method)(const std::string& glob),
UserScript *instance);
@@ -654,32 +654,32 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
const char* list_error,
const char* value_error,
URLPattern::ParseOption parse_option,
- std::string* error);
+ string16* error);
bool LoadLaunchContainer(const extensions::Manifest* manifest,
- std::string* error);
+ string16* error);
bool LoadLaunchURL(const extensions::Manifest* manifest,
- std::string* error);
+ string16* error);
bool LoadAppIsolation(const extensions::Manifest* manifest,
- std::string* error);
+ string16* error);
bool LoadWebIntentServices(const extensions::Manifest* manifest,
- std::string* error);
+ string16* error);
// Helper method to load an ExtensionAction from the page_action or
// browser_action entries in the manifest.
ExtensionAction* LoadExtensionActionHelper(
- const base::DictionaryValue* extension_action, std::string* error);
+ const base::DictionaryValue* extension_action, string16* error);
// Helper method to load an FileBrowserHandlerList from the manifest.
FileBrowserHandlerList* LoadFileBrowserHandlers(
- const base::ListValue* extension_actions, std::string* error);
+ const base::ListValue* extension_actions, string16* error);
// Helper method to load an FileBrowserHandler from manifest.
FileBrowserHandler* LoadFileBrowserHandler(
- const base::DictionaryValue* file_browser_handlers, std::string* error);
+ const base::DictionaryValue* file_browser_handlers, string16* error);
// Helper method to load an ExtensionSidebarDefaults from the sidebar manifest
// entry.
ExtensionSidebarDefaults* LoadExtensionSidebarDefaults(
- const base::DictionaryValue* sidebar, std::string* error);
+ const base::DictionaryValue* sidebar, string16* error);
// Returns true if the extension has more than one "UI surface". For example,
// an extension that has a browser action and a page action.
@@ -691,7 +691,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
// Returns true if this extension can specify |api|.
bool CanSpecifyAPIPermission(const ExtensionAPIPermission* api,
- std::string* error) const;
+ string16* error) const;
bool CanSpecifyComponentOnlyPermission() const;
bool CanSpecifyExperimentalPermission() const;
diff --git a/chrome/common/extensions/extension_error_utils.cc b/chrome/common/extensions/extension_error_utils.cc
index 0256c8d8..42da01e 100644
--- a/chrome/common/extensions/extension_error_utils.cc
+++ b/chrome/common/extensions/extension_error_utils.cc
@@ -1,10 +1,11 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/extensions/extension_error_utils.h"
#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
std::string ExtensionErrorUtils::FormatErrorMessage(
const std::string& format,
@@ -35,3 +36,34 @@ std::string ExtensionErrorUtils::FormatErrorMessage(
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s3);
return ret_val;
}
+
+string16 ExtensionErrorUtils::FormatErrorMessageUTF16(
+ const std::string& format,
+ const std::string& s1) {
+ std::string ret_val = format;
+ ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1);
+ return UTF8ToUTF16(ret_val);
+}
+
+string16 ExtensionErrorUtils::FormatErrorMessageUTF16(
+ const std::string& format,
+ const std::string& s1,
+ const std::string& s2) {
+ std::string ret_val = format;
+ ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1);
+ ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2);
+ return UTF8ToUTF16(ret_val);
+}
+
+string16 ExtensionErrorUtils::FormatErrorMessageUTF16(
+ const std::string& format,
+ const std::string& s1,
+ const std::string& s2,
+ const std::string& s3) {
+ std::string ret_val = format;
+ ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1);
+ ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2);
+ ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s3);
+ return UTF8ToUTF16(ret_val);
+}
+
diff --git a/chrome/common/extensions/extension_error_utils.h b/chrome/common/extensions/extension_error_utils.h
index 0c9bd4d..52d7efd 100644
--- a/chrome/common/extensions/extension_error_utils.h
+++ b/chrome/common/extensions/extension_error_utils.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,20 +8,34 @@
#include <string>
+#include "base/string16.h"
+
class ExtensionErrorUtils {
public:
// Creates an error messages from a pattern.
static std::string FormatErrorMessage(const std::string& format,
- const std::string& s1);
+ const std::string& s1);
static std::string FormatErrorMessage(const std::string& format,
- const std::string& s1,
- const std::string& s2);
+ const std::string& s1,
+ const std::string& s2);
static std::string FormatErrorMessage(const std::string& format,
- const std::string& s1,
- const std::string& s2,
- const std::string& s3);
+ const std::string& s1,
+ const std::string& s2,
+ const std::string& s3);
+
+ static string16 FormatErrorMessageUTF16(const std::string& format,
+ const std::string& s1);
+
+ static string16 FormatErrorMessageUTF16(const std::string& format,
+ const std::string& s1,
+ const std::string& s2);
+
+ static string16 FormatErrorMessageUTF16(const std::string& format,
+ const std::string& s1,
+ const std::string& s2,
+ const std::string& s3);
};
#endif // CHROME_COMMON_EXTENSIONS_EXTENSION_ERROR_UTILS_H_
diff --git a/chrome/common/extensions/extension_unpacker.cc b/chrome/common/extensions/extension_unpacker.cc
index bf2452e..5e4eec4 100644
--- a/chrome/common/extensions/extension_unpacker.cc
+++ b/chrome/common/extensions/extension_unpacker.cc
@@ -324,5 +324,5 @@ bool ExtensionUnpacker::ReadMessageCatalog(const FilePath& message_path) {
}
void ExtensionUnpacker::SetError(const std::string &error) {
- error_message_ = error;
+ error_message_ = UTF8ToUTF16(error);
}
diff --git a/chrome/common/extensions/extension_unpacker.h b/chrome/common/extensions/extension_unpacker.h
index 3655a38..27d3cc0 100644
--- a/chrome/common/extensions/extension_unpacker.h
+++ b/chrome/common/extensions/extension_unpacker.h
@@ -59,7 +59,7 @@ class ExtensionUnpacker {
static bool ReadMessageCatalogsFromFile(const FilePath& extension_path,
base::DictionaryValue* catalogs);
- const std::string& error_message() { return error_message_; }
+ const string16& error_message() { return error_message_; }
base::DictionaryValue* parsed_manifest() {
return parsed_manifest_.get();
}
@@ -109,7 +109,7 @@ class ExtensionUnpacker {
scoped_ptr<base::DictionaryValue> parsed_catalogs_;
// The last error message that was set. Empty if there were no errors.
- std::string error_message_;
+ string16 error_message_;
DISALLOW_COPY_AND_ASSIGN(ExtensionUnpacker);
};
diff --git a/chrome/common/extensions/extension_unpacker_unittest.cc b/chrome/common/extensions/extension_unpacker_unittest.cc
index c14df0c..8b7449e 100644
--- a/chrome/common/extensions/extension_unpacker_unittest.cc
+++ b/chrome/common/extensions/extension_unpacker_unittest.cc
@@ -6,6 +6,7 @@
#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -48,21 +49,21 @@ public:
TEST_F(ExtensionUnpackerTest, EmptyDefaultLocale) {
SetupUnpacker("empty_default_locale.crx");
EXPECT_FALSE(unpacker_->Run());
- EXPECT_EQ(std::string(errors::kInvalidDefaultLocale),
+ EXPECT_EQ(ASCIIToUTF16(errors::kInvalidDefaultLocale),
unpacker_->error_message());
}
TEST_F(ExtensionUnpackerTest, HasDefaultLocaleMissingLocalesFolder) {
SetupUnpacker("has_default_missing_locales.crx");
EXPECT_FALSE(unpacker_->Run());
- EXPECT_EQ(std::string(errors::kLocalesTreeMissing),
+ EXPECT_EQ(ASCIIToUTF16(errors::kLocalesTreeMissing),
unpacker_->error_message());
}
TEST_F(ExtensionUnpackerTest, InvalidDefaultLocale) {
SetupUnpacker("invalid_default_locale.crx");
EXPECT_FALSE(unpacker_->Run());
- EXPECT_EQ(std::string(errors::kInvalidDefaultLocale),
+ EXPECT_EQ(ASCIIToUTF16(errors::kInvalidDefaultLocale),
unpacker_->error_message());
}
@@ -70,21 +71,21 @@ TEST_F(ExtensionUnpackerTest, InvalidMessagesFile) {
SetupUnpacker("invalid_messages_file.crx");
EXPECT_FALSE(unpacker_->Run());
EXPECT_TRUE(MatchPattern(unpacker_->error_message(),
- std::string("*_locales?en_US?messages.json: Line: 2, column: 3,"
+ ASCIIToUTF16("*_locales?en_US?messages.json: Line: 2, column: 3,"
" Dictionary keys must be quoted.")));
}
TEST_F(ExtensionUnpackerTest, MissingDefaultData) {
SetupUnpacker("missing_default_data.crx");
EXPECT_FALSE(unpacker_->Run());
- EXPECT_EQ(std::string(errors::kLocalesNoDefaultMessages),
+ EXPECT_EQ(ASCIIToUTF16(errors::kLocalesNoDefaultMessages),
unpacker_->error_message());
}
TEST_F(ExtensionUnpackerTest, MissingDefaultLocaleHasLocalesFolder) {
SetupUnpacker("missing_default_has_locales.crx");
EXPECT_FALSE(unpacker_->Run());
- EXPECT_EQ(std::string(errors::kLocalesNoDefaultLocaleSpecified),
+ EXPECT_EQ(ASCIIToUTF16(errors::kLocalesNoDefaultLocaleSpecified),
unpacker_->error_message());
}
@@ -92,14 +93,14 @@ TEST_F(ExtensionUnpackerTest, MissingMessagesFile) {
SetupUnpacker("missing_messages_file.crx");
EXPECT_FALSE(unpacker_->Run());
EXPECT_TRUE(MatchPattern(unpacker_->error_message(),
- errors::kLocalesMessagesFileMissing +
- std::string("*_locales?en_US?messages.json")));
+ ASCIIToUTF16(errors::kLocalesMessagesFileMissing) +
+ ASCIIToUTF16("*_locales?en_US?messages.json")));
}
TEST_F(ExtensionUnpackerTest, NoLocaleData) {
SetupUnpacker("no_locale_data.crx");
EXPECT_FALSE(unpacker_->Run());
- EXPECT_EQ(std::string(errors::kLocalesNoDefaultMessages),
+ EXPECT_EQ(ASCIIToUTF16(errors::kLocalesNoDefaultMessages),
unpacker_->error_message());
}
diff --git a/chrome/common/extensions/manifest.cc b/chrome/common/extensions/manifest.cc
index 5f8df9c..2561762 100644
--- a/chrome/common/extensions/manifest.cc
+++ b/chrome/common/extensions/manifest.cc
@@ -114,7 +114,7 @@ std::set<std::string> Manifest::GetAllKnownKeys() {
Manifest::Manifest(DictionaryValue* value) : value_(value) {}
Manifest::~Manifest() {}
-bool Manifest::ValidateManifest(std::string* error) const {
+bool Manifest::ValidateManifest(string16* error) const {
Restrictions restrictions = g_restrictions.Get();
Type type = GetType();
@@ -129,7 +129,7 @@ bool Manifest::ValidateManifest(std::string* error) const {
}
if (!restrictions.CanAccessKey(*key, type)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kFeatureNotAllowed, *key);
return false;
}
diff --git a/chrome/common/extensions/manifest.h b/chrome/common/extensions/manifest.h
index fb372708..45c5d97 100644
--- a/chrome/common/extensions/manifest.h
+++ b/chrome/common/extensions/manifest.h
@@ -60,7 +60,7 @@ class Manifest {
// Returns true if all keys in the manifest can be specified by
// the extension type.
- bool ValidateManifest(std::string* error) const;
+ bool ValidateManifest(string16* error) const;
// Returns the manifest type.
Type GetType() const;
diff --git a/chrome/common/extensions/manifest_unittest.cc b/chrome/common/extensions/manifest_unittest.cc
index 37eb242..4e35be6 100644
--- a/chrome/common/extensions/manifest_unittest.cc
+++ b/chrome/common/extensions/manifest_unittest.cc
@@ -148,10 +148,11 @@ class ManifestTest : public testing::Test {
// fail validation and are filtered out.
DictionaryValue* value = manifest->value();
for (size_t i = 0; i < restricted_keys_length; ++i) {
- std::string error, str;
+ std::string str;
+ string16 error;
value->Set(restricted_keys[i], Value::CreateStringValue(default_value_));
EXPECT_FALSE(manifest->ValidateManifest(&error));
- EXPECT_EQ(error, ExtensionErrorUtils::FormatErrorMessage(
+ EXPECT_EQ(error, ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kFeatureNotAllowed, restricted_keys[i]));
EXPECT_FALSE(manifest->GetString(restricted_keys[i], &str));
EXPECT_TRUE(value->Remove(restricted_keys[i], NULL));
@@ -175,9 +176,9 @@ TEST_F(ManifestTest, Extension) {
value->Set(*i, Value::CreateStringValue(default_value_));
scoped_ptr<Manifest> manifest(new Manifest(value));
- std::string error;
+ string16 error;
EXPECT_TRUE(manifest->ValidateManifest(&error));
- EXPECT_EQ("", error);
+ EXPECT_EQ(ASCIIToUTF16(""), error);
AssertType(manifest.get(), Manifest::kTypeExtension);
// Verify that all the extension keys are accessible.
@@ -210,9 +211,9 @@ TEST_F(ManifestTest, Theme) {
value->Set(theme_key, Value::CreateStringValue(default_value_));
scoped_ptr<Manifest> manifest(new Manifest(value));
- std::string error;
+ string16 error;
EXPECT_TRUE(manifest->ValidateManifest(&error));
- EXPECT_EQ("", error);
+ EXPECT_EQ(ASCIIToUTF16(""), error);
AssertType(manifest.get(), Manifest::kTypeTheme);
// Verify that all the theme keys are accessible.
@@ -244,9 +245,9 @@ TEST_F(ManifestTest, PlatformApp) {
value->Set(keys::kPlatformApp, Value::CreateBooleanValue(true));
scoped_ptr<Manifest> manifest(new Manifest(value));
- std::string error;
+ string16 error;
EXPECT_TRUE(manifest->ValidateManifest(&error));
- EXPECT_EQ("", error);
+ EXPECT_EQ(ASCIIToUTF16(""), error);
AssertType(manifest.get(), Manifest::kTypePlatformApp);
// Verify that all the platform app keys are accessible.
@@ -279,9 +280,9 @@ TEST_F(ManifestTest, HostedApp) {
value->Set(keys::kWebURLs, Value::CreateStringValue(default_value_));
scoped_ptr<Manifest> manifest(new Manifest(value));
- std::string error;
+ string16 error;
EXPECT_TRUE(manifest->ValidateManifest(&error));
- EXPECT_EQ("", error);
+ EXPECT_EQ(ASCIIToUTF16(""), error);
AssertType(manifest.get(), Manifest::kTypeHostedApp);
// Verify that all the hosted app keys are accessible.
@@ -312,9 +313,9 @@ TEST_F(ManifestTest, PackagedApp) {
value->Set(keys::kApp, Value::CreateStringValue(default_value_));
scoped_ptr<Manifest> manifest(new Manifest(value));
- std::string error;
+ string16 error;
EXPECT_TRUE(manifest->ValidateManifest(&error));
- EXPECT_EQ("", error);
+ EXPECT_EQ(ASCIIToUTF16(""), error);
AssertType(manifest.get(), Manifest::kTypePackagedApp);
// Verify that all the packaged app keys are accessible.