Rename desktop_cursor_loader_updater_aurax11.
[chromium-blink-merge.git] / chrome / browser / importer / profile_writer.h
blob2192a69a0f835e03069e34de81c5f22dc026a851
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_IMPORTER_PROFILE_WRITER_H_
6 #define CHROME_BROWSER_IMPORTER_PROFILE_WRITER_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_vector.h"
13 #include "base/strings/string16.h"
14 #include "base/time/time.h"
15 #include "build/build_config.h"
16 #include "chrome/browser/history/history_types.h"
17 #include "url/gurl.h"
19 struct ImportedBookmarkEntry;
20 struct ImportedFaviconUsage;
21 class Profile;
22 class TemplateURL;
24 namespace autofill {
25 struct PasswordForm;
28 #if defined(OS_WIN)
29 struct IE7PasswordInfo;
30 #endif
32 // ProfileWriter encapsulates profile for writing entries into it.
33 // This object must be invoked on UI thread.
34 class ProfileWriter : public base::RefCountedThreadSafe<ProfileWriter> {
35 public:
36 explicit ProfileWriter(Profile* profile);
38 // These functions return true if the corresponding model has been loaded.
39 // If the models haven't been loaded, the importer waits to run until they've
40 // completed.
41 virtual bool BookmarkModelIsLoaded() const;
42 virtual bool TemplateURLServiceIsLoaded() const;
44 // Helper methods for adding data to local stores.
45 virtual void AddPasswordForm(const autofill::PasswordForm& form);
47 #if defined(OS_WIN)
48 virtual void AddIE7PasswordInfo(const IE7PasswordInfo& info);
49 #endif
51 virtual void AddHistoryPage(const history::URLRows& page,
52 history::VisitSource visit_source);
54 virtual void AddHomepage(const GURL& homepage);
56 // Adds the |bookmarks| to the bookmark model.
58 // (a) If the bookmarks bar is empty:
59 // (i) If |bookmarks| includes at least one bookmark that was originally
60 // located in a toolbar, all such bookmarks are imported directly to
61 // the toolbar; any other bookmarks are imported to a subfolder in
62 // the toolbar.
63 // (i) If |bookmarks| includes no bookmarks that were originally located
64 // in a toolbar, all bookmarks are imported directly to the toolbar.
65 // (b) If the bookmarks bar is not empty, all bookmarks are imported to a
66 // subfolder in the toolbar.
68 // In either case, if a subfolder is created, the name will be the value of
69 // |top_level_folder_name|, unless a folder with this name already exists.
70 // If a folder with this name already exists, then the name is uniquified.
71 // For example, if |first_folder_name| is 'Imported from IE' and a folder with
72 // the name 'Imported from IE' already exists in the bookmarks toolbar, then
73 // we will instead create a subfolder named 'Imported from IE (1)'.
74 virtual void AddBookmarks(
75 const std::vector<ImportedBookmarkEntry>& bookmarks,
76 const string16& top_level_folder_name);
78 virtual void AddFavicons(
79 const std::vector<ImportedFaviconUsage>& favicons);
81 // Adds the TemplateURLs in |template_urls| to the local store. The local
82 // store becomes the owner of the TemplateURLs. Some TemplateURLs in
83 // |template_urls| may conflict (same keyword or same host name in the URL)
84 // with existing TemplateURLs in the local store, in which case the existing
85 // ones take precedence and the duplicates in |template_urls| are deleted.
86 // If |unique_on_host_and_path| is true, a TemplateURL is only added if there
87 // is not an existing TemplateURL that has a replaceable search url with the
88 // same host+path combination.
89 virtual void AddKeywords(ScopedVector<TemplateURL> template_urls,
90 bool unique_on_host_and_path);
92 protected:
93 friend class base::RefCountedThreadSafe<ProfileWriter>;
95 virtual ~ProfileWriter();
97 private:
98 Profile* const profile_;
100 DISALLOW_COPY_AND_ASSIGN(ProfileWriter);
103 #endif // CHROME_BROWSER_IMPORTER_PROFILE_WRITER_H_