| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/weak_ptr.h" | 6 #include "base/memory/weak_ptr.h" |
| 7 #include "mojo/application/application_runner_chromium.h" | 7 #include "mojo/application/application_runner_chromium.h" |
| 8 #include "mojo/public/c/system/main.h" | 8 #include "mojo/public/c/system/main.h" |
| 9 #include "mojo/public/cpp/application/application_delegate.h" | 9 #include "mojo/public/cpp/application/application_delegate.h" |
| 10 #include "mojo/public/cpp/application/application_impl.h" | 10 #include "mojo/public/cpp/application/application_impl.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 virtual bool ConfigureIncomingConnection( | 54 virtual bool ConfigureIncomingConnection( |
| 55 mojo::ApplicationConnection* connection) override { | 55 mojo::ApplicationConnection* connection) override { |
| 56 connection->ConnectToService(&debugger_); | 56 connection->ConnectToService(&debugger_); |
| 57 std::cout << "Loading " << url_ << std::endl; | 57 std::cout << "Loading " << url_ << std::endl; |
| 58 Reload(); | 58 Reload(); |
| 59 ScheduleWaitForInput(); | 59 ScheduleWaitForInput(); |
| 60 return true; | 60 return true; |
| 61 } | 61 } |
| 62 | 62 |
| 63 bool ExecuteCommand(const std::string& command) { | 63 bool ExecuteCommand(const std::string& command) { |
| 64 if (command == "help") { | 64 if (command == "help" || command == "h") { |
| 65 PrintHelp(); | 65 PrintHelp(); |
| 66 return true; | 66 return true; |
| 67 } | 67 } |
| 68 if (command == "trace") { | 68 if (command == "trace") { |
| 69 ToggleTracing(); | 69 ToggleTracing(); |
| 70 return true; | 70 return true; |
| 71 } | 71 } |
| 72 if (command == "reload") { | 72 if (command == "reload" || command == "r") { |
| 73 Reload(); | 73 Reload(); |
| 74 return true; | 74 return true; |
| 75 } | 75 } |
| 76 if (command == "inspect") { | 76 if (command == "inspect") { |
| 77 Inspect(); | 77 Inspect(); |
| 78 return true; | 78 return true; |
| 79 } | 79 } |
| 80 if (command == "quit" || command == "q") { |
| 81 Quit(); |
| 82 return true; |
| 83 } |
| 80 if (command.size() == 1) { | 84 if (command.size() == 1) { |
| 81 char c = command[0]; | 85 std::cout << "Unknown command: " << command << std::endl; |
| 82 if (c == 'h') | |
| 83 PrintHelp(); | |
| 84 else if (c == 'q') | |
| 85 Quit(); | |
| 86 else if (c == 'r') | |
| 87 Reload(); | |
| 88 else | |
| 89 std::cout << "Unknown command: " << c << std::endl; | |
| 90 return true; | 86 return true; |
| 91 } | 87 } |
| 92 return false; | 88 return false; |
| 93 } | 89 } |
| 94 | 90 |
| 95 void WaitForInput() { | 91 void WaitForInput() { |
| 96 std::string command = GetCommand(); | 92 std::string command = GetCommand(); |
| 97 | 93 |
| 98 if (!ExecuteCommand(command)) { | 94 if (!ExecuteCommand(command)) { |
| 99 if (command.size() > 0) { | 95 if (command.size() > 0) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 112 | 108 |
| 113 void PrintHelp() { | 109 void PrintHelp() { |
| 114 std::cout | 110 std::cout |
| 115 << "Sky Debugger" << std::endl | 111 << "Sky Debugger" << std::endl |
| 116 << "============" << std::endl | 112 << "============" << std::endl |
| 117 << "Type a URL to load in the debugger, enter to reload." << std::endl | 113 << "Type a URL to load in the debugger, enter to reload." << std::endl |
| 118 << "Commands: help -- Help" << std::endl | 114 << "Commands: help -- Help" << std::endl |
| 119 << " trace -- Capture a trace" << std::endl | 115 << " trace -- Capture a trace" << std::endl |
| 120 << " reload -- Reload the current page" << std::endl | 116 << " reload -- Reload the current page" << std::endl |
| 121 << " inspect -- Inspect the current page" << std::endl | 117 << " inspect -- Inspect the current page" << std::endl |
| 122 << " q -- Quit" << std::endl; | 118 << " quit -- Quit" << std::endl; |
| 123 } | 119 } |
| 124 | 120 |
| 125 void Reload() { | 121 void Reload() { |
| 126 debugger_->NavigateToURL(url_); | 122 debugger_->NavigateToURL(url_); |
| 127 } | 123 } |
| 128 | 124 |
| 129 void Inspect() { | 125 void Inspect() { |
| 130 debugger_->InjectInspector(); | 126 debugger_->InjectInspector(); |
| 131 std::cout | 127 std::cout |
| 132 << "Open the following URL in Chrome:" << std::endl | 128 << "Open the following URL in Chrome:" << std::endl |
| (...skipping 26 matching lines...) Expand all Loading... |
| 159 DISALLOW_COPY_AND_ASSIGN(Prompt); | 155 DISALLOW_COPY_AND_ASSIGN(Prompt); |
| 160 }; | 156 }; |
| 161 | 157 |
| 162 } // namespace debugger | 158 } // namespace debugger |
| 163 } // namespace sky | 159 } // namespace sky |
| 164 | 160 |
| 165 MojoResult MojoMain(MojoHandle shell_handle) { | 161 MojoResult MojoMain(MojoHandle shell_handle) { |
| 166 mojo::ApplicationRunnerChromium runner(new sky::debugger::Prompt); | 162 mojo::ApplicationRunnerChromium runner(new sky::debugger::Prompt); |
| 167 return runner.Run(shell_handle); | 163 return runner.Run(shell_handle); |
| 168 } | 164 } |
| OLD | NEW |