Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / webui / bookmarks_ui.cc
blob1259adfee904094ab44f40df280988a11db524c7
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,
32 int render_frame_id,
33 const content::URLDataSource::GotDataCallback& callback) {
34 NOTREACHED() << "We should never get here since the extension should have"
35 << "been triggered";
37 callback.Run(NULL);
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";
46 BookmarksUIHTMLSource::~BookmarksUIHTMLSource() {}
48 ////////////////////////////////////////////////////////////////////////////////
50 // BookmarksUI
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);
62 // static
63 base::RefCountedMemory* BookmarksUI::GetFaviconResourceBytes(
64 ui::ScaleFactor scale_factor) {
65 return ui::ResourceBundle::GetSharedInstance().
66 LoadDataResourceBytesForScale(IDR_BOOKMARKS_FAVICON, scale_factor);