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 #include "chrome/browser/importer/importer_host.h" | 5 #include "chrome/browser/importer/importer_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/importer/firefox_profile_lock.h" | 11 #include "chrome/browser/importer/firefox_profile_lock.h" |
12 #include "chrome/browser/importer/importer.h" | 12 #include "chrome/browser/importer/importer.h" |
13 #include "chrome/browser/importer/importer_lock_dialog.h" | 13 #include "chrome/browser/importer/importer_lock_dialog.h" |
14 #include "chrome/browser/importer/importer_progress_observer.h" | 14 #include "chrome/browser/importer/importer_progress_observer.h" |
15 #include "chrome/browser/importer/importer_type.h" | 15 #include "chrome/browser/importer/importer_type.h" |
16 #include "chrome/browser/importer/in_process_importer_bridge.h" | 16 #include "chrome/browser/importer/in_process_importer_bridge.h" |
17 #include "chrome/browser/importer/toolbar_importer_utils.h" | 17 #include "chrome/browser/importer/toolbar_importer_utils.h" |
18 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/search_engines/template_url.h" | 20 #include "chrome/browser/search_engines/template_url.h" |
21 #include "chrome/browser/search_engines/template_url_service.h" | 21 #include "chrome/browser/search_engines/template_url_service.h" |
22 #include "chrome/browser/search_engines/template_url_service_factory.h" | 22 #include "chrome/browser/search_engines/template_url_service_factory.h" |
23 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
| 24 #include "chrome/browser/ui/simple_message_box.h" |
24 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
25 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
27 #include "content/public/browser/notification_source.h" | 28 #include "content/public/browser/notification_source.h" |
28 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
29 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
30 | 31 |
31 #if defined(OS_WIN) | |
32 // TODO(port): Port this file. | |
33 #include "ui/base/win/message_box_win.h" | |
34 #endif | |
35 | |
36 using content::BrowserThread; | 32 using content::BrowserThread; |
37 | 33 |
38 ImporterHost::ImporterHost() | 34 ImporterHost::ImporterHost() |
39 : profile_(NULL), | 35 : profile_(NULL), |
40 waiting_for_bookmarkbar_model_(false), | 36 waiting_for_bookmarkbar_model_(false), |
41 installed_bookmark_observer_(false), | 37 installed_bookmark_observer_(false), |
42 is_source_readable_(true), | 38 is_source_readable_(true), |
43 importer_(NULL), | 39 importer_(NULL), |
44 headless_(false), | 40 headless_(false), |
45 parent_window_(NULL), | 41 parent_window_(NULL), |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 #endif | 150 #endif |
155 | 151 |
156 CheckForLoadedModels(items); | 152 CheckForLoadedModels(items); |
157 AddRef(); | 153 AddRef(); |
158 InvokeTaskIfDone(); | 154 InvokeTaskIfDone(); |
159 } | 155 } |
160 | 156 |
161 void ImporterHost::OnGoogleGAIACookieChecked(bool result) { | 157 void ImporterHost::OnGoogleGAIACookieChecked(bool result) { |
162 #if defined(OS_WIN) | 158 #if defined(OS_WIN) |
163 if (!result) { | 159 if (!result) { |
164 ui::MessageBox( | 160 browser::ShowMessageBox(NULL, |
165 NULL, | 161 l10n_util::GetStringUTF16(IDS_IMPORTER_GOOGLE_LOGIN_TEXT), string16(), |
166 UTF16ToWide(l10n_util::GetStringUTF16( | 162 browser::MESSAGE_BOX_TYPE_INFORMATION); |
167 IDS_IMPORTER_GOOGLE_LOGIN_TEXT)).c_str(), | |
168 L"", | |
169 MB_OK | MB_TOPMOST); | |
170 | 163 |
171 GURL url("https://accounts.google.com/ServiceLogin"); | 164 GURL url("https://accounts.google.com/ServiceLogin"); |
172 DCHECK(profile_); | 165 DCHECK(profile_); |
173 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); | 166 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); |
174 if (browser) | 167 if (browser) |
175 browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED); | 168 browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED); |
176 | 169 |
177 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 170 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
178 &ImporterHost::OnImportLockDialogEnd, this, false)); | 171 &ImporterHost::OnImportLockDialogEnd, this, false)); |
179 } else { | 172 } else { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 void ImporterHost::BookmarkModelChanged() { | 257 void ImporterHost::BookmarkModelChanged() { |
265 } | 258 } |
266 | 259 |
267 void ImporterHost::Observe(int type, | 260 void ImporterHost::Observe(int type, |
268 const content::NotificationSource& source, | 261 const content::NotificationSource& source, |
269 const content::NotificationDetails& details) { | 262 const content::NotificationDetails& details) { |
270 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED); | 263 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED); |
271 registrar_.RemoveAll(); | 264 registrar_.RemoveAll(); |
272 InvokeTaskIfDone(); | 265 InvokeTaskIfDone(); |
273 } | 266 } |
OLD | NEW |