Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: chrome/browser/debugger/debugger_contents.cc

Issue 10941: Add mimetypes on the "chrome-resource://" responses.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 18
18 class DebuggerHTMLSource : public ChromeURLDataManager::DataSource { 19 class DebuggerHTMLSource : public ChromeURLDataManager::DataSource {
19 public: 20 public:
20 // 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
21 // from our string bundle. 22 // from our string bundle.
22 DebuggerHTMLSource() 23 DebuggerHTMLSource()
23 : DataSource("debugger", MessageLoop::current()) { } 24 : DataSource("debugger", MessageLoop::current()) { }
24 25
25 // Called when the network layer has requested a resource underneath 26 // Called when the network layer has requested a resource underneath
26 // the path we registered. 27 // the path we registered.
(...skipping 27 matching lines...) Expand all
54 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 55 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
55 data_str = rb.GetDataResource(resource_id); 56 data_str = rb.GetDataResource(resource_id);
56 } 57 }
57 scoped_refptr<RefCountedBytes> data_bytes(new RefCountedBytes); 58 scoped_refptr<RefCountedBytes> data_bytes(new RefCountedBytes);
58 data_bytes->data.resize(data_str.size()); 59 data_bytes->data.resize(data_str.size());
59 std::copy(data_str.begin(), data_str.end(), data_bytes->data.begin()); 60 std::copy(data_str.begin(), data_str.end(), data_bytes->data.begin());
60 61
61 SendResponse(request_id, data_bytes); 62 SendResponse(request_id, data_bytes);
62 } 63 }
63 64
65 virtual std::string GetMimeType(const std::string& path) const {
66 // Currently but three choices {"", "debugger.js", "debugger.css"}.
67 // Map the extension to mime-type, defaulting to "text/html".
68 std::string mime_type("text/html");
69 net::GetMimeTypeFromFile(ASCIIToWide(path), &mime_type);
70 return mime_type;
71 }
72
64 private: 73 private:
65 DISALLOW_EVIL_CONSTRUCTORS(DebuggerHTMLSource); 74 DISALLOW_EVIL_CONSTRUCTORS(DebuggerHTMLSource);
66 }; 75 };
67 76
68 77
69 class DebuggerHandler : public DOMMessageHandler { 78 class DebuggerHandler : public DOMMessageHandler {
70 public: 79 public:
71 explicit DebuggerHandler(DOMUIHost* host) { 80 explicit DebuggerHandler(DOMUIHost* host) {
72 host->RegisterMessageCallback("command", 81 host->RegisterMessageCallback("command",
73 NewCallback(this, &DebuggerHandler::HandleCommand)); 82 NewCallback(this, &DebuggerHandler::HandleCommand));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 html_source)); 125 html_source));
117 } 126 }
118 127
119 // static 128 // static
120 bool DebuggerContents::IsDebuggerUrl(const GURL& url) { 129 bool DebuggerContents::IsDebuggerUrl(const GURL& url) {
121 if (url.SchemeIs("chrome-resource") && url.host() == "debugger") 130 if (url.SchemeIs("chrome-resource") && url.host() == "debugger")
122 return true; 131 return true;
123 return false; 132 return false;
124 } 133 }
125 134
OLDNEW
« no previous file with comments | « chrome/browser/browser_about_handler.cc ('k') | chrome/browser/dom_ui/chrome_url_data_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698