diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser.vcproj | 4 | ||||
-rw-r--r-- | chrome/browser/importer/firefox2_importer.cc | 11 | ||||
-rw-r--r-- | chrome/browser/importer/firefox_importer_unittest.cc | 17 | ||||
-rw-r--r-- | chrome/browser/importer/firefox_importer_utils.h | 5 | ||||
-rw-r--r-- | chrome/browser/importer/firefox_profile_lock.cc | 34 | ||||
-rw-r--r-- | chrome/browser/importer/firefox_profile_lock.h | 18 | ||||
-rw-r--r-- | chrome/browser/importer/firefox_profile_lock_posix.cc | 79 | ||||
-rw-r--r-- | chrome/browser/importer/firefox_profile_lock_win.cc | 77 | ||||
-rw-r--r-- | chrome/browser/importer/ie_importer.cc | 2 | ||||
-rw-r--r-- | chrome/browser/importer/importer.cc | 1 | ||||
-rw-r--r-- | chrome/browser/importer/importer.h | 11 | ||||
-rw-r--r-- | chrome/browser/importer/importer_unittest.cc | 1 | ||||
-rw-r--r-- | chrome/browser/importer/mork_reader.cc | 4 |
13 files changed, 47 insertions, 217 deletions
diff --git a/chrome/browser/browser.vcproj b/chrome/browser/browser.vcproj index 00ba48d..7d79e5d 100644 --- a/chrome/browser/browser.vcproj +++ b/chrome/browser/browser.vcproj @@ -1562,10 +1562,6 @@ > </File> <File - RelativePath=".\importer\firefox_profile_lock_win.cc" - > - </File> - <File RelativePath=".\importer\ie_importer.cc" > </File> diff --git a/chrome/browser/importer/firefox2_importer.cc b/chrome/browser/importer/firefox2_importer.cc index 9aee0ca..aef2ba2 100644 --- a/chrome/browser/importer/firefox2_importer.cc +++ b/chrome/browser/importer/firefox2_importer.cc @@ -4,9 +4,9 @@ #include "chrome/browser/importer/firefox2_importer.h" -#include "base/file_path.h" #include "base/file_util.h" #include "base/path_service.h" +#include "base/registry.h" #include "base/string_util.h" #include "base/values.h" #include "chrome/browser/importer/firefox_importer_utils.h" @@ -69,19 +69,16 @@ void Firefox2Importer::StartImport(ProfileInfo profile_info, // static void Firefox2Importer::LoadDefaultBookmarks(const std::wstring& app_path, std::set<GURL> *urls) { - // TODO(port): Code below is correct only on Windows. // Firefox keeps its default bookmarks in a bookmarks.html file that // lives at: <Firefox install dir>\defaults\profile\bookmarks.html - FilePath file = FilePath::FromWStringHack(app_path); - file.Append(FILE_PATH_LITERAL("defaults")); - file.Append(FILE_PATH_LITERAL("profile")); - file.Append(FILE_PATH_LITERAL("bookmarks.html")); + std::wstring file = app_path; + file_util::AppendToPath(&file, L"defaults\\profile\\bookmarks.html"); urls->clear(); // Read the whole file. std::string content; - file_util::ReadFileToString(file.ToWStringHack(), &content); + file_util::ReadFileToString(file, &content); std::vector<std::string> lines; SplitString(content, '\n', &lines); diff --git a/chrome/browser/importer/firefox_importer_unittest.cc b/chrome/browser/importer/firefox_importer_unittest.cc index 2ff34b3..742a806 100644 --- a/chrome/browser/importer/firefox_importer_unittest.cc +++ b/chrome/browser/importer/firefox_importer_unittest.cc @@ -4,7 +4,6 @@ #include "testing/gtest/include/gtest/gtest.h" -#include "base/file_path.h" #include "base/file_util.h" #include "base/path_service.h" #include "chrome/browser/importer/firefox2_importer.h" @@ -147,8 +146,8 @@ TEST(FirefoxImporterTest, Firefox2BookmarkParse) { TEST(FirefoxImporterTest, ProfileLock) { std::wstring test_path; file_util::CreateNewTempDirectory(L"firefox_profile", &test_path); - FilePath lock_file_path = FilePath::FromWStringHack(test_path); - lock_file_path.Append(FirefoxProfileLock::kLockFileName); + std::wstring lock_file_path = test_path; + file_util::AppendToPath(&lock_file_path, FirefoxProfileLock::kLockFileName); scoped_ptr<FirefoxProfileLock> lock; EXPECT_EQ(static_cast<FirefoxProfileLock*>(NULL), lock.get()); @@ -174,13 +173,15 @@ TEST(FirefoxImporterTest, ProfileLock) { TEST(FirefoxImporterTest, ProfileLockOrphaned) { std::wstring test_path; file_util::CreateNewTempDirectory(L"firefox_profile", &test_path); - FilePath lock_file_path = FilePath::FromWStringHack(test_path); - lock_file_path.Append(FirefoxProfileLock::kLockFileName); + std::wstring lock_file_path = test_path; + file_util::AppendToPath(&lock_file_path, FirefoxProfileLock::kLockFileName); // Create the orphaned lock file. - FILE* lock_file = file_util::OpenFile(lock_file_path, "w"); - ASSERT_TRUE(lock_file); - file_util::CloseFile(lock_file); + HANDLE lock_file = CreateFile(lock_file_path.c_str(), + GENERIC_READ | GENERIC_WRITE, + 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, + NULL); + CloseHandle(lock_file); EXPECT_TRUE(file_util::PathExists(lock_file_path)); scoped_ptr<FirefoxProfileLock> lock; diff --git a/chrome/browser/importer/firefox_importer_utils.h b/chrome/browser/importer/firefox_importer_utils.h index 4bf287c..165ce2d 100644 --- a/chrome/browser/importer/firefox_importer_utils.h +++ b/chrome/browser/importer/firefox_importer_utils.h @@ -6,7 +6,6 @@ #define CHROME_BROWSER_IMPORTER_FIREFOX_IMPORTER_UTILS_H_ #include "base/values.h" -#include "build/build_config.h" #include "webkit/glue/password_form.h" class GURL; @@ -199,16 +198,14 @@ class NSSDecryptor { static const wchar_t kPLDS4Library[]; static const wchar_t kNSPR4Library[]; -#if defined(OS_WIN) // NSS3 module handles. HMODULE nss3_dll_; HMODULE softokn3_dll_; -#endif // True if NSS_Init() has been called bool is_nss_initialized_; - DISALLOW_COPY_AND_ASSIGN(NSSDecryptor); + DISALLOW_EVIL_CONSTRUCTORS(NSSDecryptor); }; #endif // CHROME_BROWSER_IMPORTER_FIREFOX_IMPORTER_UTILS_H_ diff --git a/chrome/browser/importer/firefox_profile_lock.cc b/chrome/browser/importer/firefox_profile_lock.cc index 777723c..aaab891 100644 --- a/chrome/browser/importer/firefox_profile_lock.cc +++ b/chrome/browser/importer/firefox_profile_lock.cc @@ -4,7 +4,7 @@ #include "chrome/browser/importer/firefox_profile_lock.h" -#include "base/file_path.h" +#include "base/file_util.h" // This class is based on Firefox code in: // profile/dirserviceprovider/src/nsProfileLock.cpp @@ -52,16 +52,36 @@ * ***** END LICENSE BLOCK ***** */ // static -const FilePath::CharType* FirefoxProfileLock::kLockFileName = - FILE_PATH_LITERAL("parent.local"); +wchar_t FirefoxProfileLock::kLockFileName[] = L"parent.lock"; -FirefoxProfileLock::FirefoxProfileLock(const std::wstring& path) { - Init(); - lock_file_ = FilePath::FromWStringHack(path); - lock_file_.Append(kLockFileName); +FirefoxProfileLock::FirefoxProfileLock(const std::wstring& path) + : lock_handle_(INVALID_HANDLE_VALUE) { + lock_file_ = path; + file_util::AppendToPath(&lock_file_, kLockFileName); Lock(); } FirefoxProfileLock::~FirefoxProfileLock() { Unlock(); } + +void FirefoxProfileLock::Lock() { + if (HasAcquired()) + return; + lock_handle_ = CreateFile(lock_file_.c_str(), GENERIC_READ | GENERIC_WRITE, + 0, NULL, OPEN_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, + NULL); +} + +void FirefoxProfileLock::Unlock() { + if (!HasAcquired()) + return; + CloseHandle(lock_handle_); + lock_handle_ = INVALID_HANDLE_VALUE; +} + +bool FirefoxProfileLock::HasAcquired() { + return (lock_handle_ != INVALID_HANDLE_VALUE); +} + + diff --git a/chrome/browser/importer/firefox_profile_lock.h b/chrome/browser/importer/firefox_profile_lock.h index 8b402cf..c32d592 100644 --- a/chrome/browser/importer/firefox_profile_lock.h +++ b/chrome/browser/importer/firefox_profile_lock.h @@ -5,16 +5,11 @@ #ifndef CHROME_BROWSER_IMPORTER_FIREFOX_PROFILE_LOCK_H__ #define CHROME_BROWSER_IMPORTER_FIREFOX_PROFILE_LOCK_H__ -#include "build/build_config.h" - -#if defined(OS_WIN) #include <windows.h> -#endif #include <string> #include "base/basictypes.h" -#include "base/file_path.h" #include "testing/gtest/include/gtest/gtest_prod.h" // Firefox is designed to allow only one application to access its @@ -83,21 +78,16 @@ class FirefoxProfileLock { FRIEND_TEST(FirefoxImporterTest, ProfileLock); FRIEND_TEST(FirefoxImporterTest, ProfileLockOrphaned); - static const FilePath::CharType* kLockFileName; - - void Init(); + // The name of the lock file. + static wchar_t kLockFileName[]; // Full path of the lock file in the profile folder. - FilePath lock_file_; + std::wstring lock_file_; // The handle of the lock file. -#if defined(OS_WIN) HANDLE lock_handle_; -#elif defined(OS_POSIX) - int lock_fd_; -#endif - DISALLOW_COPY_AND_ASSIGN(FirefoxProfileLock); + DISALLOW_EVIL_CONSTRUCTORS(FirefoxProfileLock); }; #endif // CHROME_BROWSER_IMPORTER_FIREFOX_PROFILE_LOCK_H__ diff --git a/chrome/browser/importer/firefox_profile_lock_posix.cc b/chrome/browser/importer/firefox_profile_lock_posix.cc deleted file mode 100644 index 0058bb2..0000000 --- a/chrome/browser/importer/firefox_profile_lock_posix.cc +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) 2008 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/browser/importer/firefox_profile_lock.h" - -#include <fcntl.h> -#include <sys/stat.h> -#include <sys/types.h> - -#include "base/file_util.h" - -// This class is based on Firefox code in: -// profile/dirserviceprovider/src/nsProfileLock.cpp -// The license block is: - -/* ***** BEGIN LICENSE BLOCK ***** -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License Version -* 1.1 (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -* for the specific language governing rights and limitations under the -* License. -* -* The Original Code is mozilla.org code. -* -* The Initial Developer of the Original Code is -* Netscape Communications Corporation. -* Portions created by the Initial Developer are Copyright (C) 2002 -* the Initial Developer. All Rights Reserved. -* -* Contributor(s): -* Conrad Carlen <ccarlen@netscape.com> -* Brendan Eich <brendan@mozilla.org> -* Colin Blake <colin@theblakes.com> -* Javier Pedemonte <pedemont@us.ibm.com> -* Mats Palmgren <mats.palmgren@bredband.net> -* -* Alternatively, the contents of this file may be used under the terms of -* either the GNU General Public License Version 2 or later (the "GPL"), or -* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -* in which case the provisions of the GPL or the LGPL are applicable instead -* of those above. If you wish to allow use of your version of this file only -* under the terms of either the GPL or the LGPL, and not to allow others to -* use your version of this file under the terms of the MPL, indicate your -* decision by deleting the provisions above and replace them with the notice -* and other provisions required by the GPL or the LGPL. If you do not delete -* the provisions above, a recipient may use your version of this file under -* the terms of any one of the MPL, the GPL or the LGPL. -* -* ***** END LICENSE BLOCK ***** */ - -void FirefoxProfileLock::Init() { - lock_fd_ = -1; -} - -void FirefoxProfileLock::Lock() { - if (HasAcquired()) - return; - lock_fd_ = open(lock_file_.value().c_str(), O_CREAT | O_EXCL); -} - -void FirefoxProfileLock::Unlock() { - if (!HasAcquired()) - return; - close(lock_fd_); - lock_fd_ = -1; -} - -bool FirefoxProfileLock::HasAcquired() { - return (lock_fd_ >= 0); -} - - diff --git a/chrome/browser/importer/firefox_profile_lock_win.cc b/chrome/browser/importer/firefox_profile_lock_win.cc deleted file mode 100644 index a9063c6..0000000 --- a/chrome/browser/importer/firefox_profile_lock_win.cc +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2008 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/browser/importer/firefox_profile_lock.h" - -#include <windows.h> - -// This class is based on Firefox code in: -// profile/dirserviceprovider/src/nsProfileLock.cpp -// The license block is: - -/* ***** BEGIN LICENSE BLOCK ***** -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License Version -* 1.1 (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -* for the specific language governing rights and limitations under the -* License. -* -* The Original Code is mozilla.org code. -* -* The Initial Developer of the Original Code is -* Netscape Communications Corporation. -* Portions created by the Initial Developer are Copyright (C) 2002 -* the Initial Developer. All Rights Reserved. -* -* Contributor(s): -* Conrad Carlen <ccarlen@netscape.com> -* Brendan Eich <brendan@mozilla.org> -* Colin Blake <colin@theblakes.com> -* Javier Pedemonte <pedemont@us.ibm.com> -* Mats Palmgren <mats.palmgren@bredband.net> -* -* Alternatively, the contents of this file may be used under the terms of -* either the GNU General Public License Version 2 or later (the "GPL"), or -* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -* in which case the provisions of the GPL or the LGPL are applicable instead -* of those above. If you wish to allow use of your version of this file only -* under the terms of either the GPL or the LGPL, and not to allow others to -* use your version of this file under the terms of the MPL, indicate your -* decision by deleting the provisions above and replace them with the notice -* and other provisions required by the GPL or the LGPL. If you do not delete -* the provisions above, a recipient may use your version of this file under -* the terms of any one of the MPL, the GPL or the LGPL. -* -* ***** END LICENSE BLOCK ***** */ - -void FirefoxProfileLock::Init() { - lock_handle_ = INVALID_HANDLE_VALUE; -} - -void FirefoxProfileLock::Lock() { - if (HasAcquired()) - return; - lock_handle_ = CreateFile(lock_file_.value().c_str(), - GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, - FILE_FLAG_DELETE_ON_CLOSE, NULL); -} - -void FirefoxProfileLock::Unlock() { - if (!HasAcquired()) - return; - CloseHandle(lock_handle_); - lock_handle_ = INVALID_HANDLE_VALUE; -} - -bool FirefoxProfileLock::HasAcquired() { - return (lock_handle_ != INVALID_HANDLE_VALUE); -} - - diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc index 5c247eb..2e5d919 100644 --- a/chrome/browser/importer/ie_importer.cc +++ b/chrome/browser/importer/ie_importer.cc @@ -4,12 +4,10 @@ #include "chrome/browser/importer/ie_importer.h" -#include <atlbase.h> #include <intshcut.h> #include <pstore.h> #include <shlobj.h> #include <urlhist.h> - #include <algorithm> #include "base/file_util.h" diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc index 0ca7b82..3ce8996 100644 --- a/chrome/browser/importer/importer.cc +++ b/chrome/browser/importer/importer.cc @@ -24,7 +24,6 @@ #include "chrome/browser/importer/toolbar_importer.h" #include "chrome/browser/template_url_model.h" #include "chrome/browser/shell_integration.h" -#include "chrome/browser/views/importer_lock_view.h" #include "chrome/browser/webdata/web_data_service.h" #include "chrome/common/gfx/favicon_size.h" #include "chrome/common/l10n_util.h" diff --git a/chrome/browser/importer/importer.h b/chrome/browser/importer/importer.h index f7190e9..4e57b64 100644 --- a/chrome/browser/importer/importer.h +++ b/chrome/browser/importer/importer.h @@ -8,18 +8,15 @@ #include <set> #include <vector> -#include "build/build_config.h" - #include "base/basictypes.h" #include "base/message_loop.h" #include "base/ref_counted.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/history/history_types.h" -#if defined(OS_WIN) #include "chrome/browser/ie7_password.h" -#endif #include "chrome/browser/profile.h" #include "chrome/browser/template_url.h" +#include "chrome/browser/views/importer_lock_view.h" #include "chrome/common/notification_service.h" #include "googleurl/src/gurl.h" #include "webkit/glue/password_form.h" @@ -100,9 +97,7 @@ class ProfileWriter : public base::RefCounted<ProfileWriter> { // Helper methods for adding data to local stores. virtual void AddPasswordForm(const PasswordForm& form); -#if defined(OS_WIN) virtual void AddIE7PasswordInfo(const IE7PasswordInfo& info); -#endif virtual void AddHistoryPage(const std::vector<history::URLRow>& page); virtual void AddHomepage(const GURL& homepage); // Adds the bookmarks to the BookmarkModel. @@ -412,9 +407,6 @@ class ImportObserver { }; -#if defined(OS_WIN) -// TODO(port): Make StartImportingWithUI portable. - // Shows a UI for importing and begins importing the specified items from // source_profile to target_profile. observer is notified when the process is // complete, can be NULL. parent is the window to parent the UI to, can be NULL @@ -427,6 +419,5 @@ void StartImportingWithUI(HWND parent_window, Profile* target_profile, ImportObserver* observer, bool first_run); -#endif #endif // CHROME_BROWSER_IMPORTER_IMPORTER_H_ diff --git a/chrome/browser/importer/importer_unittest.cc b/chrome/browser/importer/importer_unittest.cc index abd93c5..2f9d8e1 100644 --- a/chrome/browser/importer/importer_unittest.cc +++ b/chrome/browser/importer/importer_unittest.cc @@ -4,7 +4,6 @@ #include "testing/gtest/include/gtest/gtest.h" -#include <atlbase.h> #include <windows.h> #include <unknwn.h> #include <intshcut.h> diff --git a/chrome/browser/importer/mork_reader.cc b/chrome/browser/importer/mork_reader.cc index 7f5e5c6..4a9c1b2 100644 --- a/chrome/browser/importer/mork_reader.cc +++ b/chrome/browser/importer/mork_reader.cc @@ -44,7 +44,6 @@ #include <algorithm> -#include "base/file_path.h" #include "base/logging.h" #include "base/string_util.h" #include "chrome/browser/history/history_types.h" @@ -112,8 +111,7 @@ MorkReader::~MorkReader() { } bool MorkReader::Read(const std::wstring& filename) { - FilePath path = FilePath::FromWStringHack(filename); - stream_.open(path.value().c_str()); + stream_.open(filename.c_str()); if (!stream_.is_open()) return false; |