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