 Chromium Code Reviews
 Chromium Code Reviews Issue 7053009:
  Add chrome://quota-internals/ resources  (Closed) 
  Base URL: http://git.chromium.org/git/chromium.git@trunk
    
  
    Issue 7053009:
  Add chrome://quota-internals/ resources  (Closed) 
  Base URL: http://git.chromium.org/git/chromium.git@trunk| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/webui/quota_internals_ui.h" | |
| 6 | |
| 7 #include <algorithm> | |
| 8 #include <string> | |
| 9 | |
| 10 #include "chrome/browser/profiles/profile.h" | |
| 11 #include "chrome/common/url_constants.h" | |
| 12 #include "content/browser/tab_contents/tab_contents.h" | |
| 13 #include "grit/quota_internals_resources.h" | |
| 14 #include "ui/base/resource/resource_bundle.h" | |
| 15 | |
| 16 | |
| 
michaeln
2011/05/26 20:28:31
extra blank lines
 
tzik
2011/05/27 14:53:59
Done.
 | |
| 17 | |
| 18 QuotaInternalsUI::QuotaInternalsUI(TabContents* contents) | |
| 19 : WebUI(contents) { | |
| 20 // TODO(tzik): implement me | |
| 21 // WebUIMessageHandler* handler = | |
| 22 // new quota_internals::QuotaInternalsMessageHandler; | |
| 23 // AddMessageHandler(handler->Attach(this)); | |
| 
michaeln
2011/05/26 20:28:31
maybe just leave a TODO without the comment out co
 
tzik
2011/05/27 14:53:59
Done.
 | |
| 24 contents->profile()->GetChromeURLDataManager()-> | |
| 25 AddDataSource(new quota_internals::QuotaInternalsHTMLSource); | |
| 26 } | |
| 27 | |
| 28 namespace quota_internals { | |
| 29 | |
| 30 QuotaInternalsHTMLSource::QuotaInternalsHTMLSource() | |
| 31 : DataSource(chrome::kChromeUIQuotaInternalsHost, | |
| 32 MessageLoop::current()) { | |
| 33 } | |
| 34 | |
| 35 void QuotaInternalsHTMLSource::StartDataRequest(const std::string& path, | |
| 36 bool is_incognito, | |
| 37 int request_id) OVERRIDE { | |
| 38 base::StringPiece html( | |
| 39 ResourceBundle::GetSharedInstance().GetRawDataResource( | |
| 40 IDR_QUOTA_INTERNALS_INDEX_HTML)); | |
| 41 std::string full_html(html.data(), html.size()); | |
| 
michaeln
2011/05/26 20:28:31
nit: maybe avoid the string copy, can html_bytes b
 
tzik
2011/05/27 14:53:59
Done.
 | |
| 42 | |
| 43 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); | |
| 44 html_bytes->data.resize(full_html.size()); | |
| 45 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); | |
| 46 SendResponse(request_id, html_bytes); | |
| 47 return; | |
| 48 } | |
| 49 | |
| 50 std::string QuotaInternalsHTMLSource::GetMimeType( | |
| 51 const std::string& path_unused) const { | |
| 52 return "text/html"; | |
| 53 } | |
| 54 | |
| 55 } // namespace quota_internals | |
| 56 | |
| OLD | NEW |