| 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/bookmarks_ui.h" | 5 #include "chrome/browser/ui/webui/bookmarks_ui.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted_memory.h" | 7 #include "base/memory/ref_counted_memory.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 10 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
| 12 #include "content/public/browser/web_ui.h" | 12 #include "content/public/browser/web_ui.h" |
| 13 #include "grit/theme_resources.h" | 13 #include "grit/theme_resources.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 15 | 15 |
| 16 //////////////////////////////////////////////////////////////////////////////// | 16 //////////////////////////////////////////////////////////////////////////////// |
| 17 // | 17 // |
| 18 // BookmarksUIHTMLSource | 18 // BookmarksUIHTMLSource |
| 19 // | 19 // |
| 20 //////////////////////////////////////////////////////////////////////////////// | 20 //////////////////////////////////////////////////////////////////////////////// |
| 21 | 21 |
| 22 BookmarksUIHTMLSource::BookmarksUIHTMLSource() | 22 BookmarksUIHTMLSource::BookmarksUIHTMLSource() { |
| 23 : DataSource(chrome::kChromeUIBookmarksHost, MessageLoop::current()) { | 23 } |
| 24 |
| 25 std::string BookmarksUIHTMLSource::GetSource() { |
| 26 return chrome::kChromeUIBookmarksHost; |
| 24 } | 27 } |
| 25 | 28 |
| 26 void BookmarksUIHTMLSource::StartDataRequest(const std::string& path, | 29 void BookmarksUIHTMLSource::StartDataRequest(const std::string& path, |
| 27 bool is_incognito, | 30 bool is_incognito, |
| 28 int request_id) { | 31 int request_id) { |
| 29 NOTREACHED() << "We should never get here since the extension should have" | 32 NOTREACHED() << "We should never get here since the extension should have" |
| 30 << "been triggered"; | 33 << "been triggered"; |
| 31 | 34 |
| 32 SendResponse(request_id, NULL); | 35 url_data_source()->SendResponse(request_id, NULL); |
| 33 } | 36 } |
| 34 | 37 |
| 35 std::string BookmarksUIHTMLSource::GetMimeType(const std::string& path) const { | 38 std::string BookmarksUIHTMLSource::GetMimeType(const std::string& path) const { |
| 36 NOTREACHED() << "We should never get here since the extension should have" | 39 NOTREACHED() << "We should never get here since the extension should have" |
| 37 << "been triggered"; | 40 << "been triggered"; |
| 38 return "text/html"; | 41 return "text/html"; |
| 39 } | 42 } |
| 40 | 43 |
| 41 BookmarksUIHTMLSource::~BookmarksUIHTMLSource() {} | 44 BookmarksUIHTMLSource::~BookmarksUIHTMLSource() {} |
| 42 | 45 |
| 43 //////////////////////////////////////////////////////////////////////////////// | 46 //////////////////////////////////////////////////////////////////////////////// |
| 44 // | 47 // |
| 45 // BookmarksUI | 48 // BookmarksUI |
| 46 // | 49 // |
| 47 //////////////////////////////////////////////////////////////////////////////// | 50 //////////////////////////////////////////////////////////////////////////////// |
| 48 | 51 |
| 49 BookmarksUI::BookmarksUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 52 BookmarksUI::BookmarksUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 50 BookmarksUIHTMLSource* html_source = new BookmarksUIHTMLSource(); | |
| 51 | |
| 52 // Set up the chrome://bookmarks/ source. | 53 // Set up the chrome://bookmarks/ source. |
| 53 Profile* profile = Profile::FromWebUI(web_ui); | 54 ChromeURLDataManager::AddDataSource( |
| 54 ChromeURLDataManager::AddDataSource(profile, html_source); | 55 Profile::FromWebUI(web_ui), |
| 56 new BookmarksUIHTMLSource); |
| 55 } | 57 } |
| 56 | 58 |
| 57 // static | 59 // static |
| 58 base::RefCountedMemory* BookmarksUI::GetFaviconResourceBytes( | 60 base::RefCountedMemory* BookmarksUI::GetFaviconResourceBytes( |
| 59 ui::ScaleFactor scale_factor) { | 61 ui::ScaleFactor scale_factor) { |
| 60 return ui::ResourceBundle::GetSharedInstance(). | 62 return ui::ResourceBundle::GetSharedInstance(). |
| 61 LoadDataResourceBytesForScale(IDR_BOOKMARKS_FAVICON, scale_factor); | 63 LoadDataResourceBytesForScale(IDR_BOOKMARKS_FAVICON, scale_factor); |
| 62 } | 64 } |
| OLD | NEW |