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