summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-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
18 files changed, 157 insertions, 134 deletions
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;
}