Commit 95facbc5 authored by Oksana Zhuravlova's avatar Oksana Zhuravlova Committed by Commit Bot

Convert profile_import.mojom to use mojo/public/mojom/base/values.mojom

This change also converts the minimum necessary amount of C++ code to pass
objects of base::Value by value instead of std::unique_ptr.

Bug: 646113,799482
Change-Id: I24fa46c4bf50526422e2f4e5e34eeb62999b9958
Reviewed-on: https://chromium-review.googlesource.com/994274Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Commit-Queue: Oksana Zhuravlova <oksamyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548804}
parent 400c1e29
......@@ -50,27 +50,28 @@ void ExternalProcessImporterClient::Start() {
// Dictionary of all localized strings that could be needed by the importer
// in the external process.
auto localized_strings = std::make_unique<base::DictionaryValue>();
localized_strings->SetString(base::IntToString(IDS_BOOKMARK_GROUP),
l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP));
localized_strings->SetString(
base::Value localized_strings(base::Value::Type::DICTIONARY);
localized_strings.SetKey(
base::IntToString(IDS_BOOKMARK_GROUP),
base::Value(l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP)));
localized_strings.SetKey(
base::IntToString(IDS_BOOKMARK_GROUP_FROM_FIREFOX),
l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_FIREFOX));
localized_strings->SetString(
base::Value(l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_FIREFOX)));
localized_strings.SetKey(
base::IntToString(IDS_BOOKMARK_GROUP_FROM_SAFARI),
l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_SAFARI));
localized_strings->SetString(
base::Value(l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_SAFARI)));
localized_strings.SetKey(
base::IntToString(IDS_IMPORT_FROM_FIREFOX),
l10n_util::GetStringUTF8(IDS_IMPORT_FROM_FIREFOX));
localized_strings->SetString(
base::Value(l10n_util::GetStringUTF8(IDS_IMPORT_FROM_FIREFOX)));
localized_strings.SetKey(
base::IntToString(IDS_IMPORT_FROM_ICEWEASEL),
l10n_util::GetStringUTF8(IDS_IMPORT_FROM_ICEWEASEL));
localized_strings->SetString(
base::Value(l10n_util::GetStringUTF8(IDS_IMPORT_FROM_ICEWEASEL)));
localized_strings.SetKey(
base::IntToString(IDS_IMPORT_FROM_SAFARI),
l10n_util::GetStringUTF8(IDS_IMPORT_FROM_SAFARI));
localized_strings->SetString(
base::Value(l10n_util::GetStringUTF8(IDS_IMPORT_FROM_SAFARI)));
localized_strings.SetKey(
base::IntToString(IDS_BOOKMARK_BAR_FOLDER_NAME),
l10n_util::GetStringUTF8(IDS_BOOKMARK_BAR_FOLDER_NAME));
base::Value(l10n_util::GetStringUTF8(IDS_BOOKMARK_BAR_FOLDER_NAME)));
// If the utility process hasn't started yet the message will queue until it
// does.
......
......@@ -11,7 +11,6 @@ mojom("interfaces") {
public_deps = [
"//components/autofill/content/common:mojo_types",
"//mojo/common:common_custom_types",
"//mojo/public/mojom/base",
"//url/mojom:url_mojom_gurl",
]
......
......@@ -6,7 +6,7 @@ module chrome.mojom;
import "components/autofill/content/common/autofill_types.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "mojo/common/values.mojom";
import "mojo/public/mojom/base/values.mojom";
import "url/mojom/url.mojom";
const string kProfileImportServiceName = "profile_import";
......@@ -76,7 +76,7 @@ interface ProfileImport {
StartImport(
SourceProfile source_profile,
uint16 items,
mojo.common.mojom.DictionaryValue localized_strings,
mojo_base.mojom.DictionaryValue localized_strings,
ProfileImportObserver observer);
// Stop the importer.
......
......@@ -32,12 +32,10 @@ const int kNumAutofillFormDataToSend = 100;
} // namespace
ExternalProcessImporterBridge::ExternalProcessImporterBridge(
const base::DictionaryValue& localized_strings,
base::Value localized_strings,
scoped_refptr<chrome::mojom::ThreadSafeProfileImportObserverPtr> observer)
: observer_(std::move(observer)) {
// Bridge needs to make its own copy because OS 10.6 autoreleases the
// localized_strings value that is passed in (see http://crbug.com/46003 ).
localized_strings_.reset(localized_strings.DeepCopy());
localized_strings_ = std::move(localized_strings);
}
void ExternalProcessImporterBridge::AddBookmarks(
......@@ -179,9 +177,10 @@ void ExternalProcessImporterBridge::NotifyEnded() {
base::string16 ExternalProcessImporterBridge::GetLocalizedString(
int message_id) {
base::string16 message;
localized_strings_->GetString(base::IntToString(message_id), &message);
return message;
base::Value* message_value =
localized_strings_.FindKey(base::IntToString(message_id));
DCHECK(message_value);
return base::UTF8ToUTF16(message_value->GetString());
}
ExternalProcessImporterBridge::~ExternalProcessImporterBridge() {}
......@@ -11,6 +11,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/common/importer/importer_bridge.h"
#include "chrome/common/importer/profile_import.mojom.h"
......@@ -19,10 +20,6 @@
class GURL;
struct ImportedBookmarkEntry;
namespace base {
class DictionaryValue;
}
namespace importer {
#if defined(OS_WIN)
struct ImporterIE7PasswordInfo;
......@@ -44,7 +41,7 @@ class ExternalProcessImporterBridge : public ImporterBridge {
public:
// |observer| must outlive this object.
ExternalProcessImporterBridge(
const base::DictionaryValue& localized_strings,
base::Value localized_strings,
scoped_refptr<chrome::mojom::ThreadSafeProfileImportObserverPtr>
observer);
......@@ -89,7 +86,7 @@ class ExternalProcessImporterBridge : public ImporterBridge {
// Holds strings needed by the external importer because the resource
// bundle isn't available to the external process.
std::unique_ptr<base::DictionaryValue> localized_strings_;
base::Value localized_strings_;
scoped_refptr<chrome::mojom::ThreadSafeProfileImportObserverPtr> observer_;
......
......@@ -29,7 +29,7 @@ ProfileImportImpl::~ProfileImportImpl() {}
void ProfileImportImpl::StartImport(
const importer::SourceProfile& source_profile,
uint16_t items,
std::unique_ptr<base::DictionaryValue> localized_strings,
base::Value localized_strings,
chrome::mojom::ProfileImportObserverPtr observer) {
content::UtilityThread::Get()->EnsureBlinkInitialized();
importer_ = importer::CreateImporterByType(source_profile.importer_type);
......@@ -50,7 +50,7 @@ void ProfileImportImpl::StartImport(
ImporterCleanup();
}
bridge_ = new ExternalProcessImporterBridge(
*localized_strings,
std::move(localized_strings),
ThreadSafeProfileImportObserverPtr::Create(std::move(observer)));
import_thread_->task_runner()->PostTask(
FROM_HERE,
......
......@@ -11,6 +11,7 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/values.h"
#include "chrome/common/importer/profile_import.mojom.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "services/service_manager/public/cpp/service_context_ref.h"
......@@ -19,7 +20,6 @@ class ExternalProcessImporterBridge;
class Importer;
namespace base {
class DictionaryValue;
class Thread;
} // namespace base
......@@ -37,7 +37,7 @@ class ProfileImportImpl : public chrome::mojom::ProfileImport {
// chrome::mojom::ProfileImport:
void StartImport(const importer::SourceProfile& source_profile,
uint16_t items,
std::unique_ptr<base::DictionaryValue> localized_strings,
base::Value localized_strings,
chrome::mojom::ProfileImportObserverPtr observer) override;
void CancelImport() override;
void ReportImportItemFinished(importer::ImportItem item) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment