| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/extensions/extension_tabs_module.h" | 5 #include "chrome/browser/extensions/extension_tabs_module.h" |
| 6 | 6 |
| 7 #include "base/gfx/jpeg_codec.h" | 7 #include "app/gfx/codec/jpeg_codec.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/browser/browser.h" | 9 #include "chrome/browser/browser.h" |
| 10 #include "chrome/browser/browser_list.h" | 10 #include "chrome/browser/browser_list.h" |
| 11 #include "chrome/browser/browser_window.h" | 11 #include "chrome/browser/browser_window.h" |
| 12 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 12 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 13 #include "chrome/browser/extensions/extension_tabs_module_constants.h" | 13 #include "chrome/browser/extensions/extension_tabs_module_constants.h" |
| 14 #include "chrome/browser/extensions/extensions_service.h" | 14 #include "chrome/browser/extensions/extensions_service.h" |
| 15 #include "chrome/browser/profile.h" | 15 #include "chrome/browser/profile.h" |
| 16 #include "chrome/browser/renderer_host/backing_store.h" | 16 #include "chrome/browser/renderer_host/backing_store.h" |
| 17 #include "chrome/browser/renderer_host/render_view_host.h" | 17 #include "chrome/browser/renderer_host/render_view_host.h" |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 screen_capture = backing_store->PaintRectToBitmap( | 778 screen_capture = backing_store->PaintRectToBitmap( |
| 779 gfx::Rect(0, 0, backing_store->size().width(), | 779 gfx::Rect(0, 0, backing_store->size().width(), |
| 780 backing_store->size().height())); | 780 backing_store->size().height())); |
| 781 #else | 781 #else |
| 782 // TODO(port) | 782 // TODO(port) |
| 783 error_ = keys::kNotImplementedError; | 783 error_ = keys::kNotImplementedError; |
| 784 return false; | 784 return false; |
| 785 #endif | 785 #endif |
| 786 scoped_refptr<RefCountedBytes> jpeg_data(new RefCountedBytes); | 786 scoped_refptr<RefCountedBytes> jpeg_data(new RefCountedBytes); |
| 787 SkAutoLockPixels screen_capture_lock(screen_capture); | 787 SkAutoLockPixels screen_capture_lock(screen_capture); |
| 788 bool encoded = JPEGCodec::Encode( | 788 bool encoded = gfx::JPEGCodec::Encode( |
| 789 reinterpret_cast<unsigned char*>(screen_capture.getAddr32(0, 0)), | 789 reinterpret_cast<unsigned char*>(screen_capture.getAddr32(0, 0)), |
| 790 JPEGCodec::FORMAT_BGRA, screen_capture.width(), | 790 gfx::JPEGCodec::FORMAT_BGRA, screen_capture.width(), |
| 791 screen_capture.height(), | 791 screen_capture.height(), |
| 792 static_cast<int>(screen_capture.rowBytes()), 90, | 792 static_cast<int>(screen_capture.rowBytes()), 90, |
| 793 &jpeg_data->data); | 793 &jpeg_data->data); |
| 794 if (!encoded) { | 794 if (!encoded) { |
| 795 error_ = ExtensionErrorUtils::FormatErrorMessage( | 795 error_ = ExtensionErrorUtils::FormatErrorMessage( |
| 796 keys::kInternalVisibleTabCaptureError, ""); | 796 keys::kInternalVisibleTabCaptureError, ""); |
| 797 return false; | 797 return false; |
| 798 } | 798 } |
| 799 | 799 |
| 800 std::string base64_result; | 800 std::string base64_result; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 if (ExtensionTabUtil::GetTabById(tab_id, profile, browser, tab_strip, | 888 if (ExtensionTabUtil::GetTabById(tab_id, profile, browser, tab_strip, |
| 889 contents, tab_index)) | 889 contents, tab_index)) |
| 890 return true; | 890 return true; |
| 891 | 891 |
| 892 if (error_message) | 892 if (error_message) |
| 893 *error_message = ExtensionErrorUtils::FormatErrorMessage( | 893 *error_message = ExtensionErrorUtils::FormatErrorMessage( |
| 894 keys::kTabNotFoundError, IntToString(tab_id)); | 894 keys::kTabNotFoundError, IntToString(tab_id)); |
| 895 | 895 |
| 896 return false; | 896 return false; |
| 897 } | 897 } |
| OLD | NEW |