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

Side by Side Diff: chrome/browser/ui/webui/inspect_ui.cc

Issue 2502863002: Add UI DevTools under chrome://inspect/#other (Closed)
Patch Set: Add ui_devtools to BUILD file Created 4 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/inspect_ui.h" 5 #include "chrome/browser/ui/webui/inspect_ui.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "chrome/browser/devtools/devtools_targets_ui.h" 9 #include "chrome/browser/devtools/devtools_targets_ui.h"
10 #include "chrome/browser/devtools/devtools_ui_bindings.h" 10 #include "chrome/browser/devtools/devtools_ui_bindings.h"
(...skipping 21 matching lines...) Expand all
32 #include "content/public/common/frame_navigate_params.h" 32 #include "content/public/common/frame_navigate_params.h"
33 33
34 using content::DevToolsAgentHost; 34 using content::DevToolsAgentHost;
35 using content::WebContents; 35 using content::WebContents;
36 using content::WebUIMessageHandler; 36 using content::WebUIMessageHandler;
37 37
38 namespace { 38 namespace {
39 39
40 const char kInitUICommand[] = "init-ui"; 40 const char kInitUICommand[] = "init-ui";
41 const char kInspectCommand[] = "inspect"; 41 const char kInspectCommand[] = "inspect";
42 const char kInspectUiCommand[] = "inspect-ui";
dgozman 2016/11/15 23:47:08 inspect-additional
Sarmad Hashmi 2016/11/16 01:42:57 Done.
42 const char kActivateCommand[] = "activate"; 43 const char kActivateCommand[] = "activate";
43 const char kCloseCommand[] = "close"; 44 const char kCloseCommand[] = "close";
44 const char kReloadCommand[] = "reload"; 45 const char kReloadCommand[] = "reload";
45 const char kOpenCommand[] = "open"; 46 const char kOpenCommand[] = "open";
46 const char kInspectBrowser[] = "inspect-browser"; 47 const char kInspectBrowser[] = "inspect-browser";
47 const char kLocalHost[] = "localhost"; 48 const char kLocalHost[] = "localhost";
48 49
49 const char kDiscoverUsbDevicesEnabledCommand[] = 50 const char kDiscoverUsbDevicesEnabledCommand[] =
50 "set-discover-usb-devices-enabled"; 51 "set-discover-usb-devices-enabled";
51 const char kPortForwardingEnabledCommand[] = 52 const char kPortForwardingEnabledCommand[] =
(...skipping 13 matching lines...) Expand all
65 explicit InspectMessageHandler(InspectUI* inspect_ui) 66 explicit InspectMessageHandler(InspectUI* inspect_ui)
66 : inspect_ui_(inspect_ui) {} 67 : inspect_ui_(inspect_ui) {}
67 ~InspectMessageHandler() override {} 68 ~InspectMessageHandler() override {}
68 69
69 private: 70 private:
70 // WebUIMessageHandler implementation. 71 // WebUIMessageHandler implementation.
71 void RegisterMessages() override; 72 void RegisterMessages() override;
72 73
73 void HandleInitUICommand(const base::ListValue* args); 74 void HandleInitUICommand(const base::ListValue* args);
74 void HandleInspectCommand(const base::ListValue* args); 75 void HandleInspectCommand(const base::ListValue* args);
76 void HandleInspectUiCommand(const base::ListValue* args);
75 void HandleActivateCommand(const base::ListValue* args); 77 void HandleActivateCommand(const base::ListValue* args);
76 void HandleCloseCommand(const base::ListValue* args); 78 void HandleCloseCommand(const base::ListValue* args);
77 void HandleReloadCommand(const base::ListValue* args); 79 void HandleReloadCommand(const base::ListValue* args);
78 void HandleOpenCommand(const base::ListValue* args); 80 void HandleOpenCommand(const base::ListValue* args);
79 void HandleInspectBrowserCommand(const base::ListValue* args); 81 void HandleInspectBrowserCommand(const base::ListValue* args);
80 void HandleBooleanPrefChanged(const char* pref_name, 82 void HandleBooleanPrefChanged(const char* pref_name,
81 const base::ListValue* args); 83 const base::ListValue* args);
82 void HandlePortForwardingConfigCommand(const base::ListValue* args); 84 void HandlePortForwardingConfigCommand(const base::ListValue* args);
83 void HandleTCPDiscoveryConfigCommand(const base::ListValue* args); 85 void HandleTCPDiscoveryConfigCommand(const base::ListValue* args);
84 86
85 InspectUI* inspect_ui_; 87 InspectUI* inspect_ui_;
86 88
87 DISALLOW_COPY_AND_ASSIGN(InspectMessageHandler); 89 DISALLOW_COPY_AND_ASSIGN(InspectMessageHandler);
88 }; 90 };
89 91
90 void InspectMessageHandler::RegisterMessages() { 92 void InspectMessageHandler::RegisterMessages() {
91 web_ui()->RegisterMessageCallback(kInitUICommand, 93 web_ui()->RegisterMessageCallback(kInitUICommand,
92 base::Bind(&InspectMessageHandler::HandleInitUICommand, 94 base::Bind(&InspectMessageHandler::HandleInitUICommand,
93 base::Unretained(this))); 95 base::Unretained(this)));
94 web_ui()->RegisterMessageCallback(kInspectCommand, 96 web_ui()->RegisterMessageCallback(kInspectCommand,
95 base::Bind(&InspectMessageHandler::HandleInspectCommand, 97 base::Bind(&InspectMessageHandler::HandleInspectCommand,
96 base::Unretained(this))); 98 base::Unretained(this)));
99 web_ui()->RegisterMessageCallback(
100 kInspectUiCommand,
101 base::Bind(&InspectMessageHandler::HandleInspectUiCommand,
102 base::Unretained(this)));
97 web_ui()->RegisterMessageCallback(kActivateCommand, 103 web_ui()->RegisterMessageCallback(kActivateCommand,
98 base::Bind(&InspectMessageHandler::HandleActivateCommand, 104 base::Bind(&InspectMessageHandler::HandleActivateCommand,
99 base::Unretained(this))); 105 base::Unretained(this)));
100 web_ui()->RegisterMessageCallback(kCloseCommand, 106 web_ui()->RegisterMessageCallback(kCloseCommand,
101 base::Bind(&InspectMessageHandler::HandleCloseCommand, 107 base::Bind(&InspectMessageHandler::HandleCloseCommand,
102 base::Unretained(this))); 108 base::Unretained(this)));
103 web_ui()->RegisterMessageCallback(kDiscoverUsbDevicesEnabledCommand, 109 web_ui()->RegisterMessageCallback(kDiscoverUsbDevicesEnabledCommand,
104 base::Bind(&InspectMessageHandler::HandleBooleanPrefChanged, 110 base::Bind(&InspectMessageHandler::HandleBooleanPrefChanged,
105 base::Unretained(this), 111 base::Unretained(this),
106 &prefs::kDevToolsDiscoverUsbDevicesEnabled[0])); 112 &prefs::kDevToolsDiscoverUsbDevicesEnabled[0]));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 (!arg2 || (arg_size > 2 && args->GetString(2, arg2))); 149 (!arg2 || (arg_size > 2 && args->GetString(2, arg2)));
144 } 150 }
145 151
146 void InspectMessageHandler::HandleInspectCommand(const base::ListValue* args) { 152 void InspectMessageHandler::HandleInspectCommand(const base::ListValue* args) {
147 std::string source; 153 std::string source;
148 std::string id; 154 std::string id;
149 if (ParseStringArgs(args, &source, &id)) 155 if (ParseStringArgs(args, &source, &id))
150 inspect_ui_->Inspect(source, id); 156 inspect_ui_->Inspect(source, id);
151 } 157 }
152 158
159 void InspectMessageHandler::HandleInspectUiCommand(
160 const base::ListValue* args) {
161 std::string url;
162 if (ParseStringArgs(args, &url, nullptr)) {
163 WebContents* inspect_ui = web_ui()->GetWebContents();
164 web_ui()->GetWebContents()->GetDelegate()->OpenURLFromTab(
165 inspect_ui,
166 content::OpenURLParams(GURL(url), content::Referrer(),
167 WindowOpenDisposition::NEW_FOREGROUND_TAB,
168 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false));
169 }
170 }
171
153 void InspectMessageHandler::HandleActivateCommand(const base::ListValue* args) { 172 void InspectMessageHandler::HandleActivateCommand(const base::ListValue* args) {
154 std::string source; 173 std::string source;
155 std::string id; 174 std::string id;
156 if (ParseStringArgs(args, &source, &id)) 175 if (ParseStringArgs(args, &source, &id))
157 inspect_ui_->Activate(source, id); 176 inspect_ui_->Activate(source, id);
158 } 177 }
159 178
160 void InspectMessageHandler::HandleCloseCommand(const base::ListValue* args) { 179 void InspectMessageHandler::HandleCloseCommand(const base::ListValue* args) {
161 std::string source; 180 std::string source;
162 std::string id; 181 std::string id;
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 handler->ForceUpdate(); 587 handler->ForceUpdate();
569 } 588 }
570 589
571 void InspectUI::PopulatePortStatus(const base::Value& status) { 590 void InspectUI::PopulatePortStatus(const base::Value& status) {
572 web_ui()->CallJavascriptFunctionUnsafe("populatePortStatus", status); 591 web_ui()->CallJavascriptFunctionUnsafe("populatePortStatus", status);
573 } 592 }
574 593
575 void InspectUI::ShowIncognitoWarning() { 594 void InspectUI::ShowIncognitoWarning() {
576 web_ui()->CallJavascriptFunctionUnsafe("showIncognitoWarning"); 595 web_ui()->CallJavascriptFunctionUnsafe("showIncognitoWarning");
577 } 596 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698