summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-03 00:40:40 +0000
committerarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-03 00:40:40 +0000
commit6404197b5dcbd4ac5e756d74c00c5eaf9f1d2870 (patch)
tree705851af6128b9c6d0d38ac5bf865828ce51483d /chrome/browser
parent3774606e17a53662a3bd512f9fc6b5bb0946e675 (diff)
downloadchromium_src-6404197b5dcbd4ac5e756d74c00c5eaf9f1d2870.zip
chromium_src-6404197b5dcbd4ac5e756d74c00c5eaf9f1d2870.tar.gz
chromium_src-6404197b5dcbd4ac5e756d74c00c5eaf9f1d2870.tar.bz2
Add command line option to use a tabbed bookmark manager.
Start with --enable-tabbed-bookmark-manager. This will show chrome://bookmarks in a tab instead of the old bookmark manager. However, to get the bookmark manager extension to show you need to use --load-extension=path_to_extension. The extension uses the chrome_url_override to show the extension instead of the bookmark manager. BUG=4890 TEST=See description Review URL: http://codereview.chromium.org/661019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40468 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser.cc12
-rw-r--r--chrome/browser/browser.h1
-rw-r--r--chrome/browser/dom_ui/bookmarks_ui.cc63
-rw-r--r--chrome/browser/dom_ui/bookmarks_ui.h44
-rw-r--r--chrome/browser/dom_ui/dom_ui_factory.cc22
-rw-r--r--chrome/browser/extensions/extension_dom_ui.cc2
-rw-r--r--chrome/browser/extensions/extension_dom_ui.h1
-rw-r--r--chrome/browser/resources/bookmark_manager/manifest.json5
8 files changed, 137 insertions, 13 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 5b962e0..f559e3e 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -1289,7 +1289,12 @@ void Browser::ToggleExtensionShelf() {
void Browser::OpenBookmarkManager() {
UserMetrics::RecordAction("ShowBookmarkManager", profile_);
- window_->ShowBookmarkManager();
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableTabbedBookmarkManager)) {
+ ShowBookmarkManagerTab();
+ } else {
+ window_->ShowBookmarkManager();
+ }
}
void Browser::ShowAppMenu() {
@@ -1302,6 +1307,11 @@ void Browser::ShowPageMenu() {
window_->ShowPageMenu();
}
+void Browser::ShowBookmarkManagerTab() {
+ UserMetrics::RecordAction("ShowBookmarks", profile_);
+ ShowSingletonTab(GURL(chrome::kChromeUIBookmarksURL));
+}
+
void Browser::ShowHistoryTab() {
UserMetrics::RecordAction("ShowHistory", profile_);
ShowSingletonTab(GURL(chrome::kChromeUIHistoryURL));
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index ed5c28a..991f9d4 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -428,6 +428,7 @@ class Browser : public TabStripModelDelegate,
void OpenBookmarkManager();
void ShowAppMenu();
void ShowPageMenu();
+ void ShowBookmarkManagerTab();
void ShowHistoryTab();
void ShowDownloadsTab();
void ShowExtensionsTab();
diff --git a/chrome/browser/dom_ui/bookmarks_ui.cc b/chrome/browser/dom_ui/bookmarks_ui.cc
new file mode 100644
index 0000000..9fa457c
--- /dev/null
+++ b/chrome/browser/dom_ui/bookmarks_ui.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2010 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/dom_ui/bookmarks_ui.h"
+
+#include "app/resource_bundle.h"
+#include "base/message_loop.h"
+#include "base/ref_counted_memory.h"
+#include "base/singleton.h"
+#include "base/string_piece.h"
+#include "base/string_util.h"
+#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
+#include "chrome/common/url_constants.h"
+#include "grit/browser_resources.h"
+#include "grit/theme_resources.h"
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// BookmarksUIHTMLSource
+//
+////////////////////////////////////////////////////////////////////////////////
+
+BookmarksUIHTMLSource::BookmarksUIHTMLSource()
+ : DataSource(chrome::kChromeUIBookmarksHost, MessageLoop::current()) {
+}
+
+void BookmarksUIHTMLSource::StartDataRequest(const std::string& path,
+ bool is_off_the_record, int request_id) {
+ NOTREACHED() << "We should never get here since the extension should have"
+ << "been triggered";
+}
+
+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";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// BookmarksUI
+//
+////////////////////////////////////////////////////////////////////////////////
+
+BookmarksUI::BookmarksUI(TabContents* contents) : DOMUI(contents) {
+ BookmarksUIHTMLSource* html_source = new BookmarksUIHTMLSource();
+
+ // Set up the chrome://bookmarks/ source.
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ Singleton<ChromeURLDataManager>::get(),
+ &ChromeURLDataManager::AddDataSource,
+ make_scoped_refptr(html_source)));
+}
+
+// static
+RefCountedMemory* BookmarksUI::GetFaviconResourceBytes() {
+ return ResourceBundle::GetSharedInstance().
+ LoadDataResourceBytes(IDR_BOOKMARKS_FAVICON);
+}
diff --git a/chrome/browser/dom_ui/bookmarks_ui.h b/chrome/browser/dom_ui/bookmarks_ui.h
new file mode 100644
index 0000000..c8f2f79
--- /dev/null
+++ b/chrome/browser/dom_ui/bookmarks_ui.h
@@ -0,0 +1,44 @@
+// Copyright (c) 2010 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.
+
+#ifndef CHROME_BROWSER_DOM_UI_BOOKMARKS_UI_H_
+#define CHROME_BROWSER_DOM_UI_BOOKMARKS_UI_H_
+
+#include <string>
+
+#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
+#include "chrome/browser/dom_ui/dom_ui.h"
+
+class GURL;
+class RefCountedMemory;
+
+// This class provides the source for chrome://bookmarks/
+class BookmarksUIHTMLSource : public ChromeURLDataManager::DataSource {
+ public:
+ BookmarksUIHTMLSource();
+
+ // Called when the network layer has requested a resource underneath
+ // the path we registered.
+ virtual void StartDataRequest(const std::string& path,
+ bool is_off_the_record,
+ int request_id);
+ virtual std::string GetMimeType(const std::string& path) const;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BookmarksUIHTMLSource);
+};
+
+// This class is used to hook up chrome://bookmarks/ which in turn gets
+// overridden by an extension.
+class BookmarksUI : public DOMUI {
+ public:
+ explicit BookmarksUI(TabContents* contents);
+
+ static RefCountedMemory* GetFaviconResourceBytes();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BookmarksUI);
+};
+
+#endif // CHROME_BROWSER_DOM_UI_BOOKMARKS_UI_H_
diff --git a/chrome/browser/dom_ui/dom_ui_factory.cc b/chrome/browser/dom_ui/dom_ui_factory.cc
index e35063e..84722f6 100644
--- a/chrome/browser/dom_ui/dom_ui_factory.cc
+++ b/chrome/browser/dom_ui/dom_ui_factory.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/dom_ui/dom_ui_factory.h"
+#include "chrome/browser/dom_ui/bookmarks_ui.h"
#include "chrome/browser/dom_ui/downloads_ui.h"
#include "chrome/browser/dom_ui/devtools_ui.h"
#include "chrome/browser/dom_ui/history_ui.h"
@@ -83,14 +84,16 @@ static DOMUIFactoryFunction GetDOMUIFactoryFunction(const GURL& url) {
// We must compare hosts only since some of the DOM UIs append extra stuff
// after the host name.
- if (url.host() == chrome::kChromeUIHistoryHost)
- return &NewDOMUI<HistoryUI>;
+ if (url.host() == chrome::kChromeUIBookmarksHost)
+ return &NewDOMUI<BookmarksUI>;
+ if (url.host() == chrome::kChromeUIDevToolsHost)
+ return &NewDOMUI<DevToolsUI>;
if (url.host() == chrome::kChromeUIDownloadsHost)
return &NewDOMUI<DownloadsUI>;
if (url.host() == chrome::kChromeUIExtensionsHost)
return &NewDOMUI<ExtensionsUI>;
- if (url.host() == chrome::kChromeUIDevToolsHost)
- return &NewDOMUI<DevToolsUI>;
+ if (url.host() == chrome::kChromeUIHistoryHost)
+ return &NewDOMUI<HistoryUI>;
#if defined(OS_CHROMEOS)
if (url.host() == chrome::kChromeUIFileBrowseHost)
@@ -129,19 +132,18 @@ DOMUI* DOMUIFactory::CreateDOMUIForURL(TabContents* tab_contents,
}
// static
-RefCountedMemory* DOMUIFactory::GetFaviconResourceBytes(
- const GURL& page_url) {
+RefCountedMemory* DOMUIFactory::GetFaviconResourceBytes(const GURL& page_url) {
if (!HasDOMUIScheme(page_url))
return NULL;
- if (page_url.host() == chrome::kChromeUIHistoryHost)
- return HistoryUI::GetFaviconResourceBytes();
+ if (page_url.host() == chrome::kChromeUIBookmarksHost)
+ return BookmarksUI::GetFaviconResourceBytes();
if (page_url.host() == chrome::kChromeUIDownloadsHost)
return DownloadsUI::GetFaviconResourceBytes();
- if (page_url.host() == chrome::kChromeUIExtensionsHost)
- return ExtensionsUI::GetFaviconResourceBytes();
+ if (page_url.host() == chrome::kChromeUIHistoryHost)
+ return HistoryUI::GetFaviconResourceBytes();
return NULL;
}
diff --git a/chrome/browser/extensions/extension_dom_ui.cc b/chrome/browser/extensions/extension_dom_ui.cc
index b39b15b..773aa1d 100644
--- a/chrome/browser/extensions/extension_dom_ui.cc
+++ b/chrome/browser/extensions/extension_dom_ui.cc
@@ -52,7 +52,7 @@ void ExtensionDOMUI::ResetExtensionFunctionDispatcher(
void ExtensionDOMUI::ResetExtensionBookmarkManagerEventRouter() {
if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableExperimentalExtensionApis)) {
+ switches::kEnableTabbedBookmarkManager)) {
extension_bookmark_manager_event_router_.reset(
new ExtensionBookmarkManagerEventRouter(GetProfile(), tab_contents()));
}
diff --git a/chrome/browser/extensions/extension_dom_ui.h b/chrome/browser/extensions/extension_dom_ui.h
index 9d85ccb..42724575 100644
--- a/chrome/browser/extensions/extension_dom_ui.h
+++ b/chrome/browser/extensions/extension_dom_ui.h
@@ -16,6 +16,7 @@
class ListValue;
class PrefService;
+class RefCountedMemory;
class RenderViewHost;
class TabContents;
diff --git a/chrome/browser/resources/bookmark_manager/manifest.json b/chrome/browser/resources/bookmark_manager/manifest.json
index 7e05e6c..9ebe6f4 100644
--- a/chrome/browser/resources/bookmark_manager/manifest.json
+++ b/chrome/browser/resources/bookmark_manager/manifest.json
@@ -9,5 +9,8 @@
"bookmarks",
"experimental",
"tabs"
- ]
+ ],
+ "chrome_url_overrides": {
+ "bookmarks": "main.html"
+ }
}