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/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 results.Append(extension_info); | 787 results.Append(extension_info); |
788 } | 788 } |
789 CallClientFunction("WebInspector.addExtensions", &results, NULL, NULL); | 789 CallClientFunction("WebInspector.addExtensions", &results, NULL, NULL); |
790 } | 790 } |
791 | 791 |
792 void DevToolsUIBindings::SetDelegate(Delegate* delegate) { | 792 void DevToolsUIBindings::SetDelegate(Delegate* delegate) { |
793 delegate_.reset(delegate); | 793 delegate_.reset(delegate); |
794 } | 794 } |
795 | 795 |
796 void DevToolsUIBindings::AttachTo(content::DevToolsAgentHost* agent_host) { | 796 void DevToolsUIBindings::AttachTo(content::DevToolsAgentHost* agent_host) { |
797 DCHECK(!agent_host_); | 797 if (agent_host_) |
| 798 Detach(); |
798 agent_host_ = agent_host; | 799 agent_host_ = agent_host; |
799 agent_host_->AttachClient(this); | 800 agent_host_->AttachClient(this); |
800 } | 801 } |
801 | 802 |
802 void DevToolsUIBindings::Reattach() { | 803 void DevToolsUIBindings::Reattach() { |
803 DCHECK(agent_host_); | 804 DCHECK(agent_host_); |
804 agent_host_->DetachClient(); | 805 agent_host_->DetachClient(); |
805 agent_host_->AttachClient(this); | 806 agent_host_->AttachClient(this); |
806 } | 807 } |
807 | 808 |
808 void DevToolsUIBindings::Detach() { | 809 void DevToolsUIBindings::Detach() { |
809 DCHECK(agent_host_); | 810 if (agent_host_) |
810 agent_host_->DetachClient(); | 811 agent_host_->DetachClient(); |
811 agent_host_ = NULL; | 812 agent_host_ = NULL; |
812 } | 813 } |
813 | 814 |
814 bool DevToolsUIBindings::IsAttachedTo(content::DevToolsAgentHost* agent_host) { | 815 bool DevToolsUIBindings::IsAttachedTo(content::DevToolsAgentHost* agent_host) { |
815 return agent_host_ == agent_host; | 816 return agent_host_ == agent_host; |
816 } | 817 } |
817 | 818 |
818 void DevToolsUIBindings::CallClientFunction(const std::string& function_name, | 819 void DevToolsUIBindings::CallClientFunction(const std::string& function_name, |
819 const base::Value* arg1, | 820 const base::Value* arg1, |
820 const base::Value* arg2, | 821 const base::Value* arg2, |
(...skipping 18 matching lines...) Expand all Loading... |
839 web_contents_->GetMainFrame()->ExecuteJavaScript(javascript); | 840 web_contents_->GetMainFrame()->ExecuteJavaScript(javascript); |
840 } | 841 } |
841 | 842 |
842 void DevToolsUIBindings::DocumentOnLoadCompletedInMainFrame() { | 843 void DevToolsUIBindings::DocumentOnLoadCompletedInMainFrame() { |
843 // Call delegate first - it seeds importants bit of information. | 844 // Call delegate first - it seeds importants bit of information. |
844 delegate_->OnLoadCompleted(); | 845 delegate_->OnLoadCompleted(); |
845 | 846 |
846 UpdateTheme(); | 847 UpdateTheme(); |
847 AddDevToolsExtensionsToClient(); | 848 AddDevToolsExtensionsToClient(); |
848 } | 849 } |
OLD | NEW |