| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/automation/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 | 325 |
| 326 scoped_refptr<ImporterHost> importer_host(new ImporterHost); | 326 scoped_refptr<ImporterHost> importer_host(new ImporterHost); |
| 327 importer_host->SetObserver( | 327 importer_host->SetObserver( |
| 328 new AutomationProviderImportSettingsObserver( | 328 new AutomationProviderImportSettingsObserver( |
| 329 this, import_settings_data_.reply_message)); | 329 this, import_settings_data_.reply_message)); |
| 330 | 330 |
| 331 Profile* target_profile = import_settings_data_.browser->profile(); | 331 Profile* target_profile = import_settings_data_.browser->profile(); |
| 332 importer_host->StartImportSettings(source_profile, | 332 importer_host->StartImportSettings(source_profile, |
| 333 target_profile, | 333 target_profile, |
| 334 import_settings_data_.import_items, | 334 import_settings_data_.import_items, |
| 335 new ProfileWriter(target_profile), | 335 new ProfileWriter(target_profile)); |
| 336 import_settings_data_.first_run); | |
| 337 } | 336 } |
| 338 | 337 |
| 339 void TestingAutomationProvider::Observe( | 338 void TestingAutomationProvider::Observe( |
| 340 int type, | 339 int type, |
| 341 const content::NotificationSource& source, | 340 const content::NotificationSource& source, |
| 342 const content::NotificationDetails& details) { | 341 const content::NotificationDetails& details) { |
| 343 DCHECK(type == chrome::NOTIFICATION_SESSION_END); | 342 DCHECK(type == chrome::NOTIFICATION_SESSION_END); |
| 344 // OnBrowserRemoved does a ReleaseLater. When session end is received we exit | 343 // OnBrowserRemoved does a ReleaseLater. When session end is received we exit |
| 345 // before the task runs resulting in this object not being deleted. This | 344 // before the task runs resulting in this object not being deleted. This |
| 346 // Release balance out the Release scheduled by OnBrowserRemoved. | 345 // Release balance out the Release scheduled by OnBrowserRemoved. |
| (...skipping 2911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3258 string_to_import_item["HISTORY"] = importer::HISTORY; | 3257 string_to_import_item["HISTORY"] = importer::HISTORY; |
| 3259 string_to_import_item["FAVORITES"] = importer::FAVORITES; | 3258 string_to_import_item["FAVORITES"] = importer::FAVORITES; |
| 3260 string_to_import_item["COOKIES"] = importer::COOKIES; | 3259 string_to_import_item["COOKIES"] = importer::COOKIES; |
| 3261 string_to_import_item["PASSWORDS"] = importer::PASSWORDS; | 3260 string_to_import_item["PASSWORDS"] = importer::PASSWORDS; |
| 3262 string_to_import_item["SEARCH_ENGINES"] = importer::SEARCH_ENGINES; | 3261 string_to_import_item["SEARCH_ENGINES"] = importer::SEARCH_ENGINES; |
| 3263 string_to_import_item["HOME_PAGE"] = importer::HOME_PAGE; | 3262 string_to_import_item["HOME_PAGE"] = importer::HOME_PAGE; |
| 3264 string_to_import_item["ALL"] = importer::ALL; | 3263 string_to_import_item["ALL"] = importer::ALL; |
| 3265 | 3264 |
| 3266 ListValue* import_items_list = NULL; | 3265 ListValue* import_items_list = NULL; |
| 3267 if (!args->GetString("import_from", &import_settings_data_.browser_name) || | 3266 if (!args->GetString("import_from", &import_settings_data_.browser_name) || |
| 3268 !args->GetBoolean("first_run", &import_settings_data_.first_run) || | |
| 3269 !args->GetList("import_items", &import_items_list)) { | 3267 !args->GetList("import_items", &import_items_list)) { |
| 3270 AutomationJSONReply(this, reply_message) | 3268 AutomationJSONReply(this, reply_message) |
| 3271 .SendError("Incorrect type for one or more of the arguments."); | 3269 .SendError("Incorrect type for one or more of the arguments."); |
| 3272 return; | 3270 return; |
| 3273 } | 3271 } |
| 3274 | 3272 |
| 3275 import_settings_data_.import_items = 0; | 3273 import_settings_data_.import_items = 0; |
| 3276 int num_items = import_items_list->GetSize(); | 3274 int num_items = import_items_list->GetSize(); |
| 3277 for (int i = 0; i < num_items; i++) { | 3275 for (int i = 0; i < num_items; i++) { |
| 3278 std::string item; | 3276 std::string item; |
| (...skipping 2665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5944 if (g_browser_process) | 5942 if (g_browser_process) |
| 5945 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 5943 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 5946 } | 5944 } |
| 5947 | 5945 |
| 5948 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 5946 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
| 5949 WebContents* tab) { | 5947 WebContents* tab) { |
| 5950 TabStripModel* tab_strip = browser->tab_strip_model(); | 5948 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 5951 if (tab_strip->GetActiveWebContents() != tab) | 5949 if (tab_strip->GetActiveWebContents() != tab) |
| 5952 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); | 5950 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); |
| 5953 } | 5951 } |
| OLD | NEW |