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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 } | 293 } |
294 | 294 |
295 int AutomationProvider::GetIndexForNavigationController( | 295 int AutomationProvider::GetIndexForNavigationController( |
296 const NavigationController* controller, const Browser* parent) const { | 296 const NavigationController* controller, const Browser* parent) const { |
297 DCHECK(parent); | 297 DCHECK(parent); |
298 return chrome::GetIndexOfTab(parent, controller->GetWebContents()); | 298 return chrome::GetIndexOfTab(parent, controller->GetWebContents()); |
299 } | 299 } |
300 | 300 |
301 // TODO(phajdan.jr): move to TestingAutomationProvider. | 301 // TODO(phajdan.jr): move to TestingAutomationProvider. |
302 DictionaryValue* AutomationProvider::GetDictionaryFromDownloadItem( | 302 DictionaryValue* AutomationProvider::GetDictionaryFromDownloadItem( |
303 const DownloadItem* download) { | 303 const DownloadItem* download, bool incognito) { |
304 std::map<DownloadItem::DownloadState, std::string> state_to_string; | 304 std::map<DownloadItem::DownloadState, std::string> state_to_string; |
305 state_to_string[DownloadItem::IN_PROGRESS] = std::string("IN_PROGRESS"); | 305 state_to_string[DownloadItem::IN_PROGRESS] = std::string("IN_PROGRESS"); |
306 state_to_string[DownloadItem::CANCELLED] = std::string("CANCELLED"); | 306 state_to_string[DownloadItem::CANCELLED] = std::string("CANCELLED"); |
307 state_to_string[DownloadItem::REMOVING] = std::string("REMOVING"); | 307 state_to_string[DownloadItem::REMOVING] = std::string("REMOVING"); |
308 state_to_string[DownloadItem::INTERRUPTED] = std::string("INTERRUPTED"); | 308 state_to_string[DownloadItem::INTERRUPTED] = std::string("INTERRUPTED"); |
309 state_to_string[DownloadItem::COMPLETE] = std::string("COMPLETE"); | 309 state_to_string[DownloadItem::COMPLETE] = std::string("COMPLETE"); |
310 | 310 |
311 std::map<DownloadItem::SafetyState, std::string> safety_state_to_string; | 311 std::map<DownloadItem::SafetyState, std::string> safety_state_to_string; |
312 safety_state_to_string[DownloadItem::SAFE] = std::string("SAFE"); | 312 safety_state_to_string[DownloadItem::SAFE] = std::string("SAFE"); |
313 safety_state_to_string[DownloadItem::DANGEROUS] = std::string("DANGEROUS"); | 313 safety_state_to_string[DownloadItem::DANGEROUS] = std::string("DANGEROUS"); |
314 safety_state_to_string[DownloadItem::DANGEROUS_BUT_VALIDATED] = | 314 safety_state_to_string[DownloadItem::DANGEROUS_BUT_VALIDATED] = |
315 std::string("DANGEROUS_BUT_VALIDATED"); | 315 std::string("DANGEROUS_BUT_VALIDATED"); |
316 | 316 |
317 DictionaryValue* dl_item_value = new DictionaryValue; | 317 DictionaryValue* dl_item_value = new DictionaryValue; |
318 dl_item_value->SetInteger("id", static_cast<int>(download->GetId())); | 318 dl_item_value->SetInteger("id", static_cast<int>(download->GetId())); |
319 dl_item_value->SetString("url", download->GetURL().spec()); | 319 dl_item_value->SetString("url", download->GetURL().spec()); |
320 dl_item_value->SetString("referrer_url", download->GetReferrerUrl().spec()); | 320 dl_item_value->SetString("referrer_url", download->GetReferrerUrl().spec()); |
321 dl_item_value->SetString("file_name", | 321 dl_item_value->SetString("file_name", |
322 download->GetFileNameToReportUser().value()); | 322 download->GetFileNameToReportUser().value()); |
323 dl_item_value->SetString("full_path", | 323 dl_item_value->SetString("full_path", |
324 download->GetTargetFilePath().value()); | 324 download->GetTargetFilePath().value()); |
325 dl_item_value->SetBoolean("is_paused", download->IsPaused()); | 325 dl_item_value->SetBoolean("is_paused", download->IsPaused()); |
326 dl_item_value->SetBoolean("open_when_complete", | 326 dl_item_value->SetBoolean("open_when_complete", |
327 download->GetOpenWhenComplete()); | 327 download->GetOpenWhenComplete()); |
328 dl_item_value->SetBoolean("is_temporary", download->IsTemporary()); | 328 dl_item_value->SetBoolean("is_temporary", download->IsTemporary()); |
329 dl_item_value->SetBoolean("is_otr", download->IsOtr()); // incognito | 329 dl_item_value->SetBoolean("is_otr", incognito); |
Randy Smith (Not in Mondays)
2012/07/23 18:19:26
Does this interface make sense, or would it make m
| |
330 dl_item_value->SetString("state", state_to_string[download->GetState()]); | 330 dl_item_value->SetString("state", state_to_string[download->GetState()]); |
331 dl_item_value->SetString("safety_state", | 331 dl_item_value->SetString("safety_state", |
332 safety_state_to_string[download->GetSafetyState()]); | 332 safety_state_to_string[download->GetSafetyState()]); |
333 dl_item_value->SetInteger("PercentComplete", download->PercentComplete()); | 333 dl_item_value->SetInteger("PercentComplete", download->PercentComplete()); |
334 | 334 |
335 return dl_item_value; | 335 return dl_item_value; |
336 } | 336 } |
337 | 337 |
338 void AutomationProvider::OnChannelConnected(int pid) { | 338 void AutomationProvider::OnChannelConnected(int pid) { |
339 is_connected_ = true; | 339 is_connected_ = true; |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
750 | 750 |
751 return NULL; | 751 return NULL; |
752 } | 752 } |
753 | 753 |
754 void AutomationProvider::SaveAsAsync(int tab_handle) { | 754 void AutomationProvider::SaveAsAsync(int tab_handle) { |
755 NavigationController* tab = NULL; | 755 NavigationController* tab = NULL; |
756 WebContents* web_contents = GetWebContentsForHandle(tab_handle, &tab); | 756 WebContents* web_contents = GetWebContentsForHandle(tab_handle, &tab); |
757 if (web_contents) | 757 if (web_contents) |
758 web_contents->OnSavePage(); | 758 web_contents->OnSavePage(); |
759 } | 759 } |
OLD | NEW |