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 "app/gfx/codec/jpeg_codec.h" | 7 #include "app/gfx/codec/jpeg_codec.h" |
8 #include "base/base64.h" | 8 #include "base/base64.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 reinterpret_cast<const char*>(&jpeg_data->data[0]), | 825 reinterpret_cast<const char*>(&jpeg_data->data[0]), |
826 jpeg_data->data.size()); | 826 jpeg_data->data.size()); |
827 | 827 |
828 base::Base64Encode(stream_as_string, &base64_result); | 828 base::Base64Encode(stream_as_string, &base64_result); |
829 base64_result.insert(0, "data:image/jpg;base64,"); | 829 base64_result.insert(0, "data:image/jpg;base64,"); |
830 result_.reset(new StringValue(base64_result)); | 830 result_.reset(new StringValue(base64_result)); |
831 SendResponse(true); | 831 SendResponse(true); |
832 } | 832 } |
833 | 833 |
834 bool DetectTabLanguageFunction::RunImpl() { | 834 bool DetectTabLanguageFunction::RunImpl() { |
| 835 #if !defined(OS_WIN) |
| 836 error_ = keys::kSupportedInWindowsOnlyError; |
| 837 return false; |
| 838 #endif |
| 839 |
835 int tab_id = 0; | 840 int tab_id = 0; |
836 Browser* browser = NULL; | 841 Browser* browser = NULL; |
837 TabContents* contents = NULL; | 842 TabContents* contents = NULL; |
838 | 843 |
839 // If |tab_id| is specified, look for it. Otherwise default to selected tab | 844 // If |tab_id| is specified, look for it. Otherwise default to selected tab |
840 // in the current window. | 845 // in the current window. |
841 if (!args_->IsType(Value::TYPE_NULL)) { | 846 if (!args_->IsType(Value::TYPE_NULL)) { |
842 EXTENSION_FUNCTION_VALIDATE(args_->GetAsInteger(&tab_id)); | 847 EXTENSION_FUNCTION_VALIDATE(args_->GetAsInteger(&tab_id)); |
843 if (!GetTabById(tab_id, profile(), &browser, NULL, &contents, NULL, | 848 if (!GetTabById(tab_id, profile(), &browser, NULL, &contents, NULL, |
844 &error_)) { | 849 &error_)) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 if (ExtensionTabUtil::GetTabById(tab_id, profile, browser, tab_strip, | 909 if (ExtensionTabUtil::GetTabById(tab_id, profile, browser, tab_strip, |
905 contents, tab_index)) | 910 contents, tab_index)) |
906 return true; | 911 return true; |
907 | 912 |
908 if (error_message) | 913 if (error_message) |
909 *error_message = ExtensionErrorUtils::FormatErrorMessage( | 914 *error_message = ExtensionErrorUtils::FormatErrorMessage( |
910 keys::kTabNotFoundError, IntToString(tab_id)); | 915 keys::kTabNotFoundError, IntToString(tab_id)); |
911 | 916 |
912 return false; | 917 return false; |
913 } | 918 } |
OLD | NEW |