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

Unified Diff: chrome/browser/ui/webui/inspect_ui.cc

Issue 2248133002: [DevTools] Add UI for adding remote targets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [DevTools] Add UI for adding remote targets Created 4 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/inspect_ui.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 991e1a68cacb0704ed773495fb8c9ec5162b4e27..3bc320dee722781b13e30aaf109b31ea844fdcec 100644
--- a/chrome/browser/ui/webui/inspect_ui.cc
+++ b/chrome/browser/ui/webui/inspect_ui.cc
@@ -50,6 +50,9 @@ const char kDiscoverUsbDevicesEnabledCommand[] =
const char kPortForwardingEnabledCommand[] =
"set-port-forwarding-enabled";
const char kPortForwardingConfigCommand[] = "set-port-forwarding-config";
+const char kDiscoverTCPTargetsEnabledCommand[] =
+ "set-discover-tcp-targets-enabled";
+const char kTCPDiscoveryConfigCommand[] = "set-tcp-discovery-config";
const char kPortForwardingDefaultPort[] = "8080";
const char kPortForwardingDefaultLocation[] = "localhost:8080";
@@ -76,6 +79,7 @@ class InspectMessageHandler : public WebUIMessageHandler {
void HandleBooleanPrefChanged(const char* pref_name,
const base::ListValue* args);
void HandlePortForwardingConfigCommand(const base::ListValue* args);
+ void HandleTCPDiscoveryConfigCommand(const base::ListValue* args);
InspectUI* inspect_ui_;
@@ -106,6 +110,13 @@ void InspectMessageHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(kPortForwardingConfigCommand,
base::Bind(&InspectMessageHandler::HandlePortForwardingConfigCommand,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(kDiscoverTCPTargetsEnabledCommand,
+ base::Bind(&InspectMessageHandler::HandleBooleanPrefChanged,
+ base::Unretained(this),
+ &prefs::kDevToolsDiscoverTCPTargetsEnabled[0]));
+ web_ui()->RegisterMessageCallback(kTCPDiscoveryConfigCommand,
+ base::Bind(&InspectMessageHandler::HandleTCPDiscoveryConfigCommand,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(kReloadCommand,
base::Bind(&InspectMessageHandler::HandleReloadCommand,
base::Unretained(this)));
@@ -201,6 +212,17 @@ void InspectMessageHandler::HandlePortForwardingConfigCommand(
profile->GetPrefs()->Set(prefs::kDevToolsPortForwardingConfig, *dict_src);
}
+void InspectMessageHandler::HandleTCPDiscoveryConfigCommand(
+ 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::kDevToolsTCPDiscoveryConfig, *list_src);
+}
+
// DevToolsUIBindingsEnabler ----------------------------------------
class DevToolsUIBindingsEnabler
@@ -272,6 +294,8 @@ void InspectUI::InitUI() {
UpdateDiscoverUsbDevicesEnabled();
UpdatePortForwardingEnabled();
UpdatePortForwardingConfig();
+ UpdateTCPDiscoveryEnabled();
+ UpdateTCPDiscoveryConfig();
}
void InspectUI::Inspect(const std::string& source_id,
@@ -410,6 +434,12 @@ void InspectUI::StartListeningNotifications() {
pref_change_registrar_.Add(prefs::kDevToolsPortForwardingConfig,
base::Bind(&InspectUI::UpdatePortForwardingConfig,
base::Unretained(this)));
+ pref_change_registrar_.Add(prefs::kDevToolsDiscoverTCPTargetsEnabled,
+ base::Bind(&InspectUI::UpdateTCPDiscoveryEnabled,
+ base::Unretained(this)));
+ pref_change_registrar_.Add(prefs::kDevToolsTCPDiscoveryConfig,
+ base::Bind(&InspectUI::UpdateTCPDiscoveryConfig,
+ base::Unretained(this)));
}
void InspectUI::StopListeningNotifications() {
@@ -451,6 +481,18 @@ void InspectUI::UpdatePortForwardingConfig() {
*GetPrefValue(prefs::kDevToolsPortForwardingConfig));
}
+void InspectUI::UpdateTCPDiscoveryEnabled() {
+ web_ui()->CallJavascriptFunctionUnsafe(
+ "updateTCPDiscoveryEnabled",
+ *GetPrefValue(prefs::kDevToolsDiscoverTCPTargetsEnabled));
+}
+
+void InspectUI::UpdateTCPDiscoveryConfig() {
+ web_ui()->CallJavascriptFunctionUnsafe(
+ "updateTCPDiscoveryConfig",
+ *GetPrefValue(prefs::kDevToolsTCPDiscoveryConfig));
+}
+
void InspectUI::SetPortForwardingDefaults() {
Profile* profile = Profile::FromWebUI(web_ui());
PrefService* prefs = profile->GetPrefs();
« no previous file with comments | « chrome/browser/ui/webui/inspect_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698