Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: chrome/browser/ui/webui/media_router/media_router_webui_message_handler.cc

Issue 1475843002: [MR] Add description field to MediaSink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/webui/media_router/media_router_webui_message_handle r.h" 5 #include "chrome/browser/ui/webui/media_router/media_router_webui_message_handle r.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 const std::vector<MediaSinkWithCastModes>& sinks) { 46 const std::vector<MediaSinkWithCastModes>& sinks) {
47 scoped_ptr<base::ListValue> value(new base::ListValue); 47 scoped_ptr<base::ListValue> value(new base::ListValue);
48 48
49 for (const MediaSinkWithCastModes& sink_with_cast_modes : sinks) { 49 for (const MediaSinkWithCastModes& sink_with_cast_modes : sinks) {
50 scoped_ptr<base::DictionaryValue> sink_val(new base::DictionaryValue); 50 scoped_ptr<base::DictionaryValue> sink_val(new base::DictionaryValue);
51 51
52 const MediaSink& sink = sink_with_cast_modes.sink; 52 const MediaSink& sink = sink_with_cast_modes.sink;
53 sink_val->SetString("id", sink.id()); 53 sink_val->SetString("id", sink.id());
54 sink_val->SetString("name", sink.name()); 54 sink_val->SetString("name", sink.name());
55 sink_val->SetInteger("iconType", sink.icon_type()); 55 sink_val->SetInteger("iconType", sink.icon_type());
56 if (!sink.description().empty())
57 sink_val->SetString("description", sink.description());
56 58
57 scoped_ptr<base::ListValue> cast_modes_val(new base::ListValue); 59 scoped_ptr<base::ListValue> cast_modes_val(new base::ListValue);
58 for (MediaCastMode cast_mode : sink_with_cast_modes.cast_modes) 60 for (MediaCastMode cast_mode : sink_with_cast_modes.cast_modes)
59 cast_modes_val->AppendInteger(cast_mode); 61 cast_modes_val->AppendInteger(cast_mode);
62
apacible 2015/12/02 23:27:26 Were the new lines here and below added/deleted ju
imcheng 2015/12/03 23:11:07 Yes. I find new line after indented statement help
60 sink_val->Set("castModes", cast_modes_val.Pass()); 63 sink_val->Set("castModes", cast_modes_val.Pass());
61
62 value->Append(sink_val.release()); 64 value->Append(sink_val.release());
63 } 65 }
64 66
65 return value.Pass(); 67 return value.Pass();
66 } 68 }
67 69
68 scoped_ptr<base::DictionaryValue> RouteToValue( 70 scoped_ptr<base::DictionaryValue> RouteToValue(
69 const MediaRoute& route, const std::string& extension_id) { 71 const MediaRoute& route, const std::string& extension_id) {
70 scoped_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue); 72 scoped_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue);
71
72 dictionary->SetString("id", route.media_route_id()); 73 dictionary->SetString("id", route.media_route_id());
73 dictionary->SetString("sinkId", route.media_sink_id()); 74 dictionary->SetString("sinkId", route.media_sink_id());
74 dictionary->SetString("description", route.description()); 75 dictionary->SetString("description", route.description());
75 dictionary->SetBoolean("isLocal", route.is_local()); 76 dictionary->SetBoolean("isLocal", route.is_local());
76 77
77 const std::string& custom_path = route.custom_controller_path(); 78 const std::string& custom_path = route.custom_controller_path();
78
79 if (!custom_path.empty()) { 79 if (!custom_path.empty()) {
80 std::string full_custom_controller_path = base::StringPrintf("%s://%s/%s", 80 std::string full_custom_controller_path = base::StringPrintf("%s://%s/%s",
81 extensions::kExtensionScheme, extension_id.c_str(), 81 extensions::kExtensionScheme, extension_id.c_str(),
82 custom_path.c_str()); 82 custom_path.c_str());
83 DCHECK(GURL(full_custom_controller_path).is_valid()); 83 DCHECK(GURL(full_custom_controller_path).is_valid());
84 dictionary->SetString("customControllerPath", 84 dictionary->SetString("customControllerPath",
85 full_custom_controller_path); 85 full_custom_controller_path);
86 } 86 }
87 87
88 return dictionary.Pass(); 88 return dictionary.Pass();
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 open_args->AppendString(learn_more_url); 406 open_args->AppendString(learn_more_url);
407 web_ui()->CallJavascriptFunction(kWindowOpen, *open_args); 407 web_ui()->CallJavascriptFunction(kWindowOpen, *open_args);
408 return true; 408 return true;
409 } else { 409 } else {
410 // Do nothing; no other issue action types require any other action. 410 // Do nothing; no other issue action types require any other action.
411 return true; 411 return true;
412 } 412 }
413 } 413 }
414 414
415 } // namespace media_router 415 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698