Home | History | Annotate | Download | only in webui
      1 // Copyright (c) 2011 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/memory/singleton.h"
      9 #include "base/message_loop.h"
     10 #include "chrome/browser/profiles/profile.h"
     11 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
     12 #include "chrome/common/url_constants.h"
     13 #include "content/browser/browser_thread.h"
     14 #include "content/browser/tab_contents/tab_contents.h"
     15 #include "grit/theme_resources.h"
     16 #include "ui/base/resource/resource_bundle.h"
     17 
     18 ////////////////////////////////////////////////////////////////////////////////
     19 //
     20 // BookmarksUIHTMLSource
     21 //
     22 ////////////////////////////////////////////////////////////////////////////////
     23 
     24 BookmarksUIHTMLSource::BookmarksUIHTMLSource()
     25     : DataSource(chrome::kChromeUIBookmarksHost, MessageLoop::current()) {
     26 }
     27 
     28 void BookmarksUIHTMLSource::StartDataRequest(const std::string& path,
     29                                              bool is_incognito,
     30                                              int request_id) {
     31   NOTREACHED() << "We should never get here since the extension should have"
     32                << "been triggered";
     33 
     34   SendResponse(request_id, NULL);
     35 }
     36 
     37 std::string BookmarksUIHTMLSource::GetMimeType(const std::string& path) const {
     38   NOTREACHED() << "We should never get here since the extension should have"
     39                << "been triggered";
     40   return "text/html";
     41 }
     42 
     43 ////////////////////////////////////////////////////////////////////////////////
     44 //
     45 // BookmarksUI
     46 //
     47 ////////////////////////////////////////////////////////////////////////////////
     48 
     49 BookmarksUI::BookmarksUI(TabContents* contents) : WebUI(contents) {
     50   BookmarksUIHTMLSource* html_source = new BookmarksUIHTMLSource();
     51 
     52   // Set up the chrome://bookmarks/ source.
     53   contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source);
     54 }
     55 
     56 // static
     57 RefCountedMemory* BookmarksUI::GetFaviconResourceBytes() {
     58   return ResourceBundle::GetSharedInstance().
     59       LoadDataResourceBytes(IDR_BOOKMARKS_FAVICON);
     60 }
     61