summaryrefslogtreecommitdiff
path: root/chromium/components/media_router
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/media_router')
-rw-r--r--chromium/components/media_router/browser/android/BUILD.gn6
-rw-r--r--chromium/components/media_router/browser/media_router_base.h2
-rw-r--r--chromium/components/media_router/browser/media_router_dialog_controller.cc2
-rw-r--r--chromium/components/media_router/browser/media_router_metrics.h20
-rw-r--r--chromium/components/media_router/browser/route_message_util.cc5
-rw-r--r--chromium/components/media_router/common/discovery/media_sink_internal.cc2
-rw-r--r--chromium/components/media_router/common/discovery/media_sink_internal.h15
-rw-r--r--chromium/components/media_router/common/discovery/media_sink_service_base.cc4
-rw-r--r--chromium/components/media_router/common/discovery/media_sink_service_base.h1
-rw-r--r--chromium/components/media_router/common/mojom/media_router_mojom_traits.cc14
-rw-r--r--chromium/components/media_router/common/providers/cast/cast_media_source.cc12
-rw-r--r--chromium/components/media_router/test/android/cast_emulator/BUILD.gn1
12 files changed, 48 insertions, 36 deletions
diff --git a/chromium/components/media_router/browser/android/BUILD.gn b/chromium/components/media_router/browser/android/BUILD.gn
index 3a028f66020..55593264b6e 100644
--- a/chromium/components/media_router/browser/android/BUILD.gn
+++ b/chromium/components/media_router/browser/android/BUILD.gn
@@ -16,15 +16,16 @@ android_library("java") {
"$google_play_services_package:google_play_services_cast_framework_java",
"$google_play_services_package:google_play_services_cast_java",
"//base:base_java",
+ "//base:jni_java",
+ "//build/android:build_java",
"//components/browser_ui/media/android:java",
"//content/public/android:content_java",
"//services/media_session/public/cpp/android:media_session_java",
- "//third_party/android_deps:android_support_v7_appcompat_java",
"//third_party/android_media:android_media_java",
"//third_party/androidx:androidx_annotation_annotation_java",
"//third_party/androidx:androidx_collection_collection_java",
- "//third_party/androidx:androidx_core_core_java",
"//third_party/androidx:androidx_fragment_fragment_java",
+ "//third_party/androidx:androidx_media_media_java",
"//third_party/androidx:androidx_mediarouter_mediarouter_java",
]
sources = [
@@ -102,6 +103,7 @@ android_library("test_support_java") {
":test_jni_headers",
"//base:base_java",
"//base:base_java_test_support",
+ "//base:jni_java",
"//components/browser_ui/media/android:java",
"//content/public/android:content_java",
"//content/public/test/android:content_java_test_support",
diff --git a/chromium/components/media_router/browser/media_router_base.h b/chromium/components/media_router/browser/media_router_base.h
index 987be89d524..ca2d985e9e6 100644
--- a/chromium/components/media_router/browser/media_router_base.h
+++ b/chromium/components/media_router/browser/media_router_base.h
@@ -41,7 +41,7 @@ class MediaRouterBase : public MediaRouter {
FRIEND_TEST_ALL_PREFIXES(MediaRouterBaseTest, CreatePresentationIds);
FRIEND_TEST_ALL_PREFIXES(MediaRouterBaseTest, NotifyCallbacks);
FRIEND_TEST_ALL_PREFIXES(PresentationServiceDelegateImplTest,
- ListenForConnnectionStateChange);
+ ListenForConnectionStateChange);
FRIEND_TEST_ALL_PREFIXES(PresentationServiceDelegateImplTest, GetMediaRoutes);
MediaRouterBase();
diff --git a/chromium/components/media_router/browser/media_router_dialog_controller.cc b/chromium/components/media_router/browser/media_router_dialog_controller.cc
index 2f5488d5ae1..c17675b8b1a 100644
--- a/chromium/components/media_router/browser/media_router_dialog_controller.cc
+++ b/chromium/components/media_router/browser/media_router_dialog_controller.cc
@@ -92,8 +92,6 @@ bool MediaRouterDialogController::ShowMediaRouterDialogForPresentation(
}
start_presentation_context_ = std::move(context);
- MediaRouterMetrics::RecordMediaRouterDialogOrigin(
- MediaRouterDialogOpenOrigin::PAGE);
FocusOnMediaRouterDialog(true, MediaRouterDialogOpenOrigin::PAGE);
return true;
}
diff --git a/chromium/components/media_router/browser/media_router_metrics.h b/chromium/components/media_router/browser/media_router_metrics.h
index 273df93bddd..75f493b9fa2 100644
--- a/chromium/components/media_router/browser/media_router_metrics.h
+++ b/chromium/components/media_router/browser/media_router_metrics.h
@@ -53,10 +53,14 @@ enum class DialogActivationLocationAndCastMode {
kAppMenuAndTabMirror,
kAppMenuAndDesktopMirror,
kAppMenuAndLocalFile, // Obsolete.
+ kSharingHubAndPresentation,
+ kSharingHubAndTabMirror,
+ kSharingHubAndDesktopMirror,
// NOTE: Do not reorder existing entries, and add entries only immediately
- // above this line.
- kMaxValue = kAppMenuAndLocalFile
+ // above this line. Remember to also update
+ // tools/metrics/histograms/enums.xml.
+ kMaxValue = kSharingHubAndDesktopMirror
};
// Where the user clicked to open the Media Router dialog.
@@ -69,9 +73,11 @@ enum class MediaRouterDialogOpenOrigin {
PAGE = 3,
APP_MENU = 4,
SYSTEM_TRAY = 5,
+ SHARING_HUB = 6,
- // NOTE: Add entries only immediately above this line.
- TOTAL_COUNT = 6
+ // NOTE: Add entries only immediately above this line. Remember to also update
+ // tools/metrics/histograms/enums.xml.
+ TOTAL_COUNT = 7
};
// The possible outcomes from a route creation response.
@@ -80,7 +86,8 @@ enum class MediaRouterRouteCreationOutcome {
FAILURE_NO_ROUTE = 1,
FAILURE_INVALID_SINK = 2,
- // Note: Add entries only immediately above this line.
+ // Note: Add entries only immediately above this line. Remember to also update
+ // tools/metrics/histograms/enums.xml.
TOTAL_COUNT = 3,
};
@@ -95,7 +102,8 @@ enum class MediaRouterUserAction {
REPLACE_LOCAL_ROUTE = 5,
STOP_REMOTE = 6,
- // Note: Add entries only immediately above this line.
+ // Note: Add entries only immediately above this line. Remember to also update
+ // tools/metrics/histograms/enums.xml.
TOTAL_COUNT = 7
};
diff --git a/chromium/components/media_router/browser/route_message_util.cc b/chromium/components/media_router/browser/route_message_util.cc
index 52ae3d92c1a..3a67603d4ef 100644
--- a/chromium/components/media_router/browser/route_message_util.cc
+++ b/chromium/components/media_router/browser/route_message_util.cc
@@ -45,10 +45,9 @@ PresentationConnectionFromRouteMessage(RouteMessagePtr route_message) {
case RouteMessage::Type::BINARY:
return blink::mojom::PresentationConnectionMessage::NewData(
route_message->data.value());
- default:
- NOTREACHED() << "Unknown RouteMessageType " << route_message->type;
- return blink::mojom::PresentationConnectionMessage::New();
}
+ NOTREACHED() << "Unknown RouteMessageType " << route_message->type;
+ return nullptr;
}
} // namespace message_util
diff --git a/chromium/components/media_router/common/discovery/media_sink_internal.cc b/chromium/components/media_router/common/discovery/media_sink_internal.cc
index 0414cbae54c..683960367e8 100644
--- a/chromium/components/media_router/common/discovery/media_sink_internal.cc
+++ b/chromium/components/media_router/common/discovery/media_sink_internal.cc
@@ -206,7 +206,7 @@ bool CastSinkExtraData::operator==(const CastSinkExtraData& other) const {
return ip_endpoint == other.ip_endpoint && model_name == other.model_name &&
capabilities == other.capabilities &&
cast_channel_id == other.cast_channel_id &&
- discovered_by_dial == other.discovered_by_dial;
+ discovery_type == other.discovery_type;
}
} // namespace media_router
diff --git a/chromium/components/media_router/common/discovery/media_sink_internal.h b/chromium/components/media_router/common/discovery/media_sink_internal.h
index f68ea891955..b71928b22bf 100644
--- a/chromium/components/media_router/common/discovery/media_sink_internal.h
+++ b/chromium/components/media_router/common/discovery/media_sink_internal.h
@@ -17,6 +17,14 @@ namespace media_router {
// Default Cast control port to open Cast Socket.
static constexpr int kCastControlPort = 8009;
+// The method by which the cast sink was discovered.
+enum class CastDiscoveryType {
+ kMdns,
+ kDial,
+ kAccessCodeManualEntry,
+ kAccessCodeRememberedDevice,
+};
+
// Extra data for DIAL media sink.
struct DialSinkExtraData {
net::IPAddress ip_address;
@@ -53,11 +61,8 @@ struct CastSinkExtraData {
// browser reconnects to a device.
int cast_channel_id = 0;
- // True if Cast channel is opened from DIAL sink.
- bool discovered_by_dial = false;
-
- // True if Cast Device was discovered via access code.
- bool discovered_by_access_code = false;
+ // The method used to discover the cast sink.
+ CastDiscoveryType discovery_type = CastDiscoveryType::kMdns;
CastSinkExtraData();
CastSinkExtraData(const CastSinkExtraData& other);
diff --git a/chromium/components/media_router/common/discovery/media_sink_service_base.cc b/chromium/components/media_router/common/discovery/media_sink_service_base.cc
index bf927876f09..0fb1c1c0159 100644
--- a/chromium/components/media_router/common/discovery/media_sink_service_base.cc
+++ b/chromium/components/media_router/common/discovery/media_sink_service_base.cc
@@ -89,6 +89,10 @@ void MediaSinkServiceBase::SetTimerForTest(
discovery_timer_ = std::move(timer);
}
+void MediaSinkServiceBase::AddSinkForTest(const MediaSinkInternal& sink) {
+ sinks_.insert_or_assign(sink.sink().id(), sink);
+}
+
void MediaSinkServiceBase::StartTimer() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (discovery_timer_->IsRunning())
diff --git a/chromium/components/media_router/common/discovery/media_sink_service_base.h b/chromium/components/media_router/common/discovery/media_sink_service_base.h
index 5512197d128..155cac3e25f 100644
--- a/chromium/components/media_router/common/discovery/media_sink_service_base.h
+++ b/chromium/components/media_router/common/discovery/media_sink_service_base.h
@@ -83,6 +83,7 @@ class MediaSinkServiceBase {
const MediaSinkInternal* GetSinkByRoute(const MediaRoute& route) const;
void SetTimerForTest(std::unique_ptr<base::OneShotTimer> timer);
+ void AddSinkForTest(const MediaSinkInternal& sink);
protected:
// Called when |discovery_timer_| expires. Informs subclass to report device
diff --git a/chromium/components/media_router/common/mojom/media_router_mojom_traits.cc b/chromium/components/media_router/common/mojom/media_router_mojom_traits.cc
index fc1e99840d3..9abe02ee1e8 100644
--- a/chromium/components/media_router/common/mojom/media_router_mojom_traits.cc
+++ b/chromium/components/media_router/common/mojom/media_router_mojom_traits.cc
@@ -52,14 +52,12 @@ UnionTraits<media_router::mojom::MediaSinkExtraDataDataView,
media_router::MediaSinkInternal>::
GetTag(const media_router::MediaSinkInternal& sink) {
if (sink.is_dial_sink()) {
- return media_router::mojom::MediaSinkExtraDataDataView::Tag::
- DIAL_MEDIA_SINK;
+ return media_router::mojom::MediaSinkExtraDataDataView::Tag::kDialMediaSink;
} else if (sink.is_cast_sink()) {
- return media_router::mojom::MediaSinkExtraDataDataView::Tag::
- CAST_MEDIA_SINK;
+ return media_router::mojom::MediaSinkExtraDataDataView::Tag::kCastMediaSink;
}
NOTREACHED();
- return media_router::mojom::MediaSinkExtraDataDataView::Tag::CAST_MEDIA_SINK;
+ return media_router::mojom::MediaSinkExtraDataDataView::Tag::kCastMediaSink;
}
// static
@@ -119,16 +117,14 @@ bool UnionTraits<media_router::mojom::MediaSinkExtraDataDataView,
Read(media_router::mojom::MediaSinkExtraDataDataView data,
media_router::MediaSinkInternal* out) {
switch (data.tag()) {
- case media_router::mojom::MediaSinkExtraDataDataView::Tag::
- DIAL_MEDIA_SINK: {
+ case media_router::mojom::MediaSinkExtraDataDataView::Tag::kDialMediaSink: {
media_router::DialSinkExtraData extra_data;
if (!data.ReadDialMediaSink(&extra_data))
return false;
out->set_dial_data(extra_data);
return true;
}
- case media_router::mojom::MediaSinkExtraDataDataView::Tag::
- CAST_MEDIA_SINK: {
+ case media_router::mojom::MediaSinkExtraDataDataView::Tag::kCastMediaSink: {
media_router::CastSinkExtraData extra_data;
if (!data.ReadCastMediaSink(&extra_data))
return false;
diff --git a/chromium/components/media_router/common/providers/cast/cast_media_source.cc b/chromium/components/media_router/common/providers/cast/cast_media_source.cc
index 67e4615c525..b862ee25400 100644
--- a/chromium/components/media_router/common/providers/cast/cast_media_source.cc
+++ b/chromium/components/media_router/common/providers/cast/cast_media_source.cc
@@ -9,6 +9,7 @@
#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
+#include "base/strings/escape.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
@@ -17,7 +18,6 @@
#include "components/cast_channel/cast_message_util.h"
#include "components/cast_channel/enum_table.h"
#include "components/media_router/common/media_source.h"
-#include "net/base/escape.h"
#include "net/base/url_util.h"
#include "third_party/openscreen/src/cast/common/public/cast_streaming_app_ids.h"
#include "url/gurl.h"
@@ -158,7 +158,7 @@ base::flat_map<std::string, std::string> MakeQueryMap(const GURL& url) {
}
// TODO(crbug.com/1291718): Move to common utils? Should this use
-// net::UnescapeURLComponent instead of url::DecodeURLEscapeSequences?
+// base::UnescapeURLComponent instead of url::DecodeURLEscapeSequences?
std::string DecodeURLComponent(const std::string& encoded) {
url::RawCanonOutputT<char16_t> unescaped;
std::string output;
@@ -315,11 +315,11 @@ std::unique_ptr<CastMediaSource> ParseLegacyCastUrl(
base::StringPairs params;
base::SplitStringIntoKeyValuePairs(url.ref(), '=', '/', &params);
for (auto& pair : params) {
- pair.second = net::UnescapeURLComponent(
+ pair.second = base::UnescapeURLComponent(
pair.second,
- net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS |
- net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS |
- net::UnescapeRule::REPLACE_PLUS_WITH_SPACE);
+ base::UnescapeRule::SPACES | base::UnescapeRule::PATH_SEPARATORS |
+ base::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS |
+ base::UnescapeRule::REPLACE_PLUS_WITH_SPACE);
}
// Legacy URLs can specify multiple apps.
diff --git a/chromium/components/media_router/test/android/cast_emulator/BUILD.gn b/chromium/components/media_router/test/android/cast_emulator/BUILD.gn
index 14be15c521c..62f60b3e7a6 100644
--- a/chromium/components/media_router/test/android/cast_emulator/BUILD.gn
+++ b/chromium/components/media_router/test/android/cast_emulator/BUILD.gn
@@ -22,7 +22,6 @@ android_library("cast_emulator_java") {
deps = [
"$google_play_services_package:google_play_services_cast_java",
"//base:base_java",
- "//third_party/android_deps:android_support_v7_appcompat_java",
"//third_party/androidx:androidx_mediarouter_mediarouter_java",
]
}