summaryrefslogtreecommitdiffstats
path: root/chrome/browser/importer
diff options
context:
space:
mode:
authorharaken@google.com <haraken@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-15 15:18:12 +0000
committerharaken@google.com <haraken@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-15 15:18:12 +0000
commit4caa4cfbfa81bad1620354134766fb93c7670674 (patch)
treead9667ffbeb7e271db2d0304a112689d131faa9b /chrome/browser/importer
parent721fa4c2f13b349baeb1929128e3643218860d6b (diff)
downloadchromium_src-4caa4cfbfa81bad1620354134766fb93c7670674.zip
chromium_src-4caa4cfbfa81bad1620354134766fb93c7670674.tar.gz
chromium_src-4caa4cfbfa81bad1620354134766fb93c7670674.tar.bz2
Make sure to pass non-null Profile object to ImporterHost::StartImportSettings
BUG=17322 TEST=ImporterTest.* Review URL: http://codereview.chromium.org/7155018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89190 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/importer')
-rw-r--r--chrome/browser/importer/external_process_importer_host.cc3
-rw-r--r--chrome/browser/importer/importer_host.cc7
-rw-r--r--chrome/browser/importer/importer_unittest.cc16
3 files changed, 20 insertions, 6 deletions
diff --git a/chrome/browser/importer/external_process_importer_host.cc b/chrome/browser/importer/external_process_importer_host.cc
index 0891e34..a14a9bd 100644
--- a/chrome/browser/importer/external_process_importer_host.cc
+++ b/chrome/browser/importer/external_process_importer_host.cc
@@ -27,7 +27,10 @@ void ExternalProcessImporterHost::StartImportSettings(
uint16 items,
ProfileWriter* writer,
bool first_run) {
+ // We really only support importing from one host at a time.
DCHECK(!profile_);
+ DCHECK(target_profile);
+
profile_ = target_profile;
writer_ = writer;
source_profile_ = &source_profile;
diff --git a/chrome/browser/importer/importer_host.cc b/chrome/browser/importer/importer_host.cc
index 04e19a9..07a8166 100644
--- a/chrome/browser/importer/importer_host.cc
+++ b/chrome/browser/importer/importer_host.cc
@@ -104,6 +104,7 @@ void ImporterHost::StartImportSettings(
bool first_run) {
// We really only support importing from one host at a time.
DCHECK(!profile_);
+ DCHECK(target_profile);
profile_ = target_profile;
// Preserves the observer and creates a task, since we do async import so that
@@ -165,8 +166,7 @@ ImporterHost::~ImporterHost() {
importer_->Release();
if (installed_bookmark_observer_) {
- DCHECK(profile_); // Only way for waiting_for_bookmarkbar_model_ to be true
- // is if we have a profile.
+ DCHECK(profile_);
profile_->GetBookmarkModel()->RemoveObserver(this);
}
}
@@ -189,6 +189,9 @@ void ImporterHost::CheckForFirefoxLock(
}
void ImporterHost::CheckForLoadedModels(uint16 items) {
+ // A target profile must be loaded by StartImportSettings().
+ DCHECK(profile_);
+
// BookmarkModel should be loaded before adding IE favorites. So we observe
// the BookmarkModel if needed, and start the task after it has been loaded.
if ((items & importer::FAVORITES) && !writer_->BookmarkModelIsLoaded()) {
diff --git a/chrome/browser/importer/importer_unittest.cc b/chrome/browser/importer/importer_unittest.cc
index 388db80..8ed6136 100644
--- a/chrome/browser/importer/importer_unittest.cc
+++ b/chrome/browser/importer/importer_unittest.cc
@@ -32,6 +32,7 @@
#include "chrome/browser/importer/importer_progress_observer.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/common/chrome_paths.h"
+#include "chrome/test/testing_profile.h"
#include "content/browser/browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/glue/password_form.h"
@@ -54,7 +55,13 @@ class ImporterTest : public testing::Test {
public:
ImporterTest()
: ui_thread_(BrowserThread::UI, &message_loop_),
- file_thread_(BrowserThread::FILE, &message_loop_) {}
+ file_thread_(BrowserThread::FILE, &message_loop_),
+ profile_(new TestingProfile()) {
+ }
+
+ ~ImporterTest() {
+ profile_.reset(NULL);
+ }
protected:
virtual void SetUp() {
@@ -107,7 +114,7 @@ class ImporterTest : public testing::Test {
items = items | importer::SEARCH_ENGINES;
loop->PostTask(FROM_HERE, NewRunnableMethod(host.get(),
&ImporterHost::StartImportSettings, source_profile,
- static_cast<Profile*>(NULL), items, make_scoped_refptr(writer), true));
+ profile_.get(), items, make_scoped_refptr(writer), true));
loop->Run();
}
@@ -117,6 +124,7 @@ class ImporterTest : public testing::Test {
BrowserThread file_thread_;
FilePath profile_path_;
FilePath app_path_;
+ scoped_ptr<TestingProfile> profile_;
};
const int kMaxPathSize = 5;
@@ -395,7 +403,7 @@ TEST_F(ImporterTest, IEImporter) {
loop->PostTask(FROM_HERE, NewRunnableMethod(host.get(),
&ImporterHost::StartImportSettings,
source_profile,
- static_cast<Profile*>(NULL),
+ profile_.get(),
importer::HISTORY | importer::PASSWORDS | importer::FAVORITES,
observer,
true));
@@ -690,7 +698,7 @@ TEST_F(ImporterTest, MAYBE(Firefox2Importer)) {
host.get(),
&ImporterHost::StartImportSettings,
source_profile,
- static_cast<Profile*>(NULL),
+ profile_.get(),
importer::HISTORY | importer::PASSWORDS |
importer::FAVORITES | importer::SEARCH_ENGINES,
make_scoped_refptr(observer),