| 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 "content/browser/web_contents/navigation_controller_impl.h" | 5 #include "content/browser/web_contents/navigation_controller_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 base::Unretained(this), | 503 base::Unretained(this), |
| 504 entry->GetUniqueID(), | 504 entry->GetUniqueID(), |
| 505 base::Owned(temp_bitmap)), | 505 base::Owned(temp_bitmap)), |
| 506 temp_bitmap); | 506 temp_bitmap); |
| 507 } | 507 } |
| 508 | 508 |
| 509 void NavigationControllerImpl::OnScreenshotTaken( | 509 void NavigationControllerImpl::OnScreenshotTaken( |
| 510 int unique_id, | 510 int unique_id, |
| 511 skia::PlatformBitmap* bitmap, | 511 skia::PlatformBitmap* bitmap, |
| 512 bool success) { | 512 bool success) { |
| 513 if (!success) { | |
| 514 LOG(ERROR) << "Taking snapshot was unsuccessful for " | |
| 515 << unique_id; | |
| 516 return; | |
| 517 } | |
| 518 | |
| 519 NavigationEntryImpl* entry = NULL; | 513 NavigationEntryImpl* entry = NULL; |
| 520 for (NavigationEntries::iterator i = entries_.begin(); | 514 for (NavigationEntries::iterator i = entries_.begin(); |
| 521 i != entries_.end(); | 515 i != entries_.end(); |
| 522 ++i) { | 516 ++i) { |
| 523 if ((*i)->GetUniqueID() == unique_id) { | 517 if ((*i)->GetUniqueID() == unique_id) { |
| 524 entry = (*i).get(); | 518 entry = (*i).get(); |
| 525 break; | 519 break; |
| 526 } | 520 } |
| 527 } | 521 } |
| 528 | 522 |
| 529 if (!entry) { | 523 if (!entry) { |
| 530 LOG(ERROR) << "Invalid entry with unique id: " << unique_id; | 524 LOG(ERROR) << "Invalid entry with unique id: " << unique_id; |
| 531 return; | 525 return; |
| 532 } | 526 } |
| 533 | 527 |
| 528 if (!success) { |
| 529 LOG(ERROR) << "Taking snapshot was unsuccessful for " |
| 530 << unique_id; |
| 531 entry->SetScreenshotPNGData(std::vector<unsigned char>()); |
| 532 return; |
| 533 } |
| 534 |
| 534 std::vector<unsigned char> data; | 535 std::vector<unsigned char> data; |
| 535 if (gfx::PNGCodec::EncodeBGRASkBitmap(bitmap->GetBitmap(), true, &data)) | 536 if (gfx::PNGCodec::EncodeBGRASkBitmap(bitmap->GetBitmap(), true, &data)) |
| 536 entry->SetScreenshotPNGData(data); | 537 entry->SetScreenshotPNGData(data); |
| 538 else |
| 539 entry->SetScreenshotPNGData(std::vector<unsigned char>()); |
| 537 } | 540 } |
| 538 | 541 |
| 539 bool NavigationControllerImpl::CanGoBack() const { | 542 bool NavigationControllerImpl::CanGoBack() const { |
| 540 return entries_.size() > 1 && GetCurrentEntryIndex() > 0; | 543 return entries_.size() > 1 && GetCurrentEntryIndex() > 0; |
| 541 } | 544 } |
| 542 | 545 |
| 543 bool NavigationControllerImpl::CanGoForward() const { | 546 bool NavigationControllerImpl::CanGoForward() const { |
| 544 int index = GetCurrentEntryIndex(); | 547 int index = GetCurrentEntryIndex(); |
| 545 return index >= 0 && index < (static_cast<int>(entries_.size()) - 1); | 548 return index >= 0 && index < (static_cast<int>(entries_.size()) - 1); |
| 546 } | 549 } |
| (...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1679 const base::Callback<base::Time()>& get_timestamp_callback) { | 1682 const base::Callback<base::Time()>& get_timestamp_callback) { |
| 1680 get_timestamp_callback_ = get_timestamp_callback; | 1683 get_timestamp_callback_ = get_timestamp_callback; |
| 1681 } | 1684 } |
| 1682 | 1685 |
| 1683 void NavigationControllerImpl::SetTakeScreenshotCallbackForTest( | 1686 void NavigationControllerImpl::SetTakeScreenshotCallbackForTest( |
| 1684 const base::Callback<void(RenderViewHost*)>& take_screenshot_callback) { | 1687 const base::Callback<void(RenderViewHost*)>& take_screenshot_callback) { |
| 1685 take_screenshot_callback_ = take_screenshot_callback; | 1688 take_screenshot_callback_ = take_screenshot_callback; |
| 1686 } | 1689 } |
| 1687 | 1690 |
| 1688 } // namespace content | 1691 } // namespace content |
| OLD | NEW |