Chromium Code Reviews| 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_IMPORTER_LIST_H_ | 5 #ifndef CHROME_BROWSER_IMPORTER_IMPORTER_LIST_H_ |
| 6 #define CHROME_BROWSER_IMPORTER_IMPORTER_LIST_H_ | 6 #define CHROME_BROWSER_IMPORTER_IMPORTER_LIST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "net/url_request/url_request_context_getter.h" | |
| 17 | 16 |
| 18 namespace importer { | 17 namespace importer { |
| 19 class ImporterListObserver; | 18 class ImporterListObserver; |
| 20 struct SourceProfile; | 19 struct SourceProfile; |
| 21 } | 20 } |
| 22 | 21 |
| 23 class ImporterList : public base::RefCountedThreadSafe<ImporterList> { | 22 class ImporterList : public base::RefCountedThreadSafe<ImporterList> { |
| 24 public: | 23 public: |
| 25 explicit ImporterList(net::URLRequestContextGetter* request_context_getter); | 24 explicit ImporterList(); |
|
Ilya Sherman
2013/06/28 20:35:15
nit: No longer a need for "explicit"
gab
2013/07/02 01:43:58
Done.
| |
| 26 | 25 |
| 27 // Detects the installed browsers and their associated profiles, then stores | 26 // Detects the installed browsers and their associated profiles, then stores |
| 28 // their information in a list. It returns the list of description of all | 27 // their information in a list. It returns the list of description of all |
| 29 // profiles. Calls into DetectSourceProfilesWorker() on the FILE thread to do | 28 // profiles. Calls into DetectSourceProfilesWorker() on the FILE thread to do |
| 30 // the real work of detecting source profiles. |observer| must be non-NULL. | 29 // the real work of detecting source profiles. |observer| must be non-NULL. |
| 31 // |locale|: As in DetectSourceProfilesWorker(). | 30 // |locale|: As in DetectSourceProfilesWorker(). |
| 32 void DetectSourceProfiles(const std::string& locale, | 31 void DetectSourceProfiles(const std::string& locale, |
| 33 importer::ImporterListObserver* observer); | 32 importer::ImporterListObserver* observer); |
| 34 | 33 |
| 35 // Sets the observer of this object. When the current observer is destroyed, | 34 // Sets the observer of this object. When the current observer is destroyed, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 | 69 |
| 71 // Called by DetectSourceProfilesWorker() on the source thread. This method | 70 // Called by DetectSourceProfilesWorker() on the source thread. This method |
| 72 // notifies |observer_| that the source profiles are loaded. |profiles| is | 71 // notifies |observer_| that the source profiles are loaded. |profiles| is |
| 73 // the vector of loaded profiles. | 72 // the vector of loaded profiles. |
| 74 void SourceProfilesLoaded( | 73 void SourceProfilesLoaded( |
| 75 const std::vector<importer::SourceProfile*>& profiles); | 74 const std::vector<importer::SourceProfile*>& profiles); |
| 76 | 75 |
| 77 // The list of profiles with the default one first. | 76 // The list of profiles with the default one first. |
| 78 ScopedVector<importer::SourceProfile> source_profiles_; | 77 ScopedVector<importer::SourceProfile> source_profiles_; |
| 79 | 78 |
| 80 // Needed for Google Toolbar Import to connect to Toolbar server. | |
| 81 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | |
| 82 | |
| 83 // The ID of the thread DetectSourceProfiles() is called on. Only valid after | 79 // The ID of the thread DetectSourceProfiles() is called on. Only valid after |
| 84 // DetectSourceProfiles() is called and until SourceProfilesLoaded() has | 80 // DetectSourceProfiles() is called and until SourceProfilesLoaded() has |
| 85 // returned. | 81 // returned. |
| 86 content::BrowserThread::ID source_thread_id_; | 82 content::BrowserThread::ID source_thread_id_; |
| 87 | 83 |
| 88 // Weak reference. Only valid after DetectSourceProfiles() is called and until | 84 // Weak reference. Only valid after DetectSourceProfiles() is called and until |
| 89 // SourceProfilesLoaded() has returned. | 85 // SourceProfilesLoaded() has returned. |
| 90 importer::ImporterListObserver* observer_; | 86 importer::ImporterListObserver* observer_; |
| 91 | 87 |
| 92 // True if |observer_| is set during the lifetime of source profile detection. | 88 // True if |observer_| is set during the lifetime of source profile detection. |
| 93 // This hack is necessary in order to not use |observer_| != NULL as a method | 89 // This hack is necessary in order to not use |observer_| != NULL as a method |
| 94 // of determining whether this object is being observed or not. | 90 // of determining whether this object is being observed or not. |
| 95 // TODO(jhawkins): Remove once DetectSourceProfilesHack() is removed. | 91 // TODO(jhawkins): Remove once DetectSourceProfilesHack() is removed. |
| 96 bool is_observed_; | 92 bool is_observed_; |
| 97 | 93 |
| 98 // True if source profiles are loaded. | 94 // True if source profiles are loaded. |
| 99 bool source_profiles_loaded_; | 95 bool source_profiles_loaded_; |
| 100 | 96 |
| 101 DISALLOW_COPY_AND_ASSIGN(ImporterList); | 97 DISALLOW_COPY_AND_ASSIGN(ImporterList); |
| 102 }; | 98 }; |
| 103 | 99 |
| 104 #endif // CHROME_BROWSER_IMPORTER_IMPORTER_LIST_H_ | 100 #endif // CHROME_BROWSER_IMPORTER_IMPORTER_LIST_H_ |
| OLD | NEW |