| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_IMPORTER_PROFILE_WRITER_H_ | 5 #ifndef CHROME_BROWSER_IMPORTER_PROFILE_WRITER_H_ |
| 6 #define CHROME_BROWSER_IMPORTER_PROFILE_WRITER_H_ | 6 #define CHROME_BROWSER_IMPORTER_PROFILE_WRITER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/browser/history/history_types.h" | 16 #include "chrome/browser/history/history_types.h" |
| 17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 18 | 18 |
| 19 struct ImportedBookmarkEntry; |
| 20 struct ImportedFaviconUsage; |
| 19 class Profile; | 21 class Profile; |
| 20 class TemplateURL; | 22 class TemplateURL; |
| 21 | 23 |
| 22 namespace content { | 24 namespace content { |
| 23 struct PasswordForm; | 25 struct PasswordForm; |
| 24 } | 26 } |
| 25 | 27 |
| 26 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
| 27 struct IE7PasswordInfo; | 29 struct IE7PasswordInfo; |
| 28 #endif | 30 #endif |
| 29 | 31 |
| 30 // ProfileWriter encapsulates profile for writing entries into it. | 32 // ProfileWriter encapsulates profile for writing entries into it. |
| 31 // This object must be invoked on UI thread. | 33 // This object must be invoked on UI thread. |
| 32 class ProfileWriter : public base::RefCountedThreadSafe<ProfileWriter> { | 34 class ProfileWriter : public base::RefCountedThreadSafe<ProfileWriter> { |
| 33 public: | 35 public: |
| 34 struct BookmarkEntry { | |
| 35 BookmarkEntry(); | |
| 36 ~BookmarkEntry(); | |
| 37 bool operator==(const BookmarkEntry& other) const; | |
| 38 | |
| 39 bool in_toolbar; | |
| 40 bool is_folder; | |
| 41 GURL url; | |
| 42 std::vector<string16> path; | |
| 43 string16 title; | |
| 44 base::Time creation_time; | |
| 45 }; | |
| 46 | |
| 47 explicit ProfileWriter(Profile* profile); | 36 explicit ProfileWriter(Profile* profile); |
| 48 | 37 |
| 49 // These functions return true if the corresponding model has been loaded. | 38 // These functions return true if the corresponding model has been loaded. |
| 50 // If the models haven't been loaded, the importer waits to run until they've | 39 // If the models haven't been loaded, the importer waits to run until they've |
| 51 // completed. | 40 // completed. |
| 52 virtual bool BookmarkModelIsLoaded() const; | 41 virtual bool BookmarkModelIsLoaded() const; |
| 53 virtual bool TemplateURLServiceIsLoaded() const; | 42 virtual bool TemplateURLServiceIsLoaded() const; |
| 54 | 43 |
| 55 // Helper methods for adding data to local stores. | 44 // Helper methods for adding data to local stores. |
| 56 virtual void AddPasswordForm(const content::PasswordForm& form); | 45 virtual void AddPasswordForm(const content::PasswordForm& form); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 75 // in a toolbar, all bookmarks are imported directly to the toolbar. | 64 // in a toolbar, all bookmarks are imported directly to the toolbar. |
| 76 // (b) If the bookmarks bar is not empty, all bookmarks are imported to a | 65 // (b) If the bookmarks bar is not empty, all bookmarks are imported to a |
| 77 // subfolder in the toolbar. | 66 // subfolder in the toolbar. |
| 78 // | 67 // |
| 79 // In either case, if a subfolder is created, the name will be the value of | 68 // In either case, if a subfolder is created, the name will be the value of |
| 80 // |top_level_folder_name|, unless a folder with this name already exists. | 69 // |top_level_folder_name|, unless a folder with this name already exists. |
| 81 // If a folder with this name already exists, then the name is uniquified. | 70 // If a folder with this name already exists, then the name is uniquified. |
| 82 // For example, if |first_folder_name| is 'Imported from IE' and a folder with | 71 // For example, if |first_folder_name| is 'Imported from IE' and a folder with |
| 83 // the name 'Imported from IE' already exists in the bookmarks toolbar, then | 72 // the name 'Imported from IE' already exists in the bookmarks toolbar, then |
| 84 // we will instead create a subfolder named 'Imported from IE (1)'. | 73 // we will instead create a subfolder named 'Imported from IE (1)'. |
| 85 virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmarks, | 74 virtual void AddBookmarks( |
| 86 const string16& top_level_folder_name); | 75 const std::vector<ImportedBookmarkEntry>& bookmarks, |
| 76 const string16& top_level_folder_name); |
| 87 | 77 |
| 88 virtual void AddFavicons( | 78 virtual void AddFavicons( |
| 89 const std::vector<history::ImportedFaviconUsage>& favicons); | 79 const std::vector<ImportedFaviconUsage>& favicons); |
| 90 | 80 |
| 91 // Adds the TemplateURLs in |template_urls| to the local store. The local | 81 // Adds the TemplateURLs in |template_urls| to the local store. The local |
| 92 // store becomes the owner of the TemplateURLs. Some TemplateURLs in | 82 // store becomes the owner of the TemplateURLs. Some TemplateURLs in |
| 93 // |template_urls| may conflict (same keyword or same host name in the URL) | 83 // |template_urls| may conflict (same keyword or same host name in the URL) |
| 94 // with existing TemplateURLs in the local store, in which case the existing | 84 // with existing TemplateURLs in the local store, in which case the existing |
| 95 // ones take precedence and the duplicates in |template_urls| are deleted. | 85 // ones take precedence and the duplicates in |template_urls| are deleted. |
| 96 // If |unique_on_host_and_path| is true, a TemplateURL is only added if there | 86 // If |unique_on_host_and_path| is true, a TemplateURL is only added if there |
| 97 // is not an existing TemplateURL that has a replaceable search url with the | 87 // is not an existing TemplateURL that has a replaceable search url with the |
| 98 // same host+path combination. | 88 // same host+path combination. |
| 99 virtual void AddKeywords(ScopedVector<TemplateURL> template_urls, | 89 virtual void AddKeywords(ScopedVector<TemplateURL> template_urls, |
| 100 bool unique_on_host_and_path); | 90 bool unique_on_host_and_path); |
| 101 | 91 |
| 102 protected: | 92 protected: |
| 103 friend class base::RefCountedThreadSafe<ProfileWriter>; | 93 friend class base::RefCountedThreadSafe<ProfileWriter>; |
| 104 | 94 |
| 105 virtual ~ProfileWriter(); | 95 virtual ~ProfileWriter(); |
| 106 | 96 |
| 107 private: | 97 private: |
| 108 Profile* const profile_; | 98 Profile* const profile_; |
| 109 | 99 |
| 110 DISALLOW_COPY_AND_ASSIGN(ProfileWriter); | 100 DISALLOW_COPY_AND_ASSIGN(ProfileWriter); |
| 111 }; | 101 }; |
| 112 | 102 |
| 113 #endif // CHROME_BROWSER_IMPORTER_PROFILE_WRITER_H_ | 103 #endif // CHROME_BROWSER_IMPORTER_PROFILE_WRITER_H_ |
| OLD | NEW |