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_IMPORTER_LIST_H_
6 #define CHROME_BROWSER_IMPORTER_IMPORTER_LIST_H_
11 #include "base/basictypes.h"
12 #include "base/callback_forward.h"
13 #include "base/memory/scoped_vector.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/strings/string16.h"
21 // ImporterList detects installed browsers and profiles via
22 // DetectSourceProfilesWorker(). ImporterList lives on the UI thread.
28 // Detects the installed browsers and their associated profiles, then stores
29 // their information in a list to be accessed via count() and
30 // GetSourceProfileAt(). The detection runs asynchronously.
32 // |locale|: As in DetectSourceProfilesWorker().
33 // |include_interactive_profiles|: True to include source profiles that
34 // require user interaction to read.
35 // |profiles_loaded_callback|: Assuming this ImporterList instance is still
36 // alive, run the callback when the source profile detection finishes.
37 void DetectSourceProfiles(const std::string
& locale
,
38 bool include_interactive_profiles
,
39 const base::Closure
& profiles_loaded_callback
);
41 // Returns the number of different source profiles you can import from.
42 size_t count() const { return source_profiles_
.size(); }
44 // Returns the SourceProfile at |index|. The profiles are ordered such that
45 // the profile at index 0 is the likely default browser. The SourceProfile
46 // should be passed to ImporterHost::StartImportSettings().
47 const importer::SourceProfile
& GetSourceProfileAt(size_t index
) const;
50 // Called when the source profiles are loaded. Takes ownership of the
51 // loaded profiles in |profiles| and calls |profiles_loaded_callback|.
52 void SourceProfilesLoaded(
53 const base::Closure
& profiles_loaded_callback
,
54 const std::vector
<importer::SourceProfile
*>& profiles
);
56 // The list of profiles with the default one first.
57 ScopedVector
<importer::SourceProfile
> source_profiles_
;
59 base::WeakPtrFactory
<ImporterList
> weak_ptr_factory_
;
61 DISALLOW_COPY_AND_ASSIGN(ImporterList
);
64 #endif // CHROME_BROWSER_IMPORTER_IMPORTER_LIST_H_