Commit 59c2b964 authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Modernize CoreWLAN use.

Switch from a symbol that is no longer present in the macOS SDK to
a string that is undocumented.

Bug: 1053786
Change-Id: Ibed8b3a53a7280182b85e2cfeec7acd0bdabf53e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2063732
Auto-Submit: Avi Drissman <avi@chromium.org>
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Matt Mueller <mattm@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Reviewed-by: default avatarMatt Mueller <mattm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742707}
parent 44f0a43b
...@@ -19,15 +19,6 @@ ...@@ -19,15 +19,6 @@
#include "base/base_export.h" #include "base/base_export.h"
// ----------------------------------------------------------------------------
// Old symbols that used to be in the macOS SDK but are no longer.
// ----------------------------------------------------------------------------
// kCWSSIDDidChangeNotification is available in the CoreWLAN.framework for OSX
// versions 10.6 through 10.10 but stopped being included starting with the 10.9
// SDK. Remove when 10.10 is no longer supported by Chromium.
BASE_EXPORT extern "C" NSString* const kCWSSIDDidChangeNotification;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Definitions from SDKs newer than the one that Chromium compiles against. // Definitions from SDKs newer than the one that Chromium compiles against.
// //
......
...@@ -396,17 +396,28 @@ void WiFiServiceMac::SetEventObservers( ...@@ -396,17 +396,28 @@ void WiFiServiceMac::SetEventObservers(
// Subscribe to OS notifications. // Subscribe to OS notifications.
if (!networks_changed_observer_.is_null()) { if (!networks_changed_observer_.is_null()) {
void (^ns_observer) (NSNotification* notification) = void (^ns_observer)(NSNotification* notification) = ^(
^(NSNotification* notification) { NSNotification* notification) {
DVLOG(1) << "Received CWSSIDDidChangeNotification"; DVLOG(1) << "Received CoreWLAN notification that the SSID changed";
task_runner_->PostTask( task_runner_->PostTask(
FROM_HERE, FROM_HERE, base::BindOnce(&WiFiServiceMac::OnWlanObserverNotification,
base::BindOnce(&WiFiServiceMac::OnWlanObserverNotification, base::Unretained(this)));
base::Unretained(this)));
}; };
// A notification with the symbol kCWSSIDDidChangeNotification started being
// broadcast on SSID change starting with 10.6 and continuing on through
// 10.15. However, that symbol was marked as deprecated after macOS 10.10,
// and actually was removed starting with the macOS 10.9 SDK.
//
// Starting with 10.8, a set of parallel notifications with explicitly-
// specified string names started being broadcast. The parallel notification
// for that symbol is @"com.apple.coreWLAN.notification.ssid.legacy".
//
// Given the choice between a symbol that is marked as "deprecated" in the
// docs and actually removed from the SDK, and an undocumented string that
// is secretly broadcast, the string is the safer choice.
wlan_observer_ = [[NSNotificationCenter defaultCenter] wlan_observer_ = [[NSNotificationCenter defaultCenter]
addObserverForName:kCWSSIDDidChangeNotification addObserverForName:@"com.apple.coreWLAN.notification.ssid.legacy"
object:nil object:nil
queue:nil queue:nil
usingBlock:ns_observer]; usingBlock:ns_observer];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment