Reland "Delete mac_utils.h and mac_utils.cc"

This is a reland of ada8e17125d2124f5bcdc1558182ce95d6311d93

Original change's description:
> Delete mac_utils.h and mac_utils.cc
>
> They defined two functions: ToUtf16 and ToUtf8. The former was unused,
> and the latter is moved to
> modules/desktop_capture/mac/window_list_utils.cc, the only user.
>
> Tbr: sergeyu@chromium.org
> Bug: None
> Change-Id: Ib8a513da42e43ba8d41a2de4c1645b3f48448dc9
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/148531
> Commit-Queue: Niels Moller <nisse@webrtc.org>
> Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
> Reviewed-by: Sergey Ulanov <sergeyu@google.com>
> Cr-Commit-Position: refs/heads/master@{#28913}

Tbr: kthelgason@webrtc.org
Bug: None
Change-Id: Icda3a2d6e98cfcaf8618035c248104c234e809ac
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150109
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28979}
diff --git a/modules/desktop_capture/mac/full_screen_chrome_window_detector.cc b/modules/desktop_capture/mac/full_screen_chrome_window_detector.cc
index afa4473..f2c8fd4 100644
--- a/modules/desktop_capture/mac/full_screen_chrome_window_detector.cc
+++ b/modules/desktop_capture/mac/full_screen_chrome_window_detector.cc
@@ -16,7 +16,6 @@
 
 #include "modules/desktop_capture/mac/window_list_utils.h"
 #include "rtc_base/logging.h"
-#include "rtc_base/mac_utils.h"
 #include "rtc_base/time_utils.h"
 
 namespace webrtc {
diff --git a/modules/desktop_capture/mac/window_list_utils.cc b/modules/desktop_capture/mac/window_list_utils.cc
index 5899530..3f0a9b0 100644
--- a/modules/desktop_capture/mac/window_list_utils.cc
+++ b/modules/desktop_capture/mac/window_list_utils.cc
@@ -19,7 +19,6 @@
 #include <map>
 
 #include "rtc_base/checks.h"
-#include "rtc_base/mac_utils.h"
 
 static_assert(static_cast<webrtc::WindowId>(kCGNullWindowID) ==
                   webrtc::kNullWindowId,
@@ -29,6 +28,19 @@
 
 namespace {
 
+bool ToUtf8(const CFStringRef str16, std::string* str8) {
+  size_t maxlen = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str16),
+                                                    kCFStringEncodingUTF8) +
+                  1;
+  std::unique_ptr<char[]> buffer(new char[maxlen]);
+  if (!buffer ||
+      !CFStringGetCString(str16, buffer.get(), maxlen, kCFStringEncodingUTF8)) {
+    return false;
+  }
+  str8->assign(buffer.get());
+  return true;
+}
+
 // Get CFDictionaryRef from |id| and call |on_window| against it. This function
 // returns false if native APIs fail, typically it indicates that the |id| does
 // not represent a window. |on_window| will not be called if false is returned
@@ -247,7 +259,7 @@
   CFStringRef title = reinterpret_cast<CFStringRef>(
       CFDictionaryGetValue(window, kCGWindowName));
   std::string result;
-  if (title && rtc::ToUtf8(title, &result)) {
+  if (title && ToUtf8(title, &result)) {
     return result;
   }
 
@@ -268,7 +280,7 @@
   CFStringRef owner_name = reinterpret_cast<CFStringRef>(
       CFDictionaryGetValue(window, kCGWindowOwnerName));
   std::string result;
-  if (owner_name && rtc::ToUtf8(owner_name, &result)) {
+  if (owner_name && ToUtf8(owner_name, &result)) {
     return result;
   }
   return std::string();
diff --git a/modules/desktop_capture/mouse_cursor_monitor_mac.mm b/modules/desktop_capture/mouse_cursor_monitor_mac.mm
index 35ef394..afc4497 100644
--- a/modules/desktop_capture/mouse_cursor_monitor_mac.mm
+++ b/modules/desktop_capture/mouse_cursor_monitor_mac.mm
@@ -27,7 +27,6 @@
 #include "modules/desktop_capture/mac/full_screen_chrome_window_detector.h"
 #include "modules/desktop_capture/mac/window_list_utils.h"
 #include "modules/desktop_capture/mouse_cursor.h"
-#include "rtc_base/mac_utils.h"
 
 namespace webrtc {
 
diff --git a/modules/desktop_capture/window_capturer_mac.mm b/modules/desktop_capture/window_capturer_mac.mm
index fae3f98..828122b 100644
--- a/modules/desktop_capture/window_capturer_mac.mm
+++ b/modules/desktop_capture/window_capturer_mac.mm
@@ -27,7 +27,6 @@
 #include "modules/desktop_capture/window_finder_mac.h"
 #include "rtc_base/constructor_magic.h"
 #include "rtc_base/logging.h"
-#include "rtc_base/mac_utils.h"
 #include "rtc_base/trace_event.h"
 
 namespace webrtc {
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index b937714..7b0108d 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -926,19 +926,6 @@
     ]
   }
 
-  if (is_mac) {
-    sources += [
-      "mac_utils.cc",
-      "mac_utils.h",
-    ]
-    libs += [
-      "Cocoa.framework",
-      "Foundation.framework",
-      "IOKit.framework",
-      "Security.framework",
-      "SystemConfiguration.framework",
-    ]
-  }
   if (is_ios) {
     libs += [
       "CFNetwork.framework",
diff --git a/rtc_base/mac_utils.cc b/rtc_base/mac_utils.cc
deleted file mode 100644
index d2428b4..0000000
--- a/rtc_base/mac_utils.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- *  Copyright 2007 The WebRTC Project Authors. All rights reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "rtc_base/mac_utils.h"
-
-#include <sys/utsname.h>
-
-#include <cstring>
-#include <memory>
-
-#include "rtc_base/checks.h"
-#include "rtc_base/logging.h"
-
-namespace rtc {
-
-bool ToUtf8(const CFStringRef str16, std::string* str8) {
-  if ((nullptr == str16) || (nullptr == str8)) {
-    return false;
-  }
-  size_t maxlen = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str16),
-                                                    kCFStringEncodingUTF8) +
-                  1;
-  std::unique_ptr<char[]> buffer(new char[maxlen]);
-  if (!buffer ||
-      !CFStringGetCString(str16, buffer.get(), maxlen, kCFStringEncodingUTF8)) {
-    return false;
-  }
-  str8->assign(buffer.get());
-  return true;
-}
-
-bool ToUtf16(const std::string& str8, CFStringRef* str16) {
-  if (nullptr == str16) {
-    return false;
-  }
-  *str16 = CFStringCreateWithBytes(kCFAllocatorDefault,
-                                   reinterpret_cast<const UInt8*>(str8.data()),
-                                   str8.length(), kCFStringEncodingUTF8, false);
-  return nullptr != *str16;
-}
-}  // namespace rtc
diff --git a/rtc_base/mac_utils.h b/rtc_base/mac_utils.h
deleted file mode 100644
index 5f5b836..0000000
--- a/rtc_base/mac_utils.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- *  Copyright 2007 The WebRTC Project Authors. All rights reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef RTC_BASE_MAC_UTILS_H_
-#define RTC_BASE_MAC_UTILS_H_
-
-#include <CoreFoundation/CoreFoundation.h>
-
-#include <string>
-
-namespace rtc {
-bool ToUtf8(const CFStringRef str16, std::string* str8);
-bool ToUtf16(const std::string& str8, CFStringRef* str16);
-}  // namespace rtc
-
-#endif  // RTC_BASE_MAC_UTILS_H_