| 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 | |
| 840 int tab_id = 0; | 835 int tab_id = 0; |
| 841 Browser* browser = NULL; | 836 Browser* browser = NULL; |
| 842 TabContents* contents = NULL; | 837 TabContents* contents = NULL; |
| 843 | 838 |
| 844 // If |tab_id| is specified, look for it. Otherwise default to selected tab | 839 // If |tab_id| is specified, look for it. Otherwise default to selected tab |
| 845 // in the current window. | 840 // in the current window. |
| 846 if (!args_->IsType(Value::TYPE_NULL)) { | 841 if (!args_->IsType(Value::TYPE_NULL)) { |
| 847 EXTENSION_FUNCTION_VALIDATE(args_->GetAsInteger(&tab_id)); | 842 EXTENSION_FUNCTION_VALIDATE(args_->GetAsInteger(&tab_id)); |
| 848 if (!GetTabById(tab_id, profile(), &browser, NULL, &contents, NULL, | 843 if (!GetTabById(tab_id, profile(), &browser, NULL, &contents, NULL, |
| 849 &error_)) { | 844 &error_)) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 if (ExtensionTabUtil::GetTabById(tab_id, profile, browser, tab_strip, | 904 if (ExtensionTabUtil::GetTabById(tab_id, profile, browser, tab_strip, |
| 910 contents, tab_index)) | 905 contents, tab_index)) |
| 911 return true; | 906 return true; |
| 912 | 907 |
| 913 if (error_message) | 908 if (error_message) |
| 914 *error_message = ExtensionErrorUtils::FormatErrorMessage( | 909 *error_message = ExtensionErrorUtils::FormatErrorMessage( |
| 915 keys::kTabNotFoundError, IntToString(tab_id)); | 910 keys::kTabNotFoundError, IntToString(tab_id)); |
| 916 | 911 |
| 917 return false; | 912 return false; |
| 918 } | 913 } |
| OLD | NEW |