| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/dom_ui/keyboard_ui.h" | 5 #include "chrome/browser/dom_ui/keyboard_ui.h" |
| 6 | 6 |
| 7 #include "base/ref_counted_memory.h" | 7 #include "base/ref_counted_memory.h" |
| 8 #include "base/singleton.h" | 8 #include "base/singleton.h" |
| 9 #include "base/string_piece.h" | 9 #include "base/string_piece.h" |
| 10 #include "chrome/browser/browser_thread.h" | 10 #include "chrome/browser/browser_thread.h" |
| 11 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" | 11 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
| 12 #include "chrome/browser/profiles/profile.h" | |
| 13 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
| 14 #include "grit/browser_resources.h" | 13 #include "grit/browser_resources.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 16 | 15 |
| 17 /////////////////////////////////////////////////////////////////////////////// | 16 /////////////////////////////////////////////////////////////////////////////// |
| 18 // KeyboardUI | 17 // KeyboardUI |
| 19 | 18 |
| 20 KeyboardUI::KeyboardUI(TabContents* contents) | 19 KeyboardUI::KeyboardUI(TabContents* contents) |
| 21 : DOMUI(contents) { | 20 : DOMUI(contents) { |
| 22 KeyboardHTMLSource* html_source = new KeyboardHTMLSource(); | 21 KeyboardHTMLSource* html_source = new KeyboardHTMLSource(); |
| 23 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 22 BrowserThread::PostTask( |
| 23 BrowserThread::IO, FROM_HERE, |
| 24 NewRunnableMethod( |
| 25 ChromeURLDataManager::GetInstance(), |
| 26 &ChromeURLDataManager::AddDataSource, |
| 27 make_scoped_refptr(html_source))); |
| 24 } | 28 } |
| 25 | 29 |
| 26 KeyboardUI::~KeyboardUI() { | 30 KeyboardUI::~KeyboardUI() { |
| 27 } | 31 } |
| 28 | 32 |
| 29 /////////////////////////////////////////////////////////////////////////////// | 33 /////////////////////////////////////////////////////////////////////////////// |
| 30 // KeyboardHTMLSource | 34 // KeyboardHTMLSource |
| 31 | 35 |
| 32 KeyboardUI::KeyboardHTMLSource::KeyboardHTMLSource() | 36 KeyboardUI::KeyboardHTMLSource::KeyboardHTMLSource() |
| 33 : DataSource(chrome::kChromeUIKeyboardHost, MessageLoop::current()) { | 37 : DataSource(chrome::kChromeUIKeyboardHost, MessageLoop::current()) { |
| 34 } | 38 } |
| 35 | 39 |
| 36 void KeyboardUI::KeyboardHTMLSource::StartDataRequest(const std::string& path, | 40 void KeyboardUI::KeyboardHTMLSource::StartDataRequest(const std::string& path, |
| 37 bool is_off_the_record, | 41 bool is_off_the_record, |
| 38 int request_id) { | 42 int request_id) { |
| 39 NOTREACHED() << "We should never get here since the extension should have" | 43 NOTREACHED() << "We should never get here since the extension should have" |
| 40 << "been triggered"; | 44 << "been triggered"; |
| 41 SendResponse(request_id, NULL); | 45 SendResponse(request_id, NULL); |
| 42 } | 46 } |
| 43 | 47 |
| 44 std::string KeyboardUI::KeyboardHTMLSource::GetMimeType( | 48 std::string KeyboardUI::KeyboardHTMLSource::GetMimeType( |
| 45 const std::string&) const { | 49 const std::string&) const { |
| 46 NOTREACHED() << "We should never get here since the extension should have" | 50 NOTREACHED() << "We should never get here since the extension should have" |
| 47 << "been triggered"; | 51 << "been triggered"; |
| 48 return "text/html"; | 52 return "text/html"; |
| 49 } | 53 } |
| OLD | NEW |