| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // This file defines utility functions for working with strings. | 5 // This file defines utility functions for working with strings. |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/debugger/debugger_contents.h" | 10 #include "chrome/browser/debugger/debugger_contents.h" |
| 11 #include "chrome/browser/debugger/debugger_shell.h" | 11 #include "chrome/browser/debugger/debugger_shell.h" |
| 12 #include "chrome/browser/debugger/debugger_wrapper.h" | 12 #include "chrome/browser/debugger/debugger_wrapper.h" |
| 13 #include "chrome/browser/debugger/resources/debugger_resources.h" | 13 #include "chrome/browser/debugger/resources/debugger_resources.h" |
| 14 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" | 14 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
| 15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/common/resource_bundle.h" | 16 #include "chrome/common/resource_bundle.h" |
| 17 #include "net/base/mime_util.h" | 17 #include "net/base/mime_util.h" |
| 18 | 18 |
| 19 class DebuggerHTMLSource : public ChromeURLDataManager::DataSource { | 19 class DebuggerHTMLSource : public ChromeURLDataManager::DataSource { |
| 20 public: | 20 public: |
| 21 // Creates our datasource and sets our user message to a specific message | 21 // Creates our datasource and sets our user message to a specific message |
| 22 // from our string bundle. | 22 // from our string bundle. |
| 23 DebuggerHTMLSource() | 23 DebuggerHTMLSource() |
| 24 : DataSource("debugger", MessageLoop::current()) { } | 24 : DataSource("debugger", MessageLoop::current()) { } |
| 25 | 25 |
| 26 // Called when the network layer has requested a resource underneath | 26 // Called when the network layer has requested a resource underneath |
| 27 // the path we registered. | 27 // the path we registered. |
| 28 virtual void StartDataRequest(const std::string& path, int request_id) { | 28 virtual void StartDataRequest(const std::string& path, int request_id) { |
| 29 int resource_id = 0; | 29 int resource_id = 0; |
| 30 | 30 |
| 31 if (!path.length()) { | 31 if (!path.length()) { |
| 32 resource_id = IDR_DEBUGGER_HTML; | 32 resource_id = IDR_DEBUGGER_HTML; |
| 33 } else if (path == "debugger.js") { | 33 } else if (path == "debugger.js") { |
| 34 resource_id = IDR_DEBUGGER_JS; | 34 resource_id = IDR_DEBUGGER_JS; |
| 35 } else if (path == "debugger.css") { | 35 } else if (path == "debugger.css") { |
| 36 resource_id = IDR_DEBUGGER_CSS; | 36 resource_id = IDR_DEBUGGER_CSS; |
| 37 } else { | 37 } else { |
| 38 SendResponse(request_id, NULL); | 38 SendResponse(request_id, NULL); |
| 39 return; | 39 return; |
| 40 } | 40 } |
| 41 | 41 |
| 42 std::wstring debugger_path = | 42 std::wstring debugger_path = |
| 43 CommandLine().GetSwitchValue(switches::kJavaScriptDebuggerPath); | 43 CommandLine().GetSwitchValue(switches::kJavaScriptDebuggerPath); |
| 44 std::string data_str; | 44 std::string data_str; |
| 45 if (!debugger_path.empty() && file_util::PathExists(debugger_path)) { | 45 if (!debugger_path.empty() && file_util::PathExists(debugger_path)) { |
| 46 if (path.empty()) | 46 if (path.empty()) |
| 47 file_util::AppendToPath(&debugger_path, L"debugger.html"); | 47 file_util::AppendToPath(&debugger_path, L"debugger.html"); |
| 48 else | 48 else |
| 49 file_util::AppendToPath(&debugger_path, UTF8ToWide(path)); | 49 file_util::AppendToPath(&debugger_path, UTF8ToWide(path)); |
| 50 if (!file_util::ReadFileToString(debugger_path, &data_str)) { | 50 if (!file_util::ReadFileToString(debugger_path, &data_str)) { |
| 51 SendResponse(request_id, NULL); | 51 SendResponse(request_id, NULL); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 DebuggerHTMLSource* html_source = new DebuggerHTMLSource(); | 120 DebuggerHTMLSource* html_source = new DebuggerHTMLSource(); |
| 121 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, | 121 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, |
| 122 NewRunnableMethod(&chrome_url_data_manager, | 122 NewRunnableMethod(&chrome_url_data_manager, |
| 123 &ChromeURLDataManager::AddDataSource, | 123 &ChromeURLDataManager::AddDataSource, |
| 124 html_source)); | 124 html_source)); |
| 125 } | 125 } |
| 126 | 126 |
| 127 // static | 127 // static |
| 128 bool DebuggerContents::IsDebuggerUrl(const GURL& url) { | 128 bool DebuggerContents::IsDebuggerUrl(const GURL& url) { |
| 129 return (url.SchemeIs("chrome-resource") && url.host() == "inspector"); | 129 return (url.SchemeIs("chrome") && url.host() == "inspector"); |
| 130 } | 130 } |
| 131 | 131 |
| OLD | NEW |