| OLD | NEW |
| 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 | 406 |
| 407 DevToolsUIBindings::DevToolsUIBindings(content::WebContents* web_contents) | 407 DevToolsUIBindings::DevToolsUIBindings(content::WebContents* web_contents) |
| 408 : profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), | 408 : profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), |
| 409 android_bridge_(DevToolsAndroidBridge::Factory::GetForProfile(profile_)), | 409 android_bridge_(DevToolsAndroidBridge::Factory::GetForProfile(profile_)), |
| 410 web_contents_(web_contents), | 410 web_contents_(web_contents), |
| 411 delegate_(new DefaultBindingsDelegate(web_contents_)), | 411 delegate_(new DefaultBindingsDelegate(web_contents_)), |
| 412 device_count_updates_enabled_(false), | 412 device_count_updates_enabled_(false), |
| 413 devices_updates_enabled_(false), | 413 devices_updates_enabled_(false), |
| 414 frontend_loaded_(false), | 414 frontend_loaded_(false), |
| 415 weak_factory_(this) { | 415 weak_factory_(this) { |
| 416 DCHECK(android_bridge_); | |
| 417 g_instances.Get().push_back(this); | 416 g_instances.Get().push_back(this); |
| 418 frontend_contents_observer_.reset(new FrontendWebContentsObserver(this)); | 417 frontend_contents_observer_.reset(new FrontendWebContentsObserver(this)); |
| 419 web_contents_->GetMutableRendererPrefs()->can_accept_load_drops = false; | 418 web_contents_->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 420 | 419 |
| 421 file_helper_.reset(new DevToolsFileHelper(web_contents_, profile_)); | 420 file_helper_.reset(new DevToolsFileHelper(web_contents_, profile_)); |
| 422 file_system_indexer_ = new DevToolsFileSystemIndexer(); | 421 file_system_indexer_ = new DevToolsFileSystemIndexer(); |
| 423 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( | 422 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( |
| 424 web_contents_); | 423 web_contents_); |
| 425 | 424 |
| 426 // Wipe out page icon so that the default application icon is used. | 425 // Wipe out page icon so that the default application icon is used. |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 void DevToolsUIBindings::RecordActionUMA(const std::string& name, int action) { | 776 void DevToolsUIBindings::RecordActionUMA(const std::string& name, int action) { |
| 778 if (name == kDevToolsActionTakenHistogram) | 777 if (name == kDevToolsActionTakenHistogram) |
| 779 UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsActionTakenBoundary); | 778 UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsActionTakenBoundary); |
| 780 else if (name == kDevToolsPanelShownHistogram) | 779 else if (name == kDevToolsPanelShownHistogram) |
| 781 UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsPanelShownBoundary); | 780 UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsPanelShownBoundary); |
| 782 } | 781 } |
| 783 | 782 |
| 784 void DevToolsUIBindings::SendJsonRequest(const DispatchCallback& callback, | 783 void DevToolsUIBindings::SendJsonRequest(const DispatchCallback& callback, |
| 785 const std::string& browser_id, | 784 const std::string& browser_id, |
| 786 const std::string& url) { | 785 const std::string& url) { |
| 786 if (!android_bridge_) { |
| 787 callback.Run(nullptr); |
| 788 return; |
| 789 } |
| 787 android_bridge_->SendJsonRequest(browser_id, url, | 790 android_bridge_->SendJsonRequest(browser_id, url, |
| 788 base::Bind(&DevToolsUIBindings::JsonReceived, | 791 base::Bind(&DevToolsUIBindings::JsonReceived, |
| 789 weak_factory_.GetWeakPtr(), | 792 weak_factory_.GetWeakPtr(), |
| 790 callback)); | 793 callback)); |
| 791 } | 794 } |
| 792 | 795 |
| 793 void DevToolsUIBindings::JsonReceived(const DispatchCallback& callback, | 796 void DevToolsUIBindings::JsonReceived(const DispatchCallback& callback, |
| 794 int result, | 797 int result, |
| 795 const std::string& message) { | 798 const std::string& message) { |
| 796 if (result != net::OK) { | 799 if (result != net::OK) { |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 if (frontend_loaded_) | 1041 if (frontend_loaded_) |
| 1039 return; | 1042 return; |
| 1040 frontend_loaded_ = true; | 1043 frontend_loaded_ = true; |
| 1041 | 1044 |
| 1042 // Call delegate first - it seeds importants bit of information. | 1045 // Call delegate first - it seeds importants bit of information. |
| 1043 delegate_->OnLoadCompleted(); | 1046 delegate_->OnLoadCompleted(); |
| 1044 | 1047 |
| 1045 UpdateTheme(); | 1048 UpdateTheme(); |
| 1046 AddDevToolsExtensionsToClient(); | 1049 AddDevToolsExtensionsToClient(); |
| 1047 } | 1050 } |
| OLD | NEW |