Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2841)

Unified Diff: chrome/browser/media/window_icon_util_x11.cc

Issue 2307083002: Cleanup: move WebRTC related files from chrome/browser/media to chrome/browser/media/webrtc/ (Closed)
Patch Set: Removed file wrongly resuscitated during rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/media/window_icon_util_win.cc ('k') | chrome/browser/memory/tab_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/media/window_icon_util_x11.cc
diff --git a/chrome/browser/media/window_icon_util_x11.cc b/chrome/browser/media/window_icon_util_x11.cc
deleted file mode 100644
index 52f211f2955c5d1e8b28451982b4778ac50eda4f..0000000000000000000000000000000000000000
--- a/chrome/browser/media/window_icon_util_x11.cc
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/media/window_icon_util.h"
-
-#include <X11/Xatom.h>
-#include <X11/Xutil.h>
-
-#include "ui/gfx/x/x11_error_tracker.h"
-#include "ui/gfx/x/x11_types.h"
-
-gfx::ImageSkia GetWindowIcon(content::DesktopMediaID id) {
- DCHECK(id.type == content::DesktopMediaID::TYPE_WINDOW);
-
- Display* display = gfx::GetXDisplay();
- Atom property = XInternAtom(display, "_NET_WM_ICON", True);
- Atom actual_type;
- int actual_format;
- unsigned long bytes_after; // NOLINT: type required by XGetWindowProperty
- unsigned long size;
- long* data;
-
- // The |error_tracker| essentially provides an empty X error handler for
- // the call of XGetWindowProperty. The motivation is to guard against crash
- // for any reason that XGetWindowProperty fails. For example, at the time that
- // XGetWindowProperty is called, the window handler (a.k.a |id.id|) may
- // already be invalid due to the fact that the end user has closed the
- // corresponding window, etc.
- std::unique_ptr<gfx::X11ErrorTracker> error_tracker(
- new gfx::X11ErrorTracker());
- int status = XGetWindowProperty(display, id.id, property, 0L, ~0L, False,
- AnyPropertyType, &actual_type, &actual_format,
- &size, &bytes_after,
- reinterpret_cast<unsigned char**>(&data));
- error_tracker.reset();
-
- if (status != Success) {
- return gfx::ImageSkia();
- }
-
- // The format of |data| is concatenation of sections like
- // [width, height, pixel data of size width * height], and the total bytes
- // number of |data| is |size|. And here we are picking the largest icon.
- int width = 0;
- int height = 0;
- int start = 0;
- int i = 0;
- while (i + 1 < static_cast<int>(size)) {
- if ((i == 0 || static_cast<int>(data[i] * data[i + 1]) > width * height) &&
- (i + 1 + data[i] * data[i + 1] < static_cast<int>(size))) {
- width = static_cast<int>(data[i]);
- height = static_cast<int>(data[i + 1]);
- start = i + 2;
- }
- i = i + 2 + static_cast<int>(data[i] * data[i + 1]);
- }
-
- SkBitmap result;
- SkImageInfo info = SkImageInfo::MakeN32(width, height, kUnpremul_SkAlphaType);
- result.allocPixels(info);
- result.lockPixels();
-
- uint32_t* pixels_data = reinterpret_cast<uint32_t*>(result.getPixels());
-
- for (long y = 0; y < height; ++y) {
- for (long x = 0; x < width; ++x) {
- pixels_data[result.rowBytesAsPixels() * y + x] =
- static_cast<uint32_t>(data[start + width * y + x]);
- }
- }
-
- XFree(data);
- return gfx::ImageSkia::CreateFrom1xBitmap(result);
-}
« no previous file with comments | « chrome/browser/media/window_icon_util_win.cc ('k') | chrome/browser/memory/tab_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698