• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
BookmarksUIHTMLSource()22 BookmarksUIHTMLSource::BookmarksUIHTMLSource() {
23 }
24 
GetSource() const25 std::string BookmarksUIHTMLSource::GetSource() const {
26   return chrome::kChromeUIBookmarksHost;
27 }
28 
StartDataRequest(const std::string & path,int render_process_id,int render_frame_id,const content::URLDataSource::GotDataCallback & callback)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";
36 
37   callback.Run(NULL);
38 }
39 
GetMimeType(const std::string & path) const40 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 
~BookmarksUIHTMLSource()46 BookmarksUIHTMLSource::~BookmarksUIHTMLSource() {}
47 
48 ////////////////////////////////////////////////////////////////////////////////
49 //
50 // BookmarksUI
51 //
52 ////////////////////////////////////////////////////////////////////////////////
53 
BookmarksUI(content::WebUI * web_ui)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
GetFaviconResourceBytes(ui::ScaleFactor scale_factor)63 base::RefCountedMemory* BookmarksUI::GetFaviconResourceBytes(
64       ui::ScaleFactor scale_factor) {
65   return ui::ResourceBundle::GetSharedInstance().
66       LoadDataResourceBytesForScale(IDR_BOOKMARKS_FAVICON, scale_factor);
67 }
68