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() { ...@@ -50,27 +50,28 @@ void ExternalProcessImporterClient::Start() {
// Dictionary of all localized strings that could be needed by the importer // Dictionary of all localized strings that could be needed by the importer
// in the external process. // in the external process.
auto localized_strings = std::make_unique<base::DictionaryValue>(); base::Value localized_strings(base::Value::Type::DICTIONARY);
localized_strings->SetString(base::IntToString(IDS_BOOKMARK_GROUP), localized_strings.SetKey(
l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP)); base::IntToString(IDS_BOOKMARK_GROUP),
localized_strings->SetString( base::Value(l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP)));
localized_strings.SetKey(
base::IntToString(IDS_BOOKMARK_GROUP_FROM_FIREFOX), base::IntToString(IDS_BOOKMARK_GROUP_FROM_FIREFOX),
l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_FIREFOX)); base::Value(l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_FIREFOX)));
localized_strings->SetString( localized_strings.SetKey(
base::IntToString(IDS_BOOKMARK_GROUP_FROM_SAFARI), base::IntToString(IDS_BOOKMARK_GROUP_FROM_SAFARI),
l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_SAFARI)); base::Value(l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_SAFARI)));
localized_strings->SetString( localized_strings.SetKey(
base::IntToString(IDS_IMPORT_FROM_FIREFOX), base::IntToString(IDS_IMPORT_FROM_FIREFOX),
l10n_util::GetStringUTF8(IDS_IMPORT_FROM_FIREFOX)); base::Value(l10n_util::GetStringUTF8(IDS_IMPORT_FROM_FIREFOX)));
localized_strings->SetString( localized_strings.SetKey(
base::IntToString(IDS_IMPORT_FROM_ICEWEASEL), base::IntToString(IDS_IMPORT_FROM_ICEWEASEL),
l10n_util::GetStringUTF8(IDS_IMPORT_FROM_ICEWEASEL)); base::Value(l10n_util::GetStringUTF8(IDS_IMPORT_FROM_ICEWEASEL)));
localized_strings->SetString( localized_strings.SetKey(
base::IntToString(IDS_IMPORT_FROM_SAFARI), base::IntToString(IDS_IMPORT_FROM_SAFARI),
l10n_util::GetStringUTF8(IDS_IMPORT_FROM_SAFARI)); base::Value(l10n_util::GetStringUTF8(IDS_IMPORT_FROM_SAFARI)));
localized_strings->SetString( localized_strings.SetKey(
base::IntToString(IDS_BOOKMARK_BAR_FOLDER_NAME), 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 // If the utility process hasn't started yet the message will queue until it
// does. // does.
......
...@@ -11,7 +11,6 @@ mojom("interfaces") { ...@@ -11,7 +11,6 @@ mojom("interfaces") {
public_deps = [ public_deps = [
"//components/autofill/content/common:mojo_types", "//components/autofill/content/common:mojo_types",
"//mojo/common:common_custom_types",
"//mojo/public/mojom/base", "//mojo/public/mojom/base",
"//url/mojom:url_mojom_gurl", "//url/mojom:url_mojom_gurl",
] ]
......
...@@ -6,7 +6,7 @@ module chrome.mojom; ...@@ -6,7 +6,7 @@ module chrome.mojom;
import "components/autofill/content/common/autofill_types.mojom"; import "components/autofill/content/common/autofill_types.mojom";
import "mojo/public/mojom/base/string16.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"; import "url/mojom/url.mojom";
const string kProfileImportServiceName = "profile_import"; const string kProfileImportServiceName = "profile_import";
...@@ -76,7 +76,7 @@ interface ProfileImport { ...@@ -76,7 +76,7 @@ interface ProfileImport {
StartImport( StartImport(
SourceProfile source_profile, SourceProfile source_profile,
uint16 items, uint16 items,
mojo.common.mojom.DictionaryValue localized_strings, mojo_base.mojom.DictionaryValue localized_strings,
ProfileImportObserver observer); ProfileImportObserver observer);
// Stop the importer. // Stop the importer.
......
...@@ -32,12 +32,10 @@ const int kNumAutofillFormDataToSend = 100; ...@@ -32,12 +32,10 @@ const int kNumAutofillFormDataToSend = 100;
} // namespace } // namespace
ExternalProcessImporterBridge::ExternalProcessImporterBridge( ExternalProcessImporterBridge::ExternalProcessImporterBridge(
const base::DictionaryValue& localized_strings, base::Value localized_strings,
scoped_refptr<chrome::mojom::ThreadSafeProfileImportObserverPtr> observer) scoped_refptr<chrome::mojom::ThreadSafeProfileImportObserverPtr> observer)
: observer_(std::move(observer)) { : observer_(std::move(observer)) {
// Bridge needs to make its own copy because OS 10.6 autoreleases the localized_strings_ = std::move(localized_strings);
// localized_strings value that is passed in (see http://crbug.com/46003 ).
localized_strings_.reset(localized_strings.DeepCopy());
} }
void ExternalProcessImporterBridge::AddBookmarks( void ExternalProcessImporterBridge::AddBookmarks(
...@@ -179,9 +177,10 @@ void ExternalProcessImporterBridge::NotifyEnded() { ...@@ -179,9 +177,10 @@ void ExternalProcessImporterBridge::NotifyEnded() {
base::string16 ExternalProcessImporterBridge::GetLocalizedString( base::string16 ExternalProcessImporterBridge::GetLocalizedString(
int message_id) { int message_id) {
base::string16 message; base::Value* message_value =
localized_strings_->GetString(base::IntToString(message_id), &message); localized_strings_.FindKey(base::IntToString(message_id));
return message; DCHECK(message_value);
return base::UTF8ToUTF16(message_value->GetString());
} }
ExternalProcessImporterBridge::~ExternalProcessImporterBridge() {} ExternalProcessImporterBridge::~ExternalProcessImporterBridge() {}
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/values.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/common/importer/importer_bridge.h" #include "chrome/common/importer/importer_bridge.h"
#include "chrome/common/importer/profile_import.mojom.h" #include "chrome/common/importer/profile_import.mojom.h"
...@@ -19,10 +20,6 @@ ...@@ -19,10 +20,6 @@
class GURL; class GURL;
struct ImportedBookmarkEntry; struct ImportedBookmarkEntry;
namespace base {
class DictionaryValue;
}
namespace importer { namespace importer {
#if defined(OS_WIN) #if defined(OS_WIN)
struct ImporterIE7PasswordInfo; struct ImporterIE7PasswordInfo;
...@@ -44,7 +41,7 @@ class ExternalProcessImporterBridge : public ImporterBridge { ...@@ -44,7 +41,7 @@ class ExternalProcessImporterBridge : public ImporterBridge {
public: public:
// |observer| must outlive this object. // |observer| must outlive this object.
ExternalProcessImporterBridge( ExternalProcessImporterBridge(
const base::DictionaryValue& localized_strings, base::Value localized_strings,
scoped_refptr<chrome::mojom::ThreadSafeProfileImportObserverPtr> scoped_refptr<chrome::mojom::ThreadSafeProfileImportObserverPtr>
observer); observer);
...@@ -89,7 +86,7 @@ class ExternalProcessImporterBridge : public ImporterBridge { ...@@ -89,7 +86,7 @@ class ExternalProcessImporterBridge : public ImporterBridge {
// Holds strings needed by the external importer because the resource // Holds strings needed by the external importer because the resource
// bundle isn't available to the external process. // 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_; scoped_refptr<chrome::mojom::ThreadSafeProfileImportObserverPtr> observer_;
......
...@@ -29,7 +29,7 @@ ProfileImportImpl::~ProfileImportImpl() {} ...@@ -29,7 +29,7 @@ ProfileImportImpl::~ProfileImportImpl() {}
void ProfileImportImpl::StartImport( void ProfileImportImpl::StartImport(
const importer::SourceProfile& source_profile, const importer::SourceProfile& source_profile,
uint16_t items, uint16_t items,
std::unique_ptr<base::DictionaryValue> localized_strings, base::Value localized_strings,
chrome::mojom::ProfileImportObserverPtr observer) { chrome::mojom::ProfileImportObserverPtr observer) {
content::UtilityThread::Get()->EnsureBlinkInitialized(); content::UtilityThread::Get()->EnsureBlinkInitialized();
importer_ = importer::CreateImporterByType(source_profile.importer_type); importer_ = importer::CreateImporterByType(source_profile.importer_type);
...@@ -50,7 +50,7 @@ void ProfileImportImpl::StartImport( ...@@ -50,7 +50,7 @@ void ProfileImportImpl::StartImport(
ImporterCleanup(); ImporterCleanup();
} }
bridge_ = new ExternalProcessImporterBridge( bridge_ = new ExternalProcessImporterBridge(
*localized_strings, std::move(localized_strings),
ThreadSafeProfileImportObserverPtr::Create(std::move(observer))); ThreadSafeProfileImportObserverPtr::Create(std::move(observer)));
import_thread_->task_runner()->PostTask( import_thread_->task_runner()->PostTask(
FROM_HERE, FROM_HERE,
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/values.h"
#include "chrome/common/importer/profile_import.mojom.h" #include "chrome/common/importer/profile_import.mojom.h"
#include "mojo/public/cpp/bindings/interface_request.h" #include "mojo/public/cpp/bindings/interface_request.h"
#include "services/service_manager/public/cpp/service_context_ref.h" #include "services/service_manager/public/cpp/service_context_ref.h"
...@@ -19,7 +20,6 @@ class ExternalProcessImporterBridge; ...@@ -19,7 +20,6 @@ class ExternalProcessImporterBridge;
class Importer; class Importer;
namespace base { namespace base {
class DictionaryValue;
class Thread; class Thread;
} // namespace base } // namespace base
...@@ -37,7 +37,7 @@ class ProfileImportImpl : public chrome::mojom::ProfileImport { ...@@ -37,7 +37,7 @@ class ProfileImportImpl : public chrome::mojom::ProfileImport {
// chrome::mojom::ProfileImport: // chrome::mojom::ProfileImport:
void StartImport(const importer::SourceProfile& source_profile, void StartImport(const importer::SourceProfile& source_profile,
uint16_t items, uint16_t items,
std::unique_ptr<base::DictionaryValue> localized_strings, base::Value localized_strings,
chrome::mojom::ProfileImportObserverPtr observer) override; chrome::mojom::ProfileImportObserverPtr observer) override;
void CancelImport() override; void CancelImport() override;
void ReportImportItemFinished(importer::ImportItem item) 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