summaryrefslogtreecommitdiffstats
path: root/image
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-02-23 11:28:41 -0500
committerMatt A. Tobin <email@mattatobin.com>2020-02-23 11:28:41 -0500
commit30e4959bd325ca4c1b507784f06b7fadad75d7a6 (patch)
treee96baca26878757d829e00bb86d7dd4a030cb9f2 /image
parent33ec695ac0a1614c6812c3f9584f7db290296b7f (diff)
downloadUXP-30e4959bd325ca4c1b507784f06b7fadad75d7a6.tar
UXP-30e4959bd325ca4c1b507784f06b7fadad75d7a6.tar.gz
UXP-30e4959bd325ca4c1b507784f06b7fadad75d7a6.tar.lz
UXP-30e4959bd325ca4c1b507784f06b7fadad75d7a6.tar.xz
UXP-30e4959bd325ca4c1b507784f06b7fadad75d7a6.zip
Issue #1053 - Remove android support from image
Diffstat (limited to 'image')
-rw-r--r--image/decoders/icon/android/moz.build13
-rw-r--r--image/decoders/icon/android/nsIconChannel.cpp145
-rw-r--r--image/decoders/icon/android/nsIconChannel.h46
-rw-r--r--image/decoders/icon/moz.build3
-rw-r--r--image/decoders/moz.build2
5 files changed, 0 insertions, 209 deletions
diff --git a/image/decoders/icon/android/moz.build b/image/decoders/icon/android/moz.build
deleted file mode 100644
index 5e58ff0b6..000000000
--- a/image/decoders/icon/android/moz.build
+++ /dev/null
@@ -1,13 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-SOURCES += [
- 'nsIconChannel.cpp',
-]
-
-include('/ipc/chromium/chromium-config.mozbuild')
-
-FINAL_LIBRARY = 'xul'
diff --git a/image/decoders/icon/android/nsIconChannel.cpp b/image/decoders/icon/android/nsIconChannel.cpp
deleted file mode 100644
index 5670bf2f9..000000000
--- a/image/decoders/icon/android/nsIconChannel.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include <stdlib.h>
-#include "mozilla/dom/ContentChild.h"
-#include "nsMimeTypes.h"
-#include "nsIURL.h"
-#include "nsXULAppAPI.h"
-#include "AndroidBridge.h"
-#include "nsIconChannel.h"
-#include "nsIStringStream.h"
-#include "nsNetUtil.h"
-#include "nsComponentManagerUtils.h"
-#include "nsNullPrincipal.h"
-
-NS_IMPL_ISUPPORTS(nsIconChannel,
- nsIRequest,
- nsIChannel)
-
-using namespace mozilla;
-using mozilla::dom::ContentChild;
-
-static nsresult
-GetIconForExtension(const nsACString& aFileExt, uint32_t aIconSize,
- uint8_t* const aBuf)
-{
- if (!AndroidBridge::Bridge()) {
- return NS_ERROR_FAILURE;
- }
-
- AndroidBridge::Bridge()->GetIconForExtension(aFileExt, aIconSize, aBuf);
-
- return NS_OK;
-}
-
-static nsresult
-CallRemoteGetIconForExtension(const nsACString& aFileExt, uint32_t aIconSize,
- uint8_t* const aBuf)
-{
- NS_ENSURE_TRUE(aBuf != nullptr, NS_ERROR_NULL_POINTER);
-
- // An array has to be used to get data from remote process
- InfallibleTArray<uint8_t> bits;
- uint32_t bufSize = aIconSize * aIconSize * 4;
-
- if (!ContentChild::GetSingleton()->SendGetIconForExtension(
- PromiseFlatCString(aFileExt), aIconSize, &bits)) {
- return NS_ERROR_FAILURE;
- }
-
- NS_ASSERTION(bits.Length() == bufSize, "Pixels array is incomplete");
- if (bits.Length() != bufSize) {
- return NS_ERROR_FAILURE;
- }
-
- memcpy(aBuf, bits.Elements(), bufSize);
-
- return NS_OK;
-}
-
-static nsresult
-moz_icon_to_channel(nsIURI* aURI, const nsACString& aFileExt,
- uint32_t aIconSize, nsIChannel** aChannel)
-{
- NS_ENSURE_TRUE(aIconSize < 256 && aIconSize > 0, NS_ERROR_UNEXPECTED);
-
- int width = aIconSize;
- int height = aIconSize;
-
- // moz-icon data should have two bytes for the size,
- // then the ARGB pixel values with pre-multiplied Alpha
- const int channels = 4;
- long int buf_size = 2 + channels * height * width;
- uint8_t* const buf = (uint8_t*)moz_xmalloc(buf_size);
- NS_ENSURE_TRUE(buf, NS_ERROR_OUT_OF_MEMORY);
- uint8_t* out = buf;
-
- *(out++) = width;
- *(out++) = height;
-
- nsresult rv;
- if (XRE_IsParentProcess()) {
- rv = GetIconForExtension(aFileExt, aIconSize, out);
- } else {
- rv = CallRemoteGetIconForExtension(aFileExt, aIconSize, out);
- }
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Encode the RGBA data
- const uint8_t* in = out;
- for (int y = 0; y < height; ++y) {
- for (int x = 0; x < width; ++x) {
- uint8_t r = *(in++);
- uint8_t g = *(in++);
- uint8_t b = *(in++);
- uint8_t a = *(in++);
-#define DO_PREMULTIPLY(c_) uint8_t(uint16_t(c_) * uint16_t(a) / uint16_t(255))
- *(out++) = DO_PREMULTIPLY(b);
- *(out++) = DO_PREMULTIPLY(g);
- *(out++) = DO_PREMULTIPLY(r);
- *(out++) = a;
-#undef DO_PREMULTIPLY
- }
- }
-
- nsCOMPtr<nsIStringInputStream> stream =
- do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = stream->AdoptData((char*)buf, buf_size);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // nsIconProtocolHandler::NewChannel2 will provide the correct loadInfo for
- // this iconChannel. Use the most restrictive security settings for the
- // temporary loadInfo to make sure the channel can not be openend.
- nsCOMPtr<nsIPrincipal> nullPrincipal = nsNullPrincipal::Create();
- return NS_NewInputStreamChannel(aChannel,
- aURI,
- stream,
- nullPrincipal,
- nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED,
- nsIContentPolicy::TYPE_INTERNAL_IMAGE,
- NS_LITERAL_CSTRING(IMAGE_ICON_MS));
-}
-
-nsresult
-nsIconChannel::Init(nsIURI* aURI)
-{
- nsCOMPtr<nsIMozIconURI> iconURI = do_QueryInterface(aURI);
- NS_ASSERTION(iconURI, "URI is not an nsIMozIconURI");
-
- nsAutoCString stockIcon;
- iconURI->GetStockIcon(stockIcon);
-
- uint32_t desiredImageSize;
- iconURI->GetImageSize(&desiredImageSize);
-
- nsAutoCString iconFileExt;
- iconURI->GetFileExtension(iconFileExt);
-
- return moz_icon_to_channel(iconURI, iconFileExt, desiredImageSize,
- getter_AddRefs(mRealChannel));
-}
diff --git a/image/decoders/icon/android/nsIconChannel.h b/image/decoders/icon/android/nsIconChannel.h
deleted file mode 100644
index be5542998..000000000
--- a/image/decoders/icon/android/nsIconChannel.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_image_decoders_icon_android_nsIconChannel_h
-#define mozilla_image_decoders_icon_android_nsIconChannel_h
-
-#include "mozilla/Attributes.h"
-
-#include "nsIChannel.h"
-#include "nsIURI.h"
-#include "nsIIconURI.h"
-#include "nsCOMPtr.h"
-
-/**
- * This class is the Android implementation of nsIconChannel.
- * It asks Android for an icon, and creates a new channel for
- * that file to which all calls will be proxied.
- */
-class nsIconChannel final : public nsIChannel {
- public:
- NS_DECL_ISUPPORTS
- NS_FORWARD_NSIREQUEST(mRealChannel->)
- NS_FORWARD_NSICHANNEL(mRealChannel->)
-
- nsIconChannel() { }
-
- /**
- * Called by nsIconProtocolHandler after it creates this channel.
- * Must be called before calling any other function on this object.
- * If this method fails, no other function must be called on this object.
- */
- nsresult Init(nsIURI* aURI);
-
- private:
- ~nsIconChannel() { }
-
- /**
- * The channel to the temp icon file (e.g. to /tmp/2qy9wjqw.html).
- * Will always be non-null after a successful Init.
- */
- nsCOMPtr<nsIChannel> mRealChannel;
-};
-
-#endif // mozilla_image_decoders_icon_android_nsIconChannel_h
diff --git a/image/decoders/icon/moz.build b/image/decoders/icon/moz.build
index 9c6106fa7..d06d6aa6f 100644
--- a/image/decoders/icon/moz.build
+++ b/image/decoders/icon/moz.build
@@ -25,8 +25,5 @@ if CONFIG['OS_ARCH'] == 'WINNT':
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
platform = 'mac'
-if CONFIG['OS_TARGET'] == 'Android':
- platform = 'android'
-
if platform:
LOCAL_INCLUDES += [platform]
diff --git a/image/decoders/moz.build b/image/decoders/moz.build
index 30c026f99..de7aa7ae8 100644
--- a/image/decoders/moz.build
+++ b/image/decoders/moz.build
@@ -16,8 +16,6 @@ if CONFIG['OS_ARCH'] == 'WINNT':
if toolkit == 'cocoa':
DIRS += ['icon/mac', 'icon']
-elif toolkit == 'android':
- DIRS += ['icon/android', 'icon']
UNIFIED_SOURCES += [
'EXIF.cpp',