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/extensions/api/tabs/tabs_api.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <limits> | 9 #include <limits> |
10 #include <memory> | 10 #include <memory> |
(...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1667 this)); | 1667 this)); |
1668 } | 1668 } |
1669 | 1669 |
1670 void TabsCaptureVisibleTabFunction::OnCaptureSuccess(const SkBitmap& bitmap) { | 1670 void TabsCaptureVisibleTabFunction::OnCaptureSuccess(const SkBitmap& bitmap) { |
1671 std::string base64_result; | 1671 std::string base64_result; |
1672 if (!EncodeBitmap(bitmap, &base64_result)) { | 1672 if (!EncodeBitmap(bitmap, &base64_result)) { |
1673 OnCaptureFailure(FAILURE_REASON_ENCODING_FAILED); | 1673 OnCaptureFailure(FAILURE_REASON_ENCODING_FAILED); |
1674 return; | 1674 return; |
1675 } | 1675 } |
1676 | 1676 |
1677 SetResult(base::MakeUnique<base::StringValue>(base64_result)); | 1677 SetResult(base::MakeUnique<base::Value>(base64_result)); |
1678 SendResponse(true); | 1678 SendResponse(true); |
1679 } | 1679 } |
1680 | 1680 |
1681 void TabsCaptureVisibleTabFunction::OnCaptureFailure(FailureReason reason) { | 1681 void TabsCaptureVisibleTabFunction::OnCaptureFailure(FailureReason reason) { |
1682 const char* reason_description = "internal error"; | 1682 const char* reason_description = "internal error"; |
1683 switch (reason) { | 1683 switch (reason) { |
1684 case FAILURE_REASON_UNKNOWN: | 1684 case FAILURE_REASON_UNKNOWN: |
1685 reason_description = "unknown error"; | 1685 reason_description = "unknown error"; |
1686 break; | 1686 break; |
1687 case FAILURE_REASON_ENCODING_FAILED: | 1687 case FAILURE_REASON_ENCODING_FAILED: |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1777 } | 1777 } |
1778 | 1778 |
1779 registrar_.RemoveAll(); | 1779 registrar_.RemoveAll(); |
1780 | 1780 |
1781 // Call GotLanguage in all cases as we want to guarantee the callback is | 1781 // Call GotLanguage in all cases as we want to guarantee the callback is |
1782 // called for every API call the extension made. | 1782 // called for every API call the extension made. |
1783 GotLanguage(language); | 1783 GotLanguage(language); |
1784 } | 1784 } |
1785 | 1785 |
1786 void TabsDetectLanguageFunction::GotLanguage(const std::string& language) { | 1786 void TabsDetectLanguageFunction::GotLanguage(const std::string& language) { |
1787 SetResult(base::MakeUnique<base::StringValue>(language.c_str())); | 1787 SetResult(base::MakeUnique<base::Value>(language.c_str())); |
1788 SendResponse(true); | 1788 SendResponse(true); |
1789 | 1789 |
1790 Release(); // Balanced in Run() | 1790 Release(); // Balanced in Run() |
1791 } | 1791 } |
1792 | 1792 |
1793 ExecuteCodeInTabFunction::ExecuteCodeInTabFunction() | 1793 ExecuteCodeInTabFunction::ExecuteCodeInTabFunction() |
1794 : chrome_details_(this), execute_tab_id_(-1) { | 1794 : chrome_details_(this), execute_tab_id_(-1) { |
1795 } | 1795 } |
1796 | 1796 |
1797 ExecuteCodeInTabFunction::~ExecuteCodeInTabFunction() {} | 1797 ExecuteCodeInTabFunction::~ExecuteCodeInTabFunction() {} |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2117 params->tab_id | 2117 params->tab_id |
2118 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, | 2118 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, |
2119 base::IntToString(*params->tab_id)) | 2119 base::IntToString(*params->tab_id)) |
2120 : keys::kCannotFindTabToDiscard)); | 2120 : keys::kCannotFindTabToDiscard)); |
2121 } | 2121 } |
2122 | 2122 |
2123 TabsDiscardFunction::TabsDiscardFunction() {} | 2123 TabsDiscardFunction::TabsDiscardFunction() {} |
2124 TabsDiscardFunction::~TabsDiscardFunction() {} | 2124 TabsDiscardFunction::~TabsDiscardFunction() {} |
2125 | 2125 |
2126 } // namespace extensions | 2126 } // namespace extensions |
OLD | NEW |