| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/media/webrtc/window_icon_util.h" | 5 #include "chrome/browser/media/webrtc/window_icon_util.h" |
| 6 | 6 |
| 7 #include <X11/Xatom.h> | 7 #include <X11/Xatom.h> |
| 8 #include <X11/Xutil.h> | 8 #include <X11/Xutil.h> |
| 9 | 9 |
| 10 #include "ui/base/x/x11_util.h" |
| 10 #include "ui/gfx/x/x11_error_tracker.h" | 11 #include "ui/gfx/x/x11_error_tracker.h" |
| 11 #include "ui/gfx/x/x11_types.h" | 12 #include "ui/gfx/x/x11_types.h" |
| 12 | 13 |
| 13 gfx::ImageSkia GetWindowIcon(content::DesktopMediaID id) { | 14 gfx::ImageSkia GetWindowIcon(content::DesktopMediaID id) { |
| 14 DCHECK(id.type == content::DesktopMediaID::TYPE_WINDOW); | 15 DCHECK(id.type == content::DesktopMediaID::TYPE_WINDOW); |
| 15 | 16 |
| 16 Display* display = gfx::GetXDisplay(); | 17 Display* display = gfx::GetXDisplay(); |
| 17 Atom property = XInternAtom(display, "_NET_WM_ICON", True); | 18 Atom property = ui::GetAtom("_NET_WM_ICON"); |
| 18 Atom actual_type; | 19 Atom actual_type; |
| 19 int actual_format; | 20 int actual_format; |
| 20 unsigned long bytes_after; // NOLINT: type required by XGetWindowProperty | 21 unsigned long bytes_after; // NOLINT: type required by XGetWindowProperty |
| 21 unsigned long size; | 22 unsigned long size; |
| 22 long* data; | 23 long* data; |
| 23 | 24 |
| 24 // The |error_tracker| essentially provides an empty X error handler for | 25 // The |error_tracker| essentially provides an empty X error handler for |
| 25 // the call of XGetWindowProperty. The motivation is to guard against crash | 26 // the call of XGetWindowProperty. The motivation is to guard against crash |
| 26 // for any reason that XGetWindowProperty fails. For example, at the time that | 27 // for any reason that XGetWindowProperty fails. For example, at the time that |
| 27 // XGetWindowProperty is called, the window handler (a.k.a |id.id|) may | 28 // XGetWindowProperty is called, the window handler (a.k.a |id.id|) may |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 for (long y = 0; y < height; ++y) { | 66 for (long y = 0; y < height; ++y) { |
| 66 for (long x = 0; x < width; ++x) { | 67 for (long x = 0; x < width; ++x) { |
| 67 pixels_data[result.rowBytesAsPixels() * y + x] = | 68 pixels_data[result.rowBytesAsPixels() * y + x] = |
| 68 static_cast<uint32_t>(data[start + width * y + x]); | 69 static_cast<uint32_t>(data[start + width * y + x]); |
| 69 } | 70 } |
| 70 } | 71 } |
| 71 | 72 |
| 72 XFree(data); | 73 XFree(data); |
| 73 return gfx::ImageSkia::CreateFrom1xBitmap(result); | 74 return gfx::ImageSkia::CreateFrom1xBitmap(result); |
| 74 } | 75 } |
| OLD | NEW |