Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3493)

Unified Diff: chrome/common/importer/edge_importer_utils_win.cc

Issue 1465853002: Implement support for importing favorites from Edge on Windows 10. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing include files Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/importer/edge_importer_utils_win.cc
diff --git a/chrome/common/importer/edge_importer_utils_win.cc b/chrome/common/importer/edge_importer_utils_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c2abd64b2d7c5166c1fdbaaf782974cb4bcc5e53
--- /dev/null
+++ b/chrome/common/importer/edge_importer_utils_win.cc
@@ -0,0 +1,87 @@
+// Copyright 2015 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/importer/edge_importer_utils_win.h"
+
+#include <Shlobj.h>
+
+#include "base/files/file.h"
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
+#include "base/win/registry.h"
+#include "base/win/windows_version.h"
+#include "chrome/common/importer/importer_test_registry_overrider_win.h"
+
+namespace {
+
+const base::char16 kEdgeSettingsMainKey[] = L"MicrosoftEdge\\Main";
+
+const base::char16 kEdgePackageName[] =
+ L"microsoft.microsoftedge_8wekyb3d8bbwe";
+
+// We assume at the moment that the package name never changes for Edge.
+base::string16 GetEdgePackageName() {
+ return kEdgePackageName;
+}
+
+base::string16 GetEdgeRegistryKey(const base::string16& key_name) {
+ base::string16 registry_key =
+ L"Software\\Classes\\Local Settings\\"
+ L"Software\\Microsoft\\Windows\\CurrentVersion\\AppContainer\\"
+ L"Storage\\";
+ registry_key += GetEdgePackageName();
+ registry_key += L"\\";
+ registry_key += key_name;
+ return registry_key;
+}
+
+base::string16 GetPotentiallyOverridenEdgeKey(
+ const base::string16& desired_key_path) {
+ base::string16 test_registry_override(
+ ImporterTestRegistryOverrider::GetTestRegistryOverride());
+ return test_registry_override.empty() ? GetEdgeRegistryKey(desired_key_path)
+ : test_registry_override;
+}
+
+} // namespace
+
+namespace importer {
+
+base::string16 GetEdgeSettingsKey() {
+ return GetPotentiallyOverridenEdgeKey(kEdgeSettingsMainKey);
+}
+
+base::FilePath GetEdgeDataFilePath() {
+ wchar_t buffer[MAX_PATH];
+ if (::SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT,
+ buffer) != S_OK)
+ return base::FilePath();
+
+ base::FilePath base_path(buffer);
+ base::string16 rel_path = L"Packages\\";
+ rel_path += GetEdgePackageName();
+ rel_path += L"\\AC\\MicrosoftEdge\\User\\Default";
+ return base_path.Append(rel_path);
+}
+
+bool IsEdgeFavoritesLegacyMode() {
+ base::win::RegKey key(HKEY_CURRENT_USER, GetEdgeSettingsKey().c_str(),
+ KEY_READ);
+ DWORD ese_enabled = 0;
+ // Check whether Edge is using the new Extensible Store Engine (ESE) format
+ // for its favorites.
+ if (key.ReadValueDW(L"FavoritesESEEnabled", &ese_enabled) == ERROR_SUCCESS)
+ return !ese_enabled;
+ return true;
+}
+
+bool EdgeImporterCanImport() {
+ base::File::Info file_info;
+ if (base::win::GetVersion() < base::win::VERSION_WIN10)
+ return false;
+ return base::GetFileInfo(GetEdgeDataFilePath(), &file_info) &&
+ file_info.is_directory;
+}
+
+} // namespace importer

Powered by Google App Engine
This is Rietveld 408576698