OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ |
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
11 #include <map> | 11 #include <map> |
12 #include <set> | 12 #include <set> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/containers/hash_tables.h" | 16 #include "base/containers/hash_tables.h" |
17 #include "base/containers/scoped_ptr_hash_map.h" | 17 #include "base/containers/scoped_ptr_hash_map.h" |
18 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
22 #include "base/observer_list.h" | 22 #include "base/observer_list.h" |
23 #include "base/thread_task_runner_handle.h" | 23 #include "base/thread_task_runner_handle.h" |
| 24 #include "build/build_config.h" |
24 #include "chrome/browser/media/router/issue.h" | 25 #include "chrome/browser/media/router/issue.h" |
25 #include "chrome/browser/media/router/issue_manager.h" | 26 #include "chrome/browser/media/router/issue_manager.h" |
26 #include "chrome/browser/media/router/media_router.mojom.h" | 27 #include "chrome/browser/media/router/media_router.mojom.h" |
27 #include "chrome/browser/media/router/media_router_base.h" | 28 #include "chrome/browser/media/router/media_router_base.h" |
28 #include "chrome/browser/media/router/media_routes_observer.h" | 29 #include "chrome/browser/media/router/media_routes_observer.h" |
29 #include "mojo/public/cpp/bindings/binding.h" | 30 #include "mojo/public/cpp/bindings/binding.h" |
30 | 31 |
31 namespace content { | 32 namespace content { |
32 class BrowserContext; | 33 class BrowserContext; |
33 } | 34 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 void DetachRoute(const MediaRoute::Id& route_id) override; | 92 void DetachRoute(const MediaRoute::Id& route_id) override; |
92 void SendRouteMessage(const MediaRoute::Id& route_id, | 93 void SendRouteMessage(const MediaRoute::Id& route_id, |
93 const std::string& message, | 94 const std::string& message, |
94 const SendRouteMessageCallback& callback) override; | 95 const SendRouteMessageCallback& callback) override; |
95 void SendRouteBinaryMessage( | 96 void SendRouteBinaryMessage( |
96 const MediaRoute::Id& route_id, | 97 const MediaRoute::Id& route_id, |
97 scoped_ptr<std::vector<uint8_t>> data, | 98 scoped_ptr<std::vector<uint8_t>> data, |
98 const SendRouteMessageCallback& callback) override; | 99 const SendRouteMessageCallback& callback) override; |
99 void AddIssue(const Issue& issue) override; | 100 void AddIssue(const Issue& issue) override; |
100 void ClearIssue(const Issue::Id& issue_id) override; | 101 void ClearIssue(const Issue::Id& issue_id) override; |
| 102 void OnUserGesture() override; |
101 | 103 |
102 const std::string& media_route_provider_extension_id() const { | 104 const std::string& media_route_provider_extension_id() const { |
103 return media_route_provider_extension_id_; | 105 return media_route_provider_extension_id_; |
104 } | 106 } |
105 | 107 |
106 void set_instance_id_for_test(const std::string& instance_id) { | 108 void set_instance_id_for_test(const std::string& instance_id) { |
107 instance_id_ = instance_id; | 109 instance_id_ = instance_id; |
108 } | 110 } |
109 | 111 |
110 private: | 112 private: |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 void AttemptWakeEventPage(); | 315 void AttemptWakeEventPage(); |
314 | 316 |
315 // Sets the reason why we are attempting to wake the extension. Since | 317 // Sets the reason why we are attempting to wake the extension. Since |
316 // multiple tasks may be enqueued for execution each time the extension runs, | 318 // multiple tasks may be enqueued for execution each time the extension runs, |
317 // we record the first such reason. | 319 // we record the first such reason. |
318 void SetWakeReason(MediaRouteProviderWakeReason reason); | 320 void SetWakeReason(MediaRouteProviderWakeReason reason); |
319 | 321 |
320 // Clears the wake reason after the extension has been awoken. | 322 // Clears the wake reason after the extension has been awoken. |
321 void ClearWakeReason(); | 323 void ClearWakeReason(); |
322 | 324 |
| 325 #if defined(OS_WIN) |
| 326 // Ensures that mDNS discovery is enabled in the MRPM extension. This can be |
| 327 // called many times but the MRPM will only be called once per registration |
| 328 // period. |
| 329 void EnsureMdnsDiscoveryEnabled(); |
| 330 void DoEnsureMdnsDiscoveryEnabled(); |
| 331 |
| 332 // Callback used to enabled mDNS in the MRPM if a firewall prompt will not be |
| 333 // triggered. If a firewall prompt would be triggered, enabling mDNS won't |
| 334 // happen until the user is clearly interacting with MR. |
| 335 void OnFirewallCheckComplete(bool firewall_can_use_local_ports); |
| 336 #endif |
| 337 |
323 // Pending requests queued to be executed once component extension | 338 // Pending requests queued to be executed once component extension |
324 // becomes ready. | 339 // becomes ready. |
325 std::deque<base::Closure> pending_requests_; | 340 std::deque<base::Closure> pending_requests_; |
326 | 341 |
327 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaSinksQuery>> | 342 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaSinksQuery>> |
328 sinks_queries_; | 343 sinks_queries_; |
329 | 344 |
330 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaRoutesQuery>> | 345 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaRoutesQuery>> |
331 routes_queries_; | 346 routes_queries_; |
332 | 347 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 int wakeup_attempt_count_ = 0; | 389 int wakeup_attempt_count_ = 0; |
375 | 390 |
376 // Records the current reason the extension is being woken up. Is set to | 391 // Records the current reason the extension is being woken up. Is set to |
377 // MediaRouteProviderWakeReason::TOTAL_COUNT if there is no pending reason. | 392 // MediaRouteProviderWakeReason::TOTAL_COUNT if there is no pending reason. |
378 MediaRouteProviderWakeReason current_wake_reason_; | 393 MediaRouteProviderWakeReason current_wake_reason_; |
379 | 394 |
380 // A flag to ensure that we record the provider version once, during the | 395 // A flag to ensure that we record the provider version once, during the |
381 // initial event page wakeup attempt. | 396 // initial event page wakeup attempt. |
382 bool provider_version_was_recorded_ = false; | 397 bool provider_version_was_recorded_ = false; |
383 | 398 |
| 399 #if defined(OS_WIN) |
| 400 // A pair of flags to ensure that mDNS discovery is only enabled on Windows |
| 401 // when there will be appropriate context for the user to associate a firewall |
| 402 // prompt with Media Router. |should_enable_mdns_discovery_| can only go from |
| 403 // |false| to |true|. On Windows, |is_mdns_enabled_| is set to |false| in |
| 404 // RegisterMediaRouteProvider and only set to |true| when we successfully call |
| 405 // the extension to enable mDNS. |
| 406 bool is_mdns_enabled_ = false; |
| 407 bool should_enable_mdns_discovery_ = false; |
| 408 #endif |
| 409 |
384 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; | 410 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; |
385 | 411 |
386 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); | 412 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); |
387 }; | 413 }; |
388 | 414 |
389 } // namespace media_router | 415 } // namespace media_router |
390 | 416 |
391 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ | 417 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ |
OLD | NEW |