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 "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/debugger/debugger_contents.h" | 12 #include "chrome/browser/debugger/debugger_contents.h" |
13 #include "chrome/browser/debugger/debugger_shell.h" | 13 #include "chrome/browser/debugger/debugger_shell.h" |
14 #include "chrome/browser/debugger/debugger_wrapper.h" | 14 #include "chrome/browser/debugger/debugger_wrapper.h" |
15 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" | 15 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/common/resource_bundle.h" | 17 #include "chrome/common/resource_bundle.h" |
18 #include "net/base/mime_util.h" | 18 #include "net/base/mime_util.h" |
19 | 19 |
20 #include "grit/debugger_resources.h" | 20 #include "grit/debugger_resources.h" |
21 | 21 |
| 22 // DebuggerUI is accessible from chrome-ui://inspector. |
| 23 static const char kDebuggerHost[] = "inspector"; |
| 24 |
22 class DebuggerHTMLSource : public ChromeURLDataManager::DataSource { | 25 class DebuggerHTMLSource : public ChromeURLDataManager::DataSource { |
23 public: | 26 public: |
24 // Creates our datasource and sets our user message to a specific message | 27 // Creates our datasource and sets our user message to a specific message |
25 // from our string bundle. | 28 // from our string bundle. |
26 DebuggerHTMLSource() | 29 DebuggerHTMLSource() |
27 : DataSource("debugger", MessageLoop::current()) { } | 30 : DataSource("debugger", MessageLoop::current()) { } |
28 | 31 |
29 // Called when the network layer has requested a resource underneath | 32 // Called when the network layer has requested a resource underneath |
30 // the path we registered. | 33 // the path we registered. |
31 virtual void StartDataRequest(const std::string& path, int request_id) { | 34 virtual void StartDataRequest(const std::string& path, int request_id) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 return mime_type; | 82 return mime_type; |
80 } | 83 } |
81 | 84 |
82 private: | 85 private: |
83 DISALLOW_EVIL_CONSTRUCTORS(DebuggerHTMLSource); | 86 DISALLOW_EVIL_CONSTRUCTORS(DebuggerHTMLSource); |
84 }; | 87 }; |
85 | 88 |
86 | 89 |
87 class DebuggerHandler : public DOMMessageHandler { | 90 class DebuggerHandler : public DOMMessageHandler { |
88 public: | 91 public: |
89 explicit DebuggerHandler(DOMUIHost* host) { | 92 explicit DebuggerHandler(DOMUI* dom_ui) : DOMMessageHandler(dom_ui) { |
90 host->RegisterMessageCallback("DebuggerHostMessage", | 93 dom_ui->RegisterMessageCallback("DebuggerHostMessage", |
91 NewCallback(this, &DebuggerHandler::HandleDebuggerHostMessage)); | 94 NewCallback(this, &DebuggerHandler::HandleDebuggerHostMessage)); |
92 } | 95 } |
93 | 96 |
94 void HandleDebuggerHostMessage(const Value* content) { | 97 void HandleDebuggerHostMessage(const Value* content) { |
95 if (!content || !content->IsType(Value::TYPE_LIST)) { | 98 if (!content || !content->IsType(Value::TYPE_LIST)) { |
96 NOTREACHED(); | 99 NOTREACHED(); |
97 return; | 100 return; |
98 } | 101 } |
99 const ListValue* args = static_cast<const ListValue*>(content); | 102 const ListValue* args = static_cast<const ListValue*>(content); |
100 if (args->GetSize() < 1) { | 103 if (args->GetSize() < 1) { |
(...skipping 10 matching lines...) Expand all Loading... |
111 } | 114 } |
112 debugger_host->OnDebuggerHostMsg(args); | 115 debugger_host->OnDebuggerHostMsg(args); |
113 #endif | 116 #endif |
114 } | 117 } |
115 | 118 |
116 private: | 119 private: |
117 DISALLOW_EVIL_CONSTRUCTORS(DebuggerHandler); | 120 DISALLOW_EVIL_CONSTRUCTORS(DebuggerHandler); |
118 }; | 121 }; |
119 | 122 |
120 | 123 |
121 DebuggerContents::DebuggerContents(Profile* profile, SiteInstance* instance) | 124 DebuggerContents::DebuggerContents(DOMUIContents* contents) |
122 : DOMUIHost(profile, instance, NULL) { | 125 : DOMUI(contents) { |
123 set_type(TAB_CONTENTS_DEBUGGER); | |
124 } | 126 } |
125 | 127 |
126 void DebuggerContents::AttachMessageHandlers() { | 128 void DebuggerContents::Init() { |
127 AddMessageHandler(new DebuggerHandler(this)); | 129 AddMessageHandler(new DebuggerHandler(this)); |
128 | 130 |
129 DebuggerHTMLSource* html_source = new DebuggerHTMLSource(); | 131 DebuggerHTMLSource* html_source = new DebuggerHTMLSource(); |
130 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, | 132 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, |
131 NewRunnableMethod(&chrome_url_data_manager, | 133 NewRunnableMethod(&chrome_url_data_manager, |
132 &ChromeURLDataManager::AddDataSource, | 134 &ChromeURLDataManager::AddDataSource, |
133 html_source)); | 135 html_source)); |
134 } | 136 } |
135 | 137 |
136 // static | 138 // static |
137 bool DebuggerContents::IsDebuggerUrl(const GURL& url) { | 139 bool DebuggerContents::IsDebuggerUrl(const GURL& url) { |
138 return (url.SchemeIs("chrome-ui") && url.host() == "inspector"); | 140 return (url.SchemeIs(DOMUIContents::GetScheme().c_str()) && |
| 141 url.host() == kDebuggerHost); |
139 } | 142 } |
140 | 143 |
| 144 // static |
| 145 GURL DebuggerContents::GetBaseURL() { |
| 146 std::string url = DOMUIContents::GetScheme(); |
| 147 url += "://"; |
| 148 url += kDebuggerHost; |
| 149 return GURL(url); |
| 150 } |
OLD | NEW |