Index: chrome/browser/importer/importer.h |
=================================================================== |
--- chrome/browser/importer/importer.h (revision 4885) |
+++ chrome/browser/importer/importer.h (working copy) |
@@ -27,7 +27,9 @@ |
MS_IE = 0, |
FIREFOX2, |
FIREFOX3, |
- GOOGLE_TOOLBAR5 |
+ GOOGLE_TOOLBAR5, |
+ // Identifies a 'bookmarks.html' file. |
+ BOOKMARKS_HTML |
}; |
// An enumeration of the type of data we want to import. |
@@ -57,6 +59,18 @@ |
// This object must be invoked on UI thread. |
class ProfileWriter : public base::RefCounted<ProfileWriter> { |
public: |
+ // Used to identify how the bookmarks are added. |
+ enum BookmarkOptions { |
+ // Indicates the bookmark should only be added if unique. Uniqueness |
+ // is done by title, url and path. That is, if this is passed to |
+ // AddBookmarkEntry the bookmark is added only if there is no other |
+ // URL with the same url, path and title. |
+ ADD_IF_UNIQUE = 1 << 0, |
+ |
+ // Indicates the bookmarks are being added during first run. |
+ FIRST_RUN = 1 << 1 |
+ }; |
+ |
explicit ProfileWriter(Profile* profile) : profile_(profile) { } |
virtual ~ProfileWriter() { } |
@@ -86,9 +100,21 @@ |
virtual void AddIE7PasswordInfo(const IE7PasswordInfo& info); |
virtual void AddHistoryPage(const std::vector<history::URLRow>& page); |
virtual void AddHomepage(const GURL& homepage); |
- virtual void AddBookmarkEntry( |
- const std::vector<BookmarkEntry>& bookmark, |
- bool check_uniqueness); |
+ // Adds the bookmarks to the BookmarkModel. |
+ // |options| is a bitmask of BookmarkOptions and dictates how and |
+ // which bookmarks are added. If the bitmask contains FIRST_RUN, |
+ // then any entries with a value of true for in_toolbar are added to |
+ // the bookmark bar. If the bitmask does not contain FIRST_RUN then |
+ // the folder name the bookmarks are added to is uniqued based on |
+ // |first_folder_name|. For example, if |first_folder_name| is 'foo' |
+ // and a folder with the name 'foo' already exists in the other |
+ // bookmarks folder, then the folder name 'foo 2' is used. |
+ // If |options| contains ADD_IF_UNIQUE, then the bookmark is added only |
+ // if another bookmarks does not exist with the same title, path and |
+ // url. |
+ virtual void AddBookmarkEntry(const std::vector<BookmarkEntry>& bookmark, |
+ const std::wstring& first_folder_name, |
+ int options); |
virtual void AddFavicons( |
const std::vector<history::ImportedFavIconUsage>& favicons); |
// Add the TemplateURLs in |template_urls| to the local store and make the |
@@ -111,6 +137,19 @@ |
Profile* GetProfile() const { return profile_; } |
private: |
+ // Generates a unique folder name. If folder_name is not unique, then this |
+ // repeatedly tests for '|folder_name| + (i)' until a unique name is found. |
+ std::wstring GenerateUniqueFolderName(BookmarkModel* model, |
+ const std::wstring& folder_name); |
+ |
+ // Returns true if a bookmark exists with the same url, title and path |
+ // as |entry|. |first_folder_name| is the name to use for the first |
+ // path entry if |first_run| is true. |
+ bool DoesBookmarkExist(BookmarkModel* model, |
+ const BookmarkEntry& entry, |
+ const std::wstring& first_folder_name, |
+ bool first_run); |
+ |
Profile* profile_; |
DISALLOW_EVIL_CONSTRUCTORS(ProfileWriter); |
@@ -290,12 +329,15 @@ |
void set_first_run(bool first_run) { first_run_ = first_run; } |
+ bool cancelled() const { return cancelled_; } |
+ |
protected: |
Importer() |
: main_loop_(MessageLoop::current()), |
delagate_loop_(NULL), |
importer_host_(NULL), |
- cancelled_(false) {} |
+ cancelled_(false), |
+ first_run_(false) {} |
// Notifies the coordinator that the collection of data for the specified |
// item has begun. |
@@ -329,8 +371,6 @@ |
static bool ReencodeFavicon(const unsigned char* src_data, size_t src_len, |
std::vector<unsigned char>* png_data); |
- bool cancelled() const { return cancelled_; } |
- |
bool first_run() const { return first_run_; } |
// The importer should know the main thread so that ProfileWriter |
@@ -359,6 +399,7 @@ |
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. |
@@ -380,4 +421,3 @@ |
bool first_run); |
#endif // CHROME_BROWSER_IMPORTER_IMPORTER_H_ |
- |