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