diff options
author | Kristian Monsen <kristianm@google.com> | 2011-06-09 11:47:42 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2011-06-29 14:33:03 +0100 |
commit | dc0f95d653279beabeb9817299e2902918ba123e (patch) | |
tree | 32eb121cd532053a5b9cb0c390331349af8d6baa /chrome/browser/importer | |
parent | ba160cd4054d13d0cb0b1b46e61c3bed67095811 (diff) | |
download | external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.zip external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.tar.gz external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.tar.bz2 |
Merge Chromium at r11.0.696.0: Initial merge by git
Change-Id: I273dde2843af0839dfc08b419bb443fbd449532d
Diffstat (limited to 'chrome/browser/importer')
21 files changed, 184 insertions, 185 deletions
diff --git a/chrome/browser/importer/firefox2_importer.cc b/chrome/browser/importer/firefox2_importer.cc index bf68af0..d0208f2 100644 --- a/chrome/browser/importer/firefox2_importer.cc +++ b/chrome/browser/importer/firefox2_importer.cc @@ -13,9 +13,9 @@ #include "base/message_loop.h" #include "base/path_service.h" #include "base/stl_util-inl.h" +#include "base/string_number_conversions.h" #include "base/string_split.h" #include "base/string_util.h" -#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/history/history_types.h" @@ -32,18 +32,6 @@ #include "net/base/data_url.h" #include "webkit/glue/password_form.h" -using base::Time; -using importer::BOOKMARKS_HTML; -using importer::FAVORITES; -using importer::HISTORY; -using importer::HOME_PAGE; -using importer::PASSWORDS; -using importer::ProfileInfo; -using importer::SEARCH_ENGINES; -using webkit_glue::PasswordForm; - -// Firefox2Importer. - Firefox2Importer::Firefox2Importer() : parsing_bookmarks_html_file_(false) { } @@ -120,7 +108,7 @@ void Firefox2Importer::LoadDefaultBookmarks(const FilePath& app_path, std::wstring title; GURL url, favicon; std::wstring shortcut; - Time add_date; + base::Time add_date; std::wstring post_data; if (ParseBookmarkFromLine(line, charset, &title, &url, &favicon, &shortcut, &add_date, @@ -166,7 +154,7 @@ void Firefox2Importer::ImportBookmarksFile( std::wstring last_folder = first_folder_name; bool last_folder_on_toolbar = false; bool last_folder_is_empty = true; - Time last_folder_add_date; + base::Time last_folder_add_date; std::vector<std::wstring> path; size_t toolbar_folder = 0; std::string charset; @@ -188,7 +176,7 @@ void Firefox2Importer::ImportBookmarksFile( // Get the bookmark entry. std::wstring title, shortcut; GURL url, favicon; - Time add_date; + base::Time add_date; std::wstring post_data; bool is_bookmark; // TODO(jcampan): http://b/issue?id=1196285 we do not support POST based @@ -205,7 +193,7 @@ void Firefox2Importer::ImportBookmarksFile( post_data.empty() && CanImportURL(GURL(url)) && default_urls.find(url) == default_urls.end()) { - if (toolbar_folder > path.size() && path.size() > 0) { + if (toolbar_folder > path.size() && !path.empty()) { NOTREACHED(); // error in parsing. break; } @@ -351,7 +339,7 @@ void Firefox2Importer::ImportPasswords() { std::string content; file_util::ReadFileToString(file, &content); - std::vector<PasswordForm> forms; + std::vector<webkit_glue::PasswordForm> forms; decryptor.ParseSignons(content, &forms); if (!cancelled()) { @@ -421,7 +409,7 @@ bool Firefox2Importer::ParseFolderNameFromLine(const std::string& line, const std::string& charset, std::wstring* folder_name, bool* is_toolbar_folder, - Time* add_date) { + base::Time* add_date) { const char kFolderOpen[] = "<DT><H3"; const char kFolderClose[] = "</H3>"; const char kToolbarFolderAttribute[] = "PERSONAL_TOOLBAR_FOLDER"; @@ -450,7 +438,7 @@ bool Firefox2Importer::ParseFolderNameFromLine(const std::string& line, base::StringToInt64(value, &time); // Upper bound it at 32 bits. if (0 < time && time < (1LL << 32)) - *add_date = Time::FromTimeT(time); + *add_date = base::Time::FromTimeT(time); } if (GetAttribute(attribute_list, kToolbarFolderAttribute, &value) && @@ -469,7 +457,7 @@ bool Firefox2Importer::ParseBookmarkFromLine(const std::string& line, GURL* url, GURL* favicon, std::wstring* shortcut, - Time* add_date, + base::Time* add_date, std::wstring* post_data) { const char kItemOpen[] = "<DT><A"; const char kItemClose[] = "</A>"; @@ -485,7 +473,7 @@ bool Firefox2Importer::ParseBookmarkFromLine(const std::string& line, *favicon = GURL(); shortcut->clear(); post_data->clear(); - *add_date = Time(); + *add_date = base::Time(); if (!StartsWithASCII(line, kItemOpen, true)) return false; @@ -539,7 +527,7 @@ bool Firefox2Importer::ParseBookmarkFromLine(const std::string& line, base::StringToInt64(value, &time); // Upper bound it at 32 bits. if (0 < time && time < (1LL << 32)) - *add_date = Time::FromTimeT(time); + *add_date = base::Time::FromTimeT(time); } // Post data. diff --git a/chrome/browser/importer/firefox2_importer.h b/chrome/browser/importer/firefox2_importer.h index 7fef5e6..2c6412c 100644 --- a/chrome/browser/importer/firefox2_importer.h +++ b/chrome/browser/importer/firefox2_importer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 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. @@ -8,6 +8,8 @@ #include <set> +#include "base/basictypes.h" +#include "base/compiler_specific.h" #include "base/file_path.h" #include "base/gtest_prod_util.h" #include "chrome/browser/importer/importer.h" @@ -20,10 +22,10 @@ class Firefox2Importer : public Importer { public: Firefox2Importer(); - // Importer methods. + // Importer: virtual void StartImport(const importer::ProfileInfo& profile_info, uint16 items, - ImporterBridge* bridge); + ImporterBridge* bridge) OVERRIDE; // Loads the default bookmarks in the Firefox installed at |firefox_app_path|, // and stores their locations in |urls|. diff --git a/chrome/browser/importer/firefox3_importer.cc b/chrome/browser/importer/firefox3_importer.cc index 38317be..75c426a 100644 --- a/chrome/browser/importer/firefox3_importer.cc +++ b/chrome/browser/importer/firefox3_importer.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 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. @@ -20,21 +20,11 @@ #include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/importer/nss_decryptor.h" #include "chrome/browser/search_engines/template_url.h" -#include "chrome/common/time_format.h" #include "chrome/common/sqlite_utils.h" +#include "chrome/common/time_format.h" #include "grit/generated_resources.h" #include "webkit/glue/password_form.h" -using base::Time; -using importer::BOOKMARKS_HTML; -using importer::FAVORITES; -using importer::HISTORY; -using importer::HOME_PAGE; -using importer::PASSWORDS; -using importer::ProfileInfo; -using importer::SEARCH_ENGINES; -using webkit_glue::PasswordForm; - // Original definition is in http://mxr.mozilla.org/firefox/source/toolkit/ // components/places/public/nsINavBookmarksService.idl enum BookmarkItemType { @@ -146,7 +136,7 @@ void Firefox3Importer::ImportHistory() { row.set_visit_count(s.column_int(2)); row.set_hidden(s.column_int(3) == 1); row.set_typed_count(s.column_int(4)); - row.set_last_visit(Time::FromTimeT(s.column_int64(5)/1000000)); + row.set_last_visit(base::Time::FromTimeT(s.column_int64(5)/1000000)); rows.push_back(row); } @@ -279,14 +269,16 @@ void Firefox3Importer::ImportBookmarks() { bookmarks.push_back(entry); - if (item->favicon) - favicon_map[item->favicon].insert(item->url); + if (item->type == TYPE_BOOKMARK) { + if (item->favicon) + favicon_map[item->favicon].insert(item->url); - // This bookmark has a keyword, we import it to our TemplateURL model. - TemplateURL* t_url = Firefox2Importer::CreateTemplateURL( - item->title, UTF8ToWide(item->keyword), item->url); - if (t_url) - template_urls.push_back(t_url); + // This bookmark has a keyword, we import it to our TemplateURL model. + TemplateURL* t_url = Firefox2Importer::CreateTemplateURL( + item->title, UTF8ToWide(item->keyword), item->url); + if (t_url) + template_urls.push_back(t_url); + } } STLDeleteContainerPointers(list.begin(), list.end()); @@ -320,7 +312,7 @@ void Firefox3Importer::ImportPasswords() { return; } - std::vector<PasswordForm> forms; + std::vector<webkit_glue::PasswordForm> forms; FilePath source_path = source_path_; FilePath file = source_path.AppendASCII("signons.sqlite"); if (file_util::PathExists(file)) { @@ -535,7 +527,7 @@ void Firefox3Importer::GetWholeBookmarkFolder(sqlite3* db, BookmarkList* list, item->title = s.column_wstring(2); item->type = static_cast<BookmarkItemType>(s.column_int(3)); item->keyword = s.column_string(4); - item->date_added = Time::FromTimeT(s.column_int64(5)/1000000); + item->date_added = base::Time::FromTimeT(s.column_int64(5)/1000000); item->favicon = s.column_int64(6); item->empty_folder = true; diff --git a/chrome/browser/importer/firefox3_importer.h b/chrome/browser/importer/firefox3_importer.h index 6530edc..c5e3d8b 100644 --- a/chrome/browser/importer/firefox3_importer.h +++ b/chrome/browser/importer/firefox3_importer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 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. @@ -12,6 +12,7 @@ #include <vector> #include "base/basictypes.h" +#include "base/compiler_specific.h" #include "base/file_path.h" #include "chrome/browser/importer/importer.h" #include "chrome/browser/importer/importer_data_types.h" @@ -26,10 +27,10 @@ class Firefox3Importer : public Importer { public: Firefox3Importer(); - // Importer methods. + // Importer: virtual void StartImport(const importer::ProfileInfo& profile_info, uint16 items, - ImporterBridge* bridge); + ImporterBridge* bridge) OVERRIDE; private: typedef std::map<int64, std::set<GURL> > FaviconMap; diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc index d10453c..d051967 100644 --- a/chrome/browser/importer/ie_importer.cc +++ b/chrome/browser/importer/ie_importer.cc @@ -71,7 +71,10 @@ const GUID IEImporter::kPStoreAutocompleteGUID = {0xe161255a, 0x37c3, 0x11d2, const GUID IEImporter::kUnittestGUID = { 0xa79029d6, 0x753e, 0x4e27, {0xb8, 0x7, 0x3d, 0x46, 0xab, 0x15, 0x45, 0xdf}}; -void IEImporter::StartImport(const ProfileInfo& profile_info, +IEImporter::IEImporter() { +} + +void IEImporter::StartImport(const importer::ProfileInfo& profile_info, uint16 items, ImporterBridge* bridge) { bridge_ = bridge; @@ -112,6 +115,9 @@ void IEImporter::StartImport(const ProfileInfo& profile_info, bridge_->NotifyEnded(); } +IEImporter::~IEImporter() { +} + void IEImporter::ImportFavorites() { std::wstring path; @@ -526,7 +532,7 @@ void IEImporter::ParseFavoritesFolder(const FavoritesInfo& info, // C:\Users\Foo\Favorites\Links\Bar\Baz.url -> "Links\Bar" FilePath::StringType relative_string = shortcut.DirName().value().substr(favorites_path_len); - if (relative_string.size() > 0 && FilePath::IsSeparator(relative_string[0])) + if (!relative_string.empty() && FilePath::IsSeparator(relative_string[0])) relative_string = relative_string.substr(1); FilePath relative_path(relative_string); @@ -541,7 +547,7 @@ void IEImporter::ParseFavoritesFolder(const FavoritesInfo& info, // Flatten the bookmarks in Link folder onto bookmark toolbar. Otherwise, // put it into "Other bookmarks". if (import_to_bookmark_bar() && - (entry.path.size() > 0 && entry.path[0] == info.links_folder)) { + (!entry.path.empty() && entry.path[0] == info.links_folder)) { entry.in_toolbar = true; entry.path.erase(entry.path.begin()); toolbar_bookmarks.push_back(entry); diff --git a/chrome/browser/importer/ie_importer.h b/chrome/browser/importer/ie_importer.h index 68b7c23..dc732c4 100644 --- a/chrome/browser/importer/ie_importer.h +++ b/chrome/browser/importer/ie_importer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 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. @@ -6,22 +6,27 @@ #define CHROME_BROWSER_IMPORTER_IE_IMPORTER_H_ #pragma once +#include <string> +#include <vector> + +#include "base/basictypes.h" +#include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "chrome/browser/importer/importer.h" class IEImporter : public Importer { public: - IEImporter() {} + IEImporter(); - // Importer methods. - virtual void StartImport(const ProfileInfo& browser_info, + // Importer: + virtual void StartImport(const importer::ProfileInfo& browser_info, uint16 items, - ImporterBridge* bridge); + ImporterBridge* bridge) OVERRIDE; private: FRIEND_TEST_ALL_PREFIXES(ImporterTest, IEImporter); - virtual ~IEImporter() {} + virtual ~IEImporter(); void ImportFavorites(); void ImportHistory(); diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc index 03c72cf..5a4b489 100644 --- a/chrome/browser/importer/importer.cc +++ b/chrome/browser/importer/importer.cc @@ -10,11 +10,8 @@ #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/browser_thread.h" -#include "chrome/browser/browsing_instance.h" #include "chrome/browser/importer/firefox_profile_lock.h" #include "chrome/browser/importer/importer_bridge.h" -#include "chrome/browser/renderer_host/site_instance.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_model.h" #include "chrome/browser/tabs/tab_strip_model.h" @@ -22,6 +19,9 @@ #include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/webdata/web_data_service.h" #include "chrome/common/notification_source.h" +#include "content/browser/browser_thread.h" +#include "content/browser/browsing_instance.h" +#include "content/browser/site_instance.h" #include "grit/generated_resources.h" #include "skia/ext/image_operations.h" #include "ui/base/l10n/l10n_util.h" diff --git a/chrome/browser/importer/importer.h b/chrome/browser/importer/importer.h index 179d68b..c807d95 100644 --- a/chrome/browser/importer/importer.h +++ b/chrome/browser/importer/importer.h @@ -9,11 +9,10 @@ #include <string> #include <vector> -#include "build/build_config.h" - #include "base/basictypes.h" #include "base/ref_counted.h" #include "base/scoped_ptr.h" +#include "build/build_config.h" #include "chrome/browser/bookmarks/bookmark_model_observer.h" #include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/importer/importer_list.h" @@ -23,31 +22,26 @@ #include "chrome/common/notification_registrar.h" #include "ui/gfx/native_widget_types.h" -using importer::ImportItem; -using importer::ProfileInfo; - class ExternalProcessImporterClient; +class FirefoxProfileLock; +class GURL; +class Importer; class ImporterBridge; class InProcessImporterBridge; -class GURL; class Profile; class Task; class TemplateURL; - struct IE7PasswordInfo; namespace history { -struct ImportedFavIconUsage; class URLRow; +struct ImportedFavIconUsage; } namespace webkit_glue { struct PasswordForm; } -class FirefoxProfileLock; -class Importer; - // This class hosts the importers. It enumerates profiles from other // browsers dynamically, and controls the process of importing. When // the import process is done, ImporterHost deletes itself. @@ -473,31 +467,4 @@ class Importer : public base::RefCountedThreadSafe<Importer> { DISALLOW_COPY_AND_ASSIGN(Importer); }; -// An interface an object that calls StartImportingWithUI can call to be -// notified about the state of the import operation. -class ImportObserver { - public: - virtual ~ImportObserver() {} - // The import operation was canceled by the user. - // TODO (4164): this is never invoked, either rip it out or invoke it. - virtual void ImportCanceled() = 0; - - // The import operation was completed successfully. - virtual void ImportComplete() = 0; -}; - - -// 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 -// if there's nothing to parent to. first_run is true if it's invoked in the -// first run UI. -void StartImportingWithUI(gfx::NativeWindow parent_window, - uint16 items, - ImporterHost* coordinator, - const importer::ProfileInfo& source_profile, - Profile* target_profile, - ImportObserver* observer, - bool first_run); - #endif // CHROME_BROWSER_IMPORTER_IMPORTER_H_ diff --git a/chrome/browser/importer/importer_bridge.cc b/chrome/browser/importer/importer_bridge.cc index 2fb48a7..e1ddf2a 100644 --- a/chrome/browser/importer/importer_bridge.cc +++ b/chrome/browser/importer/importer_bridge.cc @@ -9,15 +9,15 @@ #include "base/string16.h" #include "base/utf_string_conversions.h" #include "base/values.h" -#include "chrome/browser/browser_thread.h" #include "chrome/browser/history/history_types.h" #include "chrome/browser/importer/importer.h" #if defined(OS_WIN) #include "chrome/browser/password_manager/ie7_password.h" #endif -#include "chrome/common/child_thread.h" #include "chrome/browser/importer/importer_messages.h" #include "chrome/profile_import/profile_import_thread.h" +#include "content/browser/browser_thread.h" +#include "content/common/child_thread.h" #include "ui/base/l10n/l10n_util.h" #include "webkit/glue/password_form.h" diff --git a/chrome/browser/importer/importer_data_types.h b/chrome/browser/importer/importer_data_types.h index 51376c8..fa2b328 100644 --- a/chrome/browser/importer/importer_data_types.h +++ b/chrome/browser/importer/importer_data_types.h @@ -51,7 +51,7 @@ struct ProfileInfo { ~ProfileInfo(); std::wstring description; - importer::ProfileType browser_type; + ProfileType browser_type; FilePath source_path; FilePath app_path; uint16 services_supported; // Bitmask of ImportItem. @@ -60,4 +60,3 @@ struct ProfileInfo { } // namespace importer #endif // CHROME_BROWSER_IMPORTER_IMPORTER_DATA_TYPES_H_ - diff --git a/chrome/browser/importer/importer_list.cc b/chrome/browser/importer/importer_list.cc index a47e9b4..121ec5f 100644 --- a/chrome/browser/importer/importer_list.cc +++ b/chrome/browser/importer/importer_list.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 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. @@ -32,7 +32,7 @@ namespace { #if defined(OS_WIN) void DetectIEProfiles(std::vector<importer::ProfileInfo*>* profiles) { // IE always exists and doesn't have multiple profiles. - ProfileInfo* ie = new ProfileInfo(); + importer::ProfileInfo* ie = new importer::ProfileInfo(); ie->description = UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORT_FROM_IE)); ie->browser_type = importer::MS_IE; ie->source_path.clear(); diff --git a/chrome/browser/importer/importer_list.h b/chrome/browser/importer/importer_list.h index e82764b..cb4830d 100644 --- a/chrome/browser/importer/importer_list.h +++ b/chrome/browser/importer/importer_list.h @@ -13,8 +13,8 @@ #include "base/ref_counted.h" #include "base/scoped_vector.h" #include "build/build_config.h" -#include "chrome/browser/browser_thread.h" #include "chrome/browser/importer/importer_data_types.h" +#include "content/browser/browser_thread.h" class Importer; diff --git a/chrome/browser/importer/importer_messages.h b/chrome/browser/importer/importer_messages.h index ac63526..46d6c98 100644 --- a/chrome/browser/importer/importer_messages.h +++ b/chrome/browser/importer/importer_messages.h @@ -15,6 +15,7 @@ #include "chrome/browser/importer/profile_writer.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/common/common_param_traits.h" +#include "content/common/common_param_traits.h" #include "ipc/ipc_message_utils.h" namespace IPC { @@ -132,6 +133,7 @@ struct ParamTraits<ProfileWriter::BookmarkEntry> { typedef ProfileWriter::BookmarkEntry param_type; static void Write(Message* m, const param_type& p) { WriteParam(m, p.in_toolbar); + WriteParam(m, p.is_folder); WriteParam(m, p.url); WriteParam(m, p.path); WriteParam(m, p.title); @@ -140,6 +142,7 @@ struct ParamTraits<ProfileWriter::BookmarkEntry> { static bool Read(const Message* m, void** iter, param_type* p) { return (ReadParam(m, iter, &p->in_toolbar)) && + (ReadParam(m, iter, &p->is_folder)) && (ReadParam(m, iter, &p->url)) && (ReadParam(m, iter, &p->path)) && (ReadParam(m, iter, &p->title)) && @@ -149,6 +152,8 @@ struct ParamTraits<ProfileWriter::BookmarkEntry> { l->append("("); LogParam(p.in_toolbar, l); l->append(", "); + LogParam(p.is_folder, l); + l->append(", "); LogParam(p.url, l); l->append(", "); LogParam(p.path, l); diff --git a/chrome/browser/importer/importer_observer.h b/chrome/browser/importer/importer_observer.h new file mode 100644 index 0000000..74bc350 --- /dev/null +++ b/chrome/browser/importer/importer_observer.h @@ -0,0 +1,23 @@ +// 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. + +#ifndef CHROME_BROWSER_IMPORTER_IMPORTER_OBSERVER_H_ +#define CHROME_BROWSER_IMPORTER_IMPORTER_OBSERVER_H_ +#pragma once + +// An interface that notifies the consumers about the state of the import +// operation. +class ImporterObserver { + public: + virtual ~ImporterObserver() {} + + // The import operation was completed successfully. + virtual void ImportCompleted() = 0; + + // The import operation was canceled by the user. + // TODO(4164): this is never invoked, either rip it out or invoke it. + virtual void ImportCanceled() = 0; +}; + +#endif // CHROME_BROWSER_IMPORTER_IMPORTER_OBSERVER_H_ diff --git a/chrome/browser/importer/importer_progress_dialog.h b/chrome/browser/importer/importer_progress_dialog.h new file mode 100644 index 0000000..d11df70 --- /dev/null +++ b/chrome/browser/importer/importer_progress_dialog.h @@ -0,0 +1,34 @@ +// 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. + +#ifndef CHROME_BROWSER_IMPORTER_IMPORTER_PROGRESS_DIALOG_H_ +#define CHROME_BROWSER_IMPORTER_IMPORTER_PROGRESS_DIALOG_H_ +#pragma once + +#include "ui/gfx/native_widget_types.h" + +class ImporterHost; +class ImporterObserver; +class Profile; + +namespace importer { + +struct ProfileInfo; + +// Shows an UI for importing and begins importing the specified |items| from +// |source_profile| to |target_profile|. |importer_observer| is notified when +// the process is complete, it can be NULL. |parent_window| is the window to +// parent the UI to, it can be NULL if there's nothing to parent to. |first_run| +// is true if it's invoked in the first run UI. +void ShowImportProgressDialog(gfx::NativeWindow parent_window, + uint16 items, + ImporterHost* importer_host, + ImporterObserver* importer_observer, + const ProfileInfo& source_profile, + Profile* target_profile, + bool first_run); + +} // namespace importer + +#endif // CHROME_BROWSER_IMPORTER_IMPORTER_PROGRESS_DIALOG_H_ diff --git a/chrome/browser/importer/importer_unittest.cc b/chrome/browser/importer/importer_unittest.cc index cfca4de..8ce3a78 100644 --- a/chrome/browser/importer/importer_unittest.cc +++ b/chrome/browser/importer/importer_unittest.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "testing/gtest/include/gtest/gtest.h" - #include "build/build_config.h" #if defined(OS_WIN) @@ -25,13 +23,14 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "base/values.h" -#include "chrome/browser/browser_thread.h" #include "chrome/browser/history/history_types.h" #include "chrome/browser/importer/importer.h" #include "chrome/browser/importer/importer_bridge.h" #include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/common/chrome_paths.h" +#include "content/browser/browser_thread.h" +#include "testing/gtest/include/gtest/gtest.h" #include "webkit/glue/password_form.h" #if defined(OS_WIN) @@ -40,18 +39,6 @@ #include "chrome/browser/password_manager/ie7_password.h" #endif -using importer::FAVORITES; -using importer::FIREFOX2; -using importer::FIREFOX3; -using importer::HISTORY; -using importer::ImportItem; -#if defined(OS_WIN) -using importer::MS_IE; -#endif -using importer::PASSWORDS; -using importer::SEARCH_ENGINES; -using webkit_glue::PasswordForm; - // TODO(estade): some of these are disabled on mac. http://crbug.com/48007 #if defined(OS_MACOSX) #define MAYBE(x) DISABLED_##x @@ -110,15 +97,15 @@ class ImporterTest : public testing::Test { } MessageLoop* loop = MessageLoop::current(); - ProfileInfo profile_info; - profile_info.browser_type = FIREFOX3; + importer::ProfileInfo profile_info; + profile_info.browser_type = importer::FIREFOX3; profile_info.app_path = app_path_; profile_info.source_path = profile_path_; scoped_refptr<ImporterHost> host(new ImporterHost); host->SetObserver(observer); - int items = HISTORY | PASSWORDS | FAVORITES; + int items = importer::HISTORY | importer::PASSWORDS | importer::FAVORITES; if (import_search_plugins) - items = items | SEARCH_ENGINES; + items = items | importer::SEARCH_ENGINES; loop->PostTask(FROM_HERE, NewRunnableMethod(host.get(), &ImporterHost::StartImportSettings, profile_info, static_cast<Profile*>(NULL), items, make_scoped_refptr(writer), true)); @@ -246,7 +233,7 @@ class TestObserver : public ProfileWriter, return true; } - virtual void AddPasswordForm(const PasswordForm& form) { + virtual void AddPasswordForm(const webkit_glue::PasswordForm& form) { // Importer should obtain this password form only. EXPECT_EQ(GURL("http://localhost:8080/security/index.htm"), form.origin); EXPECT_EQ("http://localhost:8080/", form.signon_realm); @@ -420,13 +407,16 @@ TEST_F(ImporterTest, IEImporter) { TestObserver* observer = new TestObserver(); host->SetObserver(observer); - ProfileInfo profile_info; - profile_info.browser_type = MS_IE; + importer::ProfileInfo profile_info; + profile_info.browser_type = importer::MS_IE; profile_info.source_path = test_path_; loop->PostTask(FROM_HERE, NewRunnableMethod(host.get(), - &ImporterHost::StartImportSettings, profile_info, - static_cast<Profile*>(NULL), HISTORY | PASSWORDS | FAVORITES, observer, + &ImporterHost::StartImportSettings, + profile_info, + static_cast<Profile*>(NULL), + importer::HISTORY | importer::PASSWORDS | importer::FAVORITES, + observer, true)); loop->Run(); @@ -598,7 +588,7 @@ class FirefoxObserver : public ProfileWriter, return true; } - virtual void AddPasswordForm(const PasswordForm& form) { + virtual void AddPasswordForm(const webkit_glue::PasswordForm& form) { PasswordList p = kFirefox2Passwords[password_count_]; EXPECT_EQ(p.origin, form.origin.spec()); EXPECT_EQ(p.realm, form.signon_realm); @@ -699,8 +689,8 @@ TEST_F(ImporterTest, MAYBE(Firefox2Importer)) { scoped_refptr<ImporterHost> host(new ImporterHost); FirefoxObserver* observer = new FirefoxObserver(); host->SetObserver(observer); - ProfileInfo profile_info; - profile_info.browser_type = FIREFOX2; + importer::ProfileInfo profile_info; + profile_info.browser_type = importer::FIREFOX2; profile_info.app_path = app_path_; profile_info.source_path = profile_path_; @@ -709,7 +699,8 @@ TEST_F(ImporterTest, MAYBE(Firefox2Importer)) { &ImporterHost::StartImportSettings, profile_info, static_cast<Profile*>(NULL), - HISTORY | PASSWORDS | FAVORITES | SEARCH_ENGINES, + importer::HISTORY | importer::PASSWORDS | + importer::FAVORITES | importer::SEARCH_ENGINES, make_scoped_refptr(observer), true)); loop->Run(); @@ -801,7 +792,7 @@ class Firefox3Observer : public ProfileWriter, return true; } - virtual void AddPasswordForm(const PasswordForm& form) { + virtual void AddPasswordForm(const webkit_glue::PasswordForm& form) { PasswordList p = kFirefox3Passwords[password_count_]; EXPECT_EQ(p.origin, form.origin.spec()); EXPECT_EQ(p.realm, form.signon_realm); diff --git a/chrome/browser/importer/safari_importer.h b/chrome/browser/importer/safari_importer.h index 7e234f5..a5150ae 100644 --- a/chrome/browser/importer/safari_importer.h +++ b/chrome/browser/importer/safari_importer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 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. @@ -6,16 +6,17 @@ #define CHROME_BROWSER_IMPORTER_SAFARI_IMPORTER_H_ #pragma once -#include "chrome/browser/importer/importer.h" - #include <map> #include <set> #include <vector> +#include "base/basictypes.h" +#include "base/compiler_specific.h" #include "base/file_path.h" #include "base/gtest_prod_util.h" -#include "chrome/common/sqlite_utils.h" +#include "chrome/browser/importer/importer.h" #include "chrome/browser/importer/importer_data_types.h" +#include "chrome/common/sqlite_utils.h" #if __OBJC__ @class NSDictionary; @@ -32,10 +33,10 @@ class SafariImporter : public Importer { // We pass it in as a parameter for testing purposes. explicit SafariImporter(const FilePath& library_dir); - // Importer methods. + // Importer: virtual void StartImport(const importer::ProfileInfo& profile_info, uint16 items, - ImporterBridge* bridge); + ImporterBridge* bridge) OVERRIDE; // Does this user account have a Safari Profile and if so, what items diff --git a/chrome/browser/importer/safari_importer.mm b/chrome/browser/importer/safari_importer.mm index de40655..e1046c6 100644 --- a/chrome/browser/importer/safari_importer.mm +++ b/chrome/browser/importer/safari_importer.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2010 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. @@ -10,6 +10,7 @@ #include <vector> #include "base/file_util.h" +#include "base/mac/mac_util.h" #include "base/message_loop.h" #include "base/scoped_nsobject.h" #include "base/string16.h" @@ -25,12 +26,6 @@ #include "grit/generated_resources.h" #include "net/base/data_url.h" -using importer::FAVORITES; -using importer::HISTORY; -using importer::NONE; -using importer::PASSWORDS; -using importer::ProfileInfo; - namespace { // A function like this is used by other importers in order to filter out @@ -326,7 +321,7 @@ double SafariImporter::HistoryTimeToEpochTime(NSString* history_time) { // Add Difference between Unix epoch and CFAbsoluteTime epoch in seconds. // Unix epoch is 1970-01-01 00:00:00.0 UTC, // CF epoch is 2001-01-01 00:00:00.0 UTC. - return CFStringGetDoubleValue(reinterpret_cast<CFStringRef>(history_time)) + + return CFStringGetDoubleValue(base::mac::NSToCFCast(history_time)) + kCFAbsoluteTimeIntervalSince1970; } diff --git a/chrome/browser/importer/safari_importer_unittest.mm b/chrome/browser/importer/safari_importer_unittest.mm index 36f233a..8323517 100644 --- a/chrome/browser/importer/safari_importer_unittest.mm +++ b/chrome/browser/importer/safari_importer_unittest.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2010 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. @@ -12,19 +12,11 @@ #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/history/history_types.h" +#include "chrome/browser/importer/importer_bridge.h" #include "chrome/common/chrome_paths.h" #include "chrome/test/file_test_utils.h" -#include "chrome/browser/importer/importer_bridge.h" #include "testing/platform_test.h" -using importer::COOKIES; -using importer::FAVORITES; -using importer::HISTORY; -using importer::HOME_PAGE; -using importer::NONE; -using importer::PASSWORDS; -using importer::SEARCH_ENGINES; - // In order to test the Safari import functionality effectively, we store a // simulated Library directory containing dummy data files in the same // structure as ~/Library in the Chrome test data directory. @@ -156,13 +148,13 @@ TEST_F(SafariImporterTest, FavIconImport) { } TEST_F(SafariImporterTest, CanImport) { - uint16 items = NONE; + uint16 items = importer::NONE; EXPECT_TRUE(SafariImporter::CanImport(GetTestSafariLibraryPath(), &items)); - EXPECT_EQ(items, HISTORY | FAVORITES); - EXPECT_EQ(items & COOKIES, NONE); - EXPECT_EQ(items & PASSWORDS, NONE); - EXPECT_EQ(items & SEARCH_ENGINES, NONE); - EXPECT_EQ(items & HOME_PAGE, NONE); + EXPECT_EQ(items, importer::HISTORY | importer::FAVORITES); + EXPECT_EQ(items & importer::COOKIES, importer::NONE); + EXPECT_EQ(items & importer::PASSWORDS, importer::NONE); + EXPECT_EQ(items & importer::SEARCH_ENGINES, importer::NONE); + EXPECT_EQ(items & importer::HOME_PAGE, importer::NONE); // Check that we don't import anything from a bogus library directory. FilePath fake_library_dir; diff --git a/chrome/browser/importer/toolbar_importer.cc b/chrome/browser/importer/toolbar_importer.cc index adcea0c..09b7514 100644 --- a/chrome/browser/importer/toolbar_importer.cc +++ b/chrome/browser/importer/toolbar_importer.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 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. @@ -7,27 +7,23 @@ #include <limits> #include "base/rand_util.h" +#include "base/string_number_conversions.h" #include "base/string_split.h" #include "base/string_util.h" -#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "base/values.h" -#include "chrome/browser/browser_thread.h" #include "chrome/browser/first_run/first_run.h" #include "chrome/browser/importer/importer_bridge.h" #include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/libxml_utils.h" #include "chrome/common/net/url_request_context_getter.h" +#include "content/browser/browser_thread.h" #include "grit/generated_resources.h" #include "net/base/cookie_monster.h" #include "net/base/data_url.h" #include "net/url_request/url_request_context.h" -using importer::FAVORITES; -using importer::NONE; -using importer::ProfileInfo; - // // ToolbarImporterUtils // diff --git a/chrome/browser/importer/toolbar_importer.h b/chrome/browser/importer/toolbar_importer.h index e0b87e5..8e5e322 100644 --- a/chrome/browser/importer/toolbar_importer.h +++ b/chrome/browser/importer/toolbar_importer.h @@ -12,6 +12,8 @@ #include <string> #include <vector> +#include "base/basictypes.h" +#include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "base/string16.h" #include "chrome/browser/importer/importer.h" @@ -38,26 +40,26 @@ class Toolbar5Importer : public URLFetcher::Delegate, public Importer { public: Toolbar5Importer(); - // Importer view calls this method to begin the process. The items parameter - // should only either be NONE or FAVORITES, since as of right now these are - // the only items this importer supports. This method provides implementation - // of Importer::StartImport. + // Importer: + // ImportDialogView calls this method to begin the process. |items| should + // only either be NONE or FAVORITES, since as of right now these are the only + // items this importer supports. virtual void StartImport(const importer::ProfileInfo& profile_info, uint16 items, - ImporterBridge* bridge); + ImporterBridge* bridge) OVERRIDE; // Importer view call this method when the user clicks the cancel button - // in the ImporterView UI. We need to post a message to our loop + // in the ImportDialogView UI. We need to post a message to our loop // to cancel network retrieval. virtual void Cancel(); // URLFetcher::Delegate method called back from the URLFetcher object. virtual void OnURLFetchComplete(const URLFetcher* source, - const GURL& url, - const net::URLRequestStatus& status, - int response_code, - const ResponseCookies& cookies, - const std::string& data); + const GURL& url, + const net::URLRequestStatus& status, + int response_code, + const ResponseCookies& cookies, + const std::string& data); private: FRIEND_TEST_ALL_PREFIXES(Toolbar5ImporterTest, BookmarkParse); |