OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/ui/webui/options/import_data_handler.h" | 5 #include "chrome/browser/ui/webui/options/import_data_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/importer/external_process_importer_host.h" | 18 #include "chrome/browser/importer/external_process_importer_host.h" |
19 #include "chrome/browser/importer/importer_host.h" | 19 #include "chrome/browser/importer/importer_host.h" |
20 #include "chrome/browser/importer/importer_list.h" | 20 #include "chrome/browser/importer/importer_list.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 22 #include "content/browser/tab_contents/tab_contents.h" |
22 #include "grit/chromium_strings.h" | 23 #include "grit/chromium_strings.h" |
23 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
25 | 26 |
26 ImportDataHandler::ImportDataHandler() : importer_host_(NULL) { | 27 ImportDataHandler::ImportDataHandler() : importer_host_(NULL) { |
27 } | 28 } |
28 | 29 |
29 ImportDataHandler::~ImportDataHandler() { | 30 ImportDataHandler::~ImportDataHandler() { |
30 if (importer_list_) | 31 if (importer_list_) |
31 importer_list_->SetObserver(NULL); | 32 importer_list_->SetObserver(NULL); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // TODO(csilv): Out-of-process import has only been qualified on MacOS X, | 104 // TODO(csilv): Out-of-process import has only been qualified on MacOS X, |
104 // so we will only use it on that platform since it is required. Remove this | 105 // so we will only use it on that platform since it is required. Remove this |
105 // conditional logic once oop import is qualified for Linux/Windows. | 106 // conditional logic once oop import is qualified for Linux/Windows. |
106 // http://crbug.com/22142 | 107 // http://crbug.com/22142 |
107 #if defined(OS_MACOSX) | 108 #if defined(OS_MACOSX) |
108 importer_host_ = new ExternalProcessImporterHost; | 109 importer_host_ = new ExternalProcessImporterHost; |
109 #else | 110 #else |
110 importer_host_ = new ImporterHost; | 111 importer_host_ = new ImporterHost; |
111 #endif | 112 #endif |
112 importer_host_->SetObserver(this); | 113 importer_host_->SetObserver(this); |
113 Profile* profile = web_ui_->GetProfile(); | 114 Profile* profile = |
| 115 Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context()); |
114 importer_host_->StartImportSettings(source_profile, profile, | 116 importer_host_->StartImportSettings(source_profile, profile, |
115 import_services, | 117 import_services, |
116 new ProfileWriter(profile), false); | 118 new ProfileWriter(profile), false); |
117 } else { | 119 } else { |
118 LOG(WARNING) << "There were no settings to import from '" | 120 LOG(WARNING) << "There were no settings to import from '" |
119 << source_profile.importer_name << "'."; | 121 << source_profile.importer_name << "'."; |
120 } | 122 } |
121 } | 123 } |
122 | 124 |
123 void ImportDataHandler::OnSourceProfilesLoaded() { | 125 void ImportDataHandler::OnSourceProfilesLoaded() { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 void ImportDataHandler::ImportItemEnded(importer::ImportItem item) { | 158 void ImportDataHandler::ImportItemEnded(importer::ImportItem item) { |
157 // TODO(csilv): show progress detail in the web view. | 159 // TODO(csilv): show progress detail in the web view. |
158 } | 160 } |
159 | 161 |
160 void ImportDataHandler::ImportEnded() { | 162 void ImportDataHandler::ImportEnded() { |
161 importer_host_->SetObserver(NULL); | 163 importer_host_->SetObserver(NULL); |
162 importer_host_ = NULL; | 164 importer_host_ = NULL; |
163 | 165 |
164 web_ui_->CallJavascriptFunction("ImportDataOverlay.confirmSuccess"); | 166 web_ui_->CallJavascriptFunction("ImportDataOverlay.confirmSuccess"); |
165 } | 167 } |
OLD | NEW |