| 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/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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 dictionary->SetString("title", issue.title()); | 203 dictionary->SetString("title", issue.title()); |
| 204 dictionary->SetString("message", issue.message()); | 204 dictionary->SetString("message", issue.message()); |
| 205 dictionary->SetInteger("defaultActionType", issue.default_action().type()); | 205 dictionary->SetInteger("defaultActionType", issue.default_action().type()); |
| 206 if (!issue.secondary_actions().empty()) { | 206 if (!issue.secondary_actions().empty()) { |
| 207 dictionary->SetInteger("secondaryActionType", | 207 dictionary->SetInteger("secondaryActionType", |
| 208 issue.secondary_actions().begin()->type()); | 208 issue.secondary_actions().begin()->type()); |
| 209 } | 209 } |
| 210 if (!issue.route_id().empty()) | 210 if (!issue.route_id().empty()) |
| 211 dictionary->SetString("routeId", issue.route_id()); | 211 dictionary->SetString("routeId", issue.route_id()); |
| 212 dictionary->SetBoolean("isBlocking", issue.is_blocking()); | 212 dictionary->SetBoolean("isBlocking", issue.is_blocking()); |
| 213 if (issue.help_page_id() > 0) |
| 214 dictionary->SetInteger("helpPageId", issue.help_page_id()); |
| 213 | 215 |
| 214 return dictionary; | 216 return dictionary; |
| 215 } | 217 } |
| 216 | 218 |
| 217 bool IsValidIssueActionTypeNum(int issue_action_type_num) { | 219 bool IsValidIssueActionTypeNum(int issue_action_type_num) { |
| 218 return issue_action_type_num >= 0 && | 220 return issue_action_type_num >= 0 && |
| 219 issue_action_type_num < IssueAction::TYPE_MAX; | 221 issue_action_type_num < IssueAction::TYPE_MAX; |
| 220 } | 222 } |
| 221 | 223 |
| 222 // Composes a "learn more" URL. The URL depends on template arguments in |args|. | 224 // Composes a "learn more" URL. The URL depends on template arguments in |args|. |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 } | 462 } |
| 461 | 463 |
| 462 MediaRouterUI* media_router_ui = | 464 MediaRouterUI* media_router_ui = |
| 463 static_cast<MediaRouterUI*>(web_ui()->GetController()); | 465 static_cast<MediaRouterUI*>(web_ui()->GetController()); |
| 464 if (media_router_ui->HasPendingRouteRequest()) { | 466 if (media_router_ui->HasPendingRouteRequest()) { |
| 465 DVLOG(1) << "UI already has pending route request. Ignoring."; | 467 DVLOG(1) << "UI already has pending route request. Ignoring."; |
| 466 Issue issue( | 468 Issue issue( |
| 467 l10n_util::GetStringUTF8(IDS_MEDIA_ROUTER_ISSUE_PENDING_ROUTE), | 469 l10n_util::GetStringUTF8(IDS_MEDIA_ROUTER_ISSUE_PENDING_ROUTE), |
| 468 std::string(), IssueAction(IssueAction::TYPE_DISMISS), | 470 std::string(), IssueAction(IssueAction::TYPE_DISMISS), |
| 469 std::vector<IssueAction>(), std::string(), Issue::NOTIFICATION, | 471 std::vector<IssueAction>(), std::string(), Issue::NOTIFICATION, |
| 470 false, std::string()); | 472 false, -1); |
| 471 media_router_ui_->AddIssue(issue); | 473 media_router_ui_->AddIssue(issue); |
| 472 return; | 474 return; |
| 473 } | 475 } |
| 474 | 476 |
| 475 DVLOG(2) << __FUNCTION__ << ": sink id: " << sink_id | 477 DVLOG(2) << __FUNCTION__ << ": sink id: " << sink_id |
| 476 << ", cast mode: " << cast_mode_num; | 478 << ", cast mode: " << cast_mode_num; |
| 477 | 479 |
| 478 // TODO(haibinlu): Pass additional parameters into the CreateRoute request, | 480 // TODO(haibinlu): Pass additional parameters into the CreateRoute request, |
| 479 // e.g. low-fps-mirror, user-override. (crbug.com/490364) | 481 // e.g. low-fps-mirror, user-override. (crbug.com/490364) |
| 480 if (!media_router_ui->CreateRoute( | 482 if (!media_router_ui->CreateRoute( |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 } | 555 } |
| 554 | 556 |
| 555 MediaRouterUI* media_router_ui = | 557 MediaRouterUI* media_router_ui = |
| 556 static_cast<MediaRouterUI*>(web_ui()->GetController()); | 558 static_cast<MediaRouterUI*>(web_ui()->GetController()); |
| 557 if (media_router_ui->HasPendingRouteRequest()) { | 559 if (media_router_ui->HasPendingRouteRequest()) { |
| 558 DVLOG(1) << "UI already has pending route request. Ignoring."; | 560 DVLOG(1) << "UI already has pending route request. Ignoring."; |
| 559 Issue issue( | 561 Issue issue( |
| 560 l10n_util::GetStringUTF8(IDS_MEDIA_ROUTER_ISSUE_PENDING_ROUTE), | 562 l10n_util::GetStringUTF8(IDS_MEDIA_ROUTER_ISSUE_PENDING_ROUTE), |
| 561 std::string(), IssueAction(IssueAction::TYPE_DISMISS), | 563 std::string(), IssueAction(IssueAction::TYPE_DISMISS), |
| 562 std::vector<IssueAction>(), std::string(), Issue::NOTIFICATION, | 564 std::vector<IssueAction>(), std::string(), Issue::NOTIFICATION, |
| 563 false, std::string()); | 565 false, -1); |
| 564 media_router_ui_->AddIssue(issue); | 566 media_router_ui_->AddIssue(issue); |
| 565 return; | 567 return; |
| 566 } | 568 } |
| 567 | 569 |
| 568 if (!media_router_ui_->ConnectRoute(sink_id, route_id)) { | 570 if (!media_router_ui_->ConnectRoute(sink_id, route_id)) { |
| 569 DVLOG(1) << "Error initiating route join request."; | 571 DVLOG(1) << "Error initiating route join request."; |
| 570 } | 572 } |
| 571 } | 573 } |
| 572 | 574 |
| 573 void MediaRouterWebUIMessageHandler::OnCloseRoute(const base::ListValue* args) { | 575 void MediaRouterWebUIMessageHandler::OnCloseRoute(const base::ListValue* args) { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 #endif // defined(GOOGLE_CHROME_BUILD) | 868 #endif // defined(GOOGLE_CHROME_BUILD) |
| 867 | 869 |
| 868 return AccountInfo(); | 870 return AccountInfo(); |
| 869 } | 871 } |
| 870 | 872 |
| 871 void MediaRouterWebUIMessageHandler::SetWebUIForTest(content::WebUI* web_ui) { | 873 void MediaRouterWebUIMessageHandler::SetWebUIForTest(content::WebUI* web_ui) { |
| 872 set_web_ui(web_ui); | 874 set_web_ui(web_ui); |
| 873 } | 875 } |
| 874 | 876 |
| 875 } // namespace media_router | 877 } // namespace media_router |
| OLD | NEW |