// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/webui/bookmarks_ui.h"
#include "base/memory/ref_counted_memory.h"
#include "base/message_loop/message_loop.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_ui.h"
#include "grit/theme_resources.h"
#include "ui/base/resource/resource_bundle.h"
////////////////////////////////////////////////////////////////////////////////
//
// BookmarksUIHTMLSource
//
////////////////////////////////////////////////////////////////////////////////
BookmarksUIHTMLSource::BookmarksUIHTMLSource() {
}
std::string BookmarksUIHTMLSource::GetSource() const {
return chrome::kChromeUIBookmarksHost;
}
void BookmarksUIHTMLSource::StartDataRequest(
const std::string& path,
int render_process_id,
int render_view_id,
const content::URLDataSource::GotDataCallback& callback) {
NOTREACHED() << "We should never get here since the extension should have"
<< "been triggered";
callback.Run(NULL);
}
std::string BookmarksUIHTMLSource::GetMimeType(const std::string& path) const {
NOTREACHED() << "We should never get here since the extension should have"
<< "been triggered";
return "text/html";
}
BookmarksUIHTMLSource::~BookmarksUIHTMLSource() {}
////////////////////////////////////////////////////////////////////////////////
//
// BookmarksUI
//
////////////////////////////////////////////////////////////////////////////////
BookmarksUI::BookmarksUI(content::WebUI* web_ui) : WebUIController(web_ui) {
BookmarksUIHTMLSource* html_source = new BookmarksUIHTMLSource();
// Set up the chrome://bookmarks/ source.
Profile* profile = Profile::FromWebUI(web_ui);
content::URLDataSource::Add(profile, html_source);
}
// static
base::RefCountedMemory* BookmarksUI::GetFaviconResourceBytes(
ui::ScaleFactor scale_factor) {
return ui::ResourceBundle::GetSharedInstance().
LoadDataResourceBytesForScale(IDR_BOOKMARKS_FAVICON, scale_factor);
}