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

Side by Side Diff: chrome/browser/devtools/devtools_ui_bindings.cc

Issue 912863002: [DevTools] Remote JSON requests from javascript (Chromium side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/devtools/devtools_ui_bindings.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/devtools/devtools_ui_bindings.h" 5 #include "chrome/browser/devtools/devtools_ui_bindings.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 agent_host_->DispatchProtocolMessage(message); 772 agent_host_->DispatchProtocolMessage(message);
773 } 773 }
774 774
775 void DevToolsUIBindings::RecordActionUMA(const std::string& name, int action) { 775 void DevToolsUIBindings::RecordActionUMA(const std::string& name, int action) {
776 if (name == kDevToolsActionTakenHistogram) 776 if (name == kDevToolsActionTakenHistogram)
777 UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsActionTakenBoundary); 777 UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsActionTakenBoundary);
778 else if (name == kDevToolsPanelShownHistogram) 778 else if (name == kDevToolsPanelShownHistogram)
779 UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsPanelShownBoundary); 779 UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsPanelShownBoundary);
780 } 780 }
781 781
782 void DevToolsUIBindings::SendJsonRequest(const DispatchCallback& callback,
783 const std::string& browser_id,
784 const std::string& url) {
785 remote_targets_handler_->SendJsonRequest(browser_id, url,
dgozman 2015/03/06 14:00:32 Use DevToolsAndroidBridge directly.
vkuzkokov 2015/03/11 16:34:03 Done.
786 base::Bind(&DevToolsUIBindings::JsonReceived,
787 weak_factory_.GetWeakPtr(),
788 callback));
789 }
790
791 void DevToolsUIBindings::JsonReceived(const DispatchCallback& callback,
792 int result,
793 const std::string& message) {
794 if (result != net::OK) {
795 callback.Run(nullptr);
796 return;
797 }
798 base::StringValue message_value(message);
799 callback.Run(&message_value);
800 }
801
782 void DevToolsUIBindings::OnURLFetchComplete(const net::URLFetcher* source) { 802 void DevToolsUIBindings::OnURLFetchComplete(const net::URLFetcher* source) {
783 DCHECK(source); 803 DCHECK(source);
784 PendingRequestsMap::iterator it = pending_requests_.find(source); 804 PendingRequestsMap::iterator it = pending_requests_.find(source);
785 DCHECK(it != pending_requests_.end()); 805 DCHECK(it != pending_requests_.end());
786 806
787 base::DictionaryValue response; 807 base::DictionaryValue response;
788 base::DictionaryValue* headers = new base::DictionaryValue(); 808 base::DictionaryValue* headers = new base::DictionaryValue();
789 net::HttpResponseHeaders* rh = source->GetResponseHeaders(); 809 net::HttpResponseHeaders* rh = source->GetResponseHeaders();
790 response.SetInteger("statusCode", rh ? rh->response_code() : 200); 810 response.SetInteger("statusCode", rh ? rh->response_code() : 200);
791 response.Set("headers", headers); 811 response.Set("headers", headers);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 if (frontend_loaded_) 1036 if (frontend_loaded_)
1017 return; 1037 return;
1018 frontend_loaded_ = true; 1038 frontend_loaded_ = true;
1019 1039
1020 // Call delegate first - it seeds importants bit of information. 1040 // Call delegate first - it seeds importants bit of information.
1021 delegate_->OnLoadCompleted(); 1041 delegate_->OnLoadCompleted();
1022 1042
1023 UpdateTheme(); 1043 UpdateTheme();
1024 AddDevToolsExtensionsToClient(); 1044 AddDevToolsExtensionsToClient();
1025 } 1045 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/devtools_ui_bindings.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698