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 #include "chrome/browser/ui/ash/cast_config_delegate_chromeos.h" | 5 #include "chrome/browser/ui/ash/cast_config_delegate_chromeos.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 |
| 9 #include <memory> |
8 #include <string> | 10 #include <string> |
9 #include <utility> | 11 #include <utility> |
10 | 12 |
11 #include "base/macros.h" | 13 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/browser/extensions/api/cast_devices_private/cast_devices_privat
e_api.h" | 15 #include "chrome/browser/extensions/api/cast_devices_private/cast_devices_privat
e_api.h" |
15 #include "chrome/browser/extensions/api/tab_capture/tab_capture_api.h" | 16 #include "chrome/browser/extensions/api/tab_capture/tab_capture_api.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/browser/ui/browser_navigator.h" | 18 #include "chrome/browser/ui/browser_navigator.h" |
18 #include "chrome/browser/ui/browser_navigator_params.h" | 19 #include "chrome/browser/ui/browser_navigator_params.h" |
19 #include "chrome/common/extensions/api/cast_devices_private.h" | 20 #include "chrome/common/extensions/api/cast_devices_private.h" |
20 #include "content/public/browser/browser_context.h" | 21 #include "content/public/browser/browser_context.h" |
21 #include "content/public/browser/render_frame_host.h" | 22 #include "content/public/browser/render_frame_host.h" |
22 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } | 60 } |
60 | 61 |
61 CastConfigDelegateChromeos::~CastConfigDelegateChromeos() { | 62 CastConfigDelegateChromeos::~CastConfigDelegateChromeos() { |
62 } | 63 } |
63 | 64 |
64 bool CastConfigDelegateChromeos::HasCastExtension() const { | 65 bool CastConfigDelegateChromeos::HasCastExtension() const { |
65 return FindCastExtension() != nullptr; | 66 return FindCastExtension() != nullptr; |
66 } | 67 } |
67 | 68 |
68 void CastConfigDelegateChromeos::RequestDeviceRefresh() { | 69 void CastConfigDelegateChromeos::RequestDeviceRefresh() { |
69 scoped_ptr<base::ListValue> args = | 70 std::unique_ptr<base::ListValue> args = |
70 extensions::api::cast_devices_private::UpdateDevicesRequested::Create(); | 71 extensions::api::cast_devices_private::UpdateDevicesRequested::Create(); |
71 scoped_ptr<extensions::Event> event(new extensions::Event( | 72 std::unique_ptr<extensions::Event> event(new extensions::Event( |
72 extensions::events::CAST_DEVICES_PRIVATE_ON_UPDATE_DEVICES_REQUESTED, | 73 extensions::events::CAST_DEVICES_PRIVATE_ON_UPDATE_DEVICES_REQUESTED, |
73 extensions::api::cast_devices_private::UpdateDevicesRequested::kEventName, | 74 extensions::api::cast_devices_private::UpdateDevicesRequested::kEventName, |
74 std::move(args))); | 75 std::move(args))); |
75 extensions::EventRouter::Get(GetProfile()) | 76 extensions::EventRouter::Get(GetProfile()) |
76 ->DispatchEventToExtension(FindCastExtension()->id(), std::move(event)); | 77 ->DispatchEventToExtension(FindCastExtension()->id(), std::move(event)); |
77 } | 78 } |
78 | 79 |
79 void CastConfigDelegateChromeos::CastToReceiver( | 80 void CastConfigDelegateChromeos::CastToReceiver( |
80 const std::string& receiver_id) { | 81 const std::string& receiver_id) { |
81 scoped_ptr<base::ListValue> args = | 82 std::unique_ptr<base::ListValue> args = |
82 extensions::api::cast_devices_private::StartCast::Create(receiver_id); | 83 extensions::api::cast_devices_private::StartCast::Create(receiver_id); |
83 scoped_ptr<extensions::Event> event(new extensions::Event( | 84 std::unique_ptr<extensions::Event> event(new extensions::Event( |
84 extensions::events::CAST_DEVICES_PRIVATE_ON_START_CAST, | 85 extensions::events::CAST_DEVICES_PRIVATE_ON_START_CAST, |
85 extensions::api::cast_devices_private::StartCast::kEventName, | 86 extensions::api::cast_devices_private::StartCast::kEventName, |
86 std::move(args))); | 87 std::move(args))); |
87 extensions::EventRouter::Get(GetProfile()) | 88 extensions::EventRouter::Get(GetProfile()) |
88 ->DispatchEventToExtension(FindCastExtension()->id(), std::move(event)); | 89 ->DispatchEventToExtension(FindCastExtension()->id(), std::move(event)); |
89 } | 90 } |
90 | 91 |
91 void CastConfigDelegateChromeos::StopCasting(const std::string& activity_id) { | 92 void CastConfigDelegateChromeos::StopCasting(const std::string& activity_id) { |
92 scoped_ptr<base::ListValue> args = | 93 std::unique_ptr<base::ListValue> args = |
93 extensions::api::cast_devices_private::StopCast::Create("user-stop"); | 94 extensions::api::cast_devices_private::StopCast::Create("user-stop"); |
94 scoped_ptr<extensions::Event> event(new extensions::Event( | 95 std::unique_ptr<extensions::Event> event(new extensions::Event( |
95 extensions::events::CAST_DEVICES_PRIVATE_ON_STOP_CAST, | 96 extensions::events::CAST_DEVICES_PRIVATE_ON_STOP_CAST, |
96 extensions::api::cast_devices_private::StopCast::kEventName, | 97 extensions::api::cast_devices_private::StopCast::kEventName, |
97 std::move(args))); | 98 std::move(args))); |
98 extensions::EventRouter::Get(GetProfile()) | 99 extensions::EventRouter::Get(GetProfile()) |
99 ->DispatchEventToExtension(FindCastExtension()->id(), std::move(event)); | 100 ->DispatchEventToExtension(FindCastExtension()->id(), std::move(event)); |
100 } | 101 } |
101 | 102 |
102 bool CastConfigDelegateChromeos::HasOptions() const { | 103 bool CastConfigDelegateChromeos::HasOptions() const { |
103 return true; | 104 return true; |
104 } | 105 } |
(...skipping 14 matching lines...) Expand all Loading... |
119 ->AddObserver(observer); | 120 ->AddObserver(observer); |
120 } | 121 } |
121 | 122 |
122 void CastConfigDelegateChromeos::RemoveObserver( | 123 void CastConfigDelegateChromeos::RemoveObserver( |
123 ash::CastConfigDelegate::Observer* observer) { | 124 ash::CastConfigDelegate::Observer* observer) { |
124 return extensions::CastDeviceUpdateListeners::Get(GetProfile()) | 125 return extensions::CastDeviceUpdateListeners::Get(GetProfile()) |
125 ->RemoveObserver(observer); | 126 ->RemoveObserver(observer); |
126 } | 127 } |
127 | 128 |
128 } // namespace chromeos | 129 } // namespace chromeos |
OLD | NEW |