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