| Index: chrome/browser/ui/webui/inspect_ui.cc
|
| diff --git a/chrome/browser/ui/webui/inspect_ui.cc b/chrome/browser/ui/webui/inspect_ui.cc
|
| index 18c88bd5d45f6a70df42ec5855b4af5a0d1fac28..5230a909cae35bdbc0c3e4629b6f5faaa211f3aa 100644
|
| --- a/chrome/browser/ui/webui/inspect_ui.cc
|
| +++ b/chrome/browser/ui/webui/inspect_ui.cc
|
| @@ -50,6 +50,7 @@ const char kDiscoverUsbDevicesEnabledCommand[] =
|
| const char kPortForwardingEnabledCommand[] =
|
| "set-port-forwarding-enabled";
|
| const char kPortForwardingConfigCommand[] = "set-port-forwarding-config";
|
| +const char kTargetDiscoveryConfigCommand[] = "set-target-discovery-config";
|
|
|
| const char kPortForwardingDefaultPort[] = "8080";
|
| const char kPortForwardingDefaultLocation[] = "localhost:8080";
|
| @@ -76,6 +77,7 @@ class InspectMessageHandler : public WebUIMessageHandler {
|
| void HandleBooleanPrefChanged(const char* pref_name,
|
| const base::ListValue* args);
|
| void HandlePortForwardingConfigCommand(const base::ListValue* args);
|
| + void HandleTargetDiscoveryConfigCommand(const base::ListValue* args);
|
|
|
| InspectUI* inspect_ui_;
|
|
|
| @@ -106,6 +108,9 @@ void InspectMessageHandler::RegisterMessages() {
|
| web_ui()->RegisterMessageCallback(kPortForwardingConfigCommand,
|
| base::Bind(&InspectMessageHandler::HandlePortForwardingConfigCommand,
|
| base::Unretained(this)));
|
| + web_ui()->RegisterMessageCallback(kTargetDiscoveryConfigCommand,
|
| + base::Bind(&InspectMessageHandler::HandleTargetDiscoveryConfigCommand,
|
| + base::Unretained(this)));
|
| web_ui()->RegisterMessageCallback(kReloadCommand,
|
| base::Bind(&InspectMessageHandler::HandleReloadCommand,
|
| base::Unretained(this)));
|
| @@ -201,6 +206,17 @@ void InspectMessageHandler::HandlePortForwardingConfigCommand(
|
| profile->GetPrefs()->Set(prefs::kDevToolsPortForwardingConfig, *dict_src);
|
| }
|
|
|
| +void InspectMessageHandler::HandleTargetDiscoveryConfigCommand(
|
| + const base::ListValue* args) {
|
| + Profile* profile = Profile::FromWebUI(web_ui());
|
| + if (!profile)
|
| + return;
|
| +
|
| + const base::ListValue* list_src;
|
| + if (args->GetSize() == 1 && args->GetList(0, &list_src))
|
| + profile->GetPrefs()->Set(prefs::kDevToolsTargetDiscoveryConfig, *list_src);
|
| +}
|
| +
|
| // DevToolsUIBindingsEnabler ----------------------------------------
|
|
|
| class DevToolsUIBindingsEnabler
|
| @@ -272,6 +288,7 @@ void InspectUI::InitUI() {
|
| UpdateDiscoverUsbDevicesEnabled();
|
| UpdatePortForwardingEnabled();
|
| UpdatePortForwardingConfig();
|
| + UpdateTargetDiscoveryConfig();
|
| }
|
|
|
| void InspectUI::Inspect(const std::string& source_id,
|
| @@ -410,6 +427,9 @@ void InspectUI::StartListeningNotifications() {
|
| pref_change_registrar_.Add(prefs::kDevToolsPortForwardingConfig,
|
| base::Bind(&InspectUI::UpdatePortForwardingConfig,
|
| base::Unretained(this)));
|
| + pref_change_registrar_.Add(prefs::kDevToolsTargetDiscoveryConfig,
|
| + base::Bind(&InspectUI::UpdateTargetDiscoveryConfig,
|
| + base::Unretained(this)));
|
| }
|
|
|
| void InspectUI::StopListeningNotifications() {
|
| @@ -451,6 +471,12 @@ void InspectUI::UpdatePortForwardingConfig() {
|
| *GetPrefValue(prefs::kDevToolsPortForwardingConfig));
|
| }
|
|
|
| +void InspectUI::UpdateTargetDiscoveryConfig() {
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| + "updateTargetDiscoveryConfig",
|
| + *GetPrefValue(prefs::kDevToolsTargetDiscoveryConfig));
|
| +}
|
| +
|
| void InspectUI::SetPortForwardingDefaults() {
|
| Profile* profile = Profile::FromWebUI(web_ui());
|
| PrefService* prefs = profile->GetPrefs();
|
|
|