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.
5 #include "chrome/browser/ui/webui/bookmarks_ui.h"
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"
16 ////////////////////////////////////////////////////////////////////////////////
18 // BookmarksUIHTMLSource
20 ////////////////////////////////////////////////////////////////////////////////
22 BookmarksUIHTMLSource::BookmarksUIHTMLSource() {
25 std::string
BookmarksUIHTMLSource::GetSource() const {
26 return chrome::kChromeUIBookmarksHost
;
29 void BookmarksUIHTMLSource::StartDataRequest(
30 const std::string
& path
,
31 int render_process_id
,
33 const content::URLDataSource::GotDataCallback
& callback
) {
34 NOTREACHED() << "We should never get here since the extension should have"
40 std::string
BookmarksUIHTMLSource::GetMimeType(const std::string
& path
) const {
41 NOTREACHED() << "We should never get here since the extension should have"
46 BookmarksUIHTMLSource::~BookmarksUIHTMLSource() {}
48 ////////////////////////////////////////////////////////////////////////////////
52 ////////////////////////////////////////////////////////////////////////////////
54 BookmarksUI::BookmarksUI(content::WebUI
* web_ui
) : WebUIController(web_ui
) {
55 BookmarksUIHTMLSource
* html_source
= new BookmarksUIHTMLSource();
57 // Set up the chrome://bookmarks/ source.
58 Profile
* profile
= Profile::FromWebUI(web_ui
);
59 content::URLDataSource::Add(profile
, html_source
);
63 base::RefCountedMemory
* BookmarksUI::GetFaviconResourceBytes(
64 ui::ScaleFactor scale_factor
) {
65 return ui::ResourceBundle::GetSharedInstance().
66 LoadDataResourceBytesForScale(IDR_BOOKMARKS_FAVICON
, scale_factor
);