| 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/automation/automation_provider.h" | 5 #include "chrome/browser/automation/automation_provider.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/browser/automation/automation_resource_message_filter.h" | 32 #include "chrome/browser/automation/automation_resource_message_filter.h" |
| 33 #include "chrome/browser/automation/automation_tab_tracker.h" | 33 #include "chrome/browser/automation/automation_tab_tracker.h" |
| 34 #include "chrome/browser/automation/automation_window_tracker.h" | 34 #include "chrome/browser/automation/automation_window_tracker.h" |
| 35 #include "chrome/browser/bookmarks/bookmark_model.h" | 35 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 36 #include "chrome/browser/bookmarks/bookmark_storage.h" | 36 #include "chrome/browser/bookmarks/bookmark_storage.h" |
| 37 #include "chrome/browser/browser_process.h" | 37 #include "chrome/browser/browser_process.h" |
| 38 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 38 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 39 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 39 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 40 #include "chrome/browser/character_encoding.h" | 40 #include "chrome/browser/character_encoding.h" |
| 41 #include "chrome/browser/content_settings/host_content_settings_map.h" | 41 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 42 #include "chrome/browser/download/download_service.h" |
| 43 #include "chrome/browser/download/download_service_factory.h" |
| 42 #include "chrome/browser/net/url_request_mock_util.h" | 44 #include "chrome/browser/net/url_request_mock_util.h" |
| 43 #include "chrome/browser/prefs/pref_service.h" | 45 #include "chrome/browser/prefs/pref_service.h" |
| 44 #include "chrome/browser/printing/print_job.h" | 46 #include "chrome/browser/printing/print_job.h" |
| 45 #include "chrome/browser/profiles/profile_manager.h" | 47 #include "chrome/browser/profiles/profile_manager.h" |
| 46 #include "chrome/browser/ssl/ssl_blocking_page.h" | 48 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 47 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | 49 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
| 48 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 50 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
| 49 #include "chrome/browser/ui/browser_commands.h" | 51 #include "chrome/browser/ui/browser_commands.h" |
| 50 #include "chrome/browser/ui/browser_finder.h" | 52 #include "chrome/browser/ui/browser_finder.h" |
| 51 #include "chrome/browser/ui/browser_tabstrip.h" | 53 #include "chrome/browser/ui/browser_tabstrip.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 } | 295 } |
| 294 | 296 |
| 295 int AutomationProvider::GetIndexForNavigationController( | 297 int AutomationProvider::GetIndexForNavigationController( |
| 296 const NavigationController* controller, const Browser* parent) const { | 298 const NavigationController* controller, const Browser* parent) const { |
| 297 DCHECK(parent); | 299 DCHECK(parent); |
| 298 return chrome::GetIndexOfTab(parent, controller->GetWebContents()); | 300 return chrome::GetIndexOfTab(parent, controller->GetWebContents()); |
| 299 } | 301 } |
| 300 | 302 |
| 301 // TODO(phajdan.jr): move to TestingAutomationProvider. | 303 // TODO(phajdan.jr): move to TestingAutomationProvider. |
| 302 DictionaryValue* AutomationProvider::GetDictionaryFromDownloadItem( | 304 DictionaryValue* AutomationProvider::GetDictionaryFromDownloadItem( |
| 303 const DownloadItem* download) { | 305 const DownloadItem* download, Profile* profile) { |
| 304 std::map<DownloadItem::DownloadState, std::string> state_to_string; | 306 std::map<DownloadItem::DownloadState, std::string> state_to_string; |
| 305 state_to_string[DownloadItem::IN_PROGRESS] = std::string("IN_PROGRESS"); | 307 state_to_string[DownloadItem::IN_PROGRESS] = std::string("IN_PROGRESS"); |
| 306 state_to_string[DownloadItem::CANCELLED] = std::string("CANCELLED"); | 308 state_to_string[DownloadItem::CANCELLED] = std::string("CANCELLED"); |
| 307 state_to_string[DownloadItem::REMOVING] = std::string("REMOVING"); | 309 state_to_string[DownloadItem::REMOVING] = std::string("REMOVING"); |
| 308 state_to_string[DownloadItem::INTERRUPTED] = std::string("INTERRUPTED"); | 310 state_to_string[DownloadItem::INTERRUPTED] = std::string("INTERRUPTED"); |
| 309 state_to_string[DownloadItem::COMPLETE] = std::string("COMPLETE"); | 311 state_to_string[DownloadItem::COMPLETE] = std::string("COMPLETE"); |
| 310 | 312 |
| 311 std::map<DownloadItem::SafetyState, std::string> safety_state_to_string; | 313 std::map<DownloadItem::SafetyState, std::string> safety_state_to_string; |
| 312 safety_state_to_string[DownloadItem::SAFE] = std::string("SAFE"); | 314 safety_state_to_string[DownloadItem::SAFE] = std::string("SAFE"); |
| 313 safety_state_to_string[DownloadItem::DANGEROUS] = std::string("DANGEROUS"); | 315 safety_state_to_string[DownloadItem::DANGEROUS] = std::string("DANGEROUS"); |
| 314 safety_state_to_string[DownloadItem::DANGEROUS_BUT_VALIDATED] = | 316 safety_state_to_string[DownloadItem::DANGEROUS_BUT_VALIDATED] = |
| 315 std::string("DANGEROUS_BUT_VALIDATED"); | 317 std::string("DANGEROUS_BUT_VALIDATED"); |
| 316 | 318 |
| 317 DictionaryValue* dl_item_value = new DictionaryValue; | 319 DictionaryValue* dl_item_value = new DictionaryValue; |
| 318 dl_item_value->SetInteger("id", static_cast<int>(download->GetId())); | 320 dl_item_value->SetInteger("id", static_cast<int>(download->GetId())); |
| 319 dl_item_value->SetString("url", download->GetURL().spec()); | 321 dl_item_value->SetString("url", download->GetURL().spec()); |
| 320 dl_item_value->SetString("referrer_url", download->GetReferrerUrl().spec()); | 322 dl_item_value->SetString("referrer_url", download->GetReferrerUrl().spec()); |
| 321 dl_item_value->SetString("file_name", | 323 dl_item_value->SetString("file_name", |
| 322 download->GetFileNameToReportUser().value()); | 324 download->GetFileNameToReportUser().value()); |
| 323 dl_item_value->SetString("full_path", | 325 dl_item_value->SetString("full_path", |
| 324 download->GetTargetFilePath().value()); | 326 download->GetTargetFilePath().value()); |
| 325 dl_item_value->SetBoolean("is_paused", download->IsPaused()); | 327 dl_item_value->SetBoolean("is_paused", download->IsPaused()); |
| 326 dl_item_value->SetBoolean("open_when_complete", | 328 dl_item_value->SetBoolean("open_when_complete", |
| 327 download->GetOpenWhenComplete()); | 329 download->GetOpenWhenComplete()); |
| 328 dl_item_value->SetBoolean("is_temporary", download->IsTemporary()); | 330 dl_item_value->SetBoolean("is_temporary", download->IsTemporary()); |
| 329 dl_item_value->SetBoolean("is_otr", download->IsOtr()); // incognito | 331 bool incognito = profile->HasOffTheRecordProfile() && |
| 332 DownloadServiceFactory::GetForProfile( |
| 333 profile->GetOffTheRecordProfile())->HasCreatedDownloadManager() && |
| 334 (content::BrowserContext::GetDownloadManager( |
| 335 profile->GetOffTheRecordProfile())->GetDownload( |
| 336 download->GetId()) == download); |
| 337 dl_item_value->SetBoolean("is_otr", incognito); |
| 330 dl_item_value->SetString("state", state_to_string[download->GetState()]); | 338 dl_item_value->SetString("state", state_to_string[download->GetState()]); |
| 331 dl_item_value->SetString("safety_state", | 339 dl_item_value->SetString("safety_state", |
| 332 safety_state_to_string[download->GetSafetyState()]); | 340 safety_state_to_string[download->GetSafetyState()]); |
| 333 dl_item_value->SetInteger("PercentComplete", download->PercentComplete()); | 341 dl_item_value->SetInteger("PercentComplete", download->PercentComplete()); |
| 334 | 342 |
| 335 return dl_item_value; | 343 return dl_item_value; |
| 336 } | 344 } |
| 337 | 345 |
| 338 void AutomationProvider::OnChannelConnected(int pid) { | 346 void AutomationProvider::OnChannelConnected(int pid) { |
| 339 is_connected_ = true; | 347 is_connected_ = true; |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 | 758 |
| 751 return NULL; | 759 return NULL; |
| 752 } | 760 } |
| 753 | 761 |
| 754 void AutomationProvider::SaveAsAsync(int tab_handle) { | 762 void AutomationProvider::SaveAsAsync(int tab_handle) { |
| 755 NavigationController* tab = NULL; | 763 NavigationController* tab = NULL; |
| 756 WebContents* web_contents = GetWebContentsForHandle(tab_handle, &tab); | 764 WebContents* web_contents = GetWebContentsForHandle(tab_handle, &tab); |
| 757 if (web_contents) | 765 if (web_contents) |
| 758 web_contents->OnSavePage(); | 766 web_contents->OnSavePage(); |
| 759 } | 767 } |
| OLD | NEW |