summaryrefslogtreecommitdiffstats
path: root/chrome
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
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')
-rw-r--r--chrome/app/theme/theme_resources.grd1
-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
-rwxr-xr-xchrome/chrome_browser.gypi2
-rw-r--r--chrome/common/chrome_switches.cc3
-rw-r--r--chrome/common/chrome_switches.h1
-rw-r--r--chrome/common/extensions/extension.cc9
-rw-r--r--chrome/common/url_constants.cc2
-rw-r--r--chrome/common/url_constants.h2
15 files changed, 155 insertions, 15 deletions
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd
index 08c7ed6..101e7a9 100644
--- a/chrome/app/theme/theme_resources.grd
+++ b/chrome/app/theme/theme_resources.grd
@@ -255,6 +255,7 @@
</if>
<include name="IDR_THROBBER_LIGHT" file="throbber_light.png" type="BINDATA" />
<include name="IDR_OTR_ICON_STANDALONE" file="otr_icon_standalone.png" type="BINDATA" />
+ <include name="IDR_BOOKMARKS_FAVICON" file="bookmarks_favicon.png" type="BINDATA" />
<include name="IDR_BOOKMARK_MANAGER_RECENT_ICON" file="bookmark_manager_recent.png" type="BINDATA" />
<include name="IDR_BOOKMARK_MANAGER_SEARCH_ICON" file="bookmark_manager_search.png" type="BINDATA" />
<include name="IDR_TAB_ALPHA_LEFT" file="tab_alpha_left.png" type="BINDATA" />
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"
+ }
}
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index a1352ed..0dba333 100755
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -763,6 +763,8 @@
'browser/dock_info.cc',
'browser/dock_info.h',
'browser/dom_operation_notification_details.h',
+ 'browser/dom_ui/bookmarks_ui.cc',
+ 'browser/dom_ui/bookmarks_ui.h',
'browser/dom_ui/chrome_url_data_manager.cc',
'browser/dom_ui/chrome_url_data_manager.h',
'browser/dom_ui/devtools_ui.cc',
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 5787e1c..3b538b33 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -294,6 +294,9 @@ const char kEnableSyncBookmarks[] = "enable-sync-bookmarks";
// Enable syncing browser preferences.
const char kEnableSyncPreferences[] = "enable-sync-preferences";
+// Enable the tabbed bookmark manager
+const char kEnableTabbedBookmarkManager[] = "enable-tabbed-bookmark-manager";
+
// Whether the multiple profiles feature based on the user-data-dir flag is
// enabled or not.
const char kEnableUserDataDirProfiles[] = "enable-udd-profiles";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index afebf87..c40675d 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -100,6 +100,7 @@ extern const char kEnableSync[];
extern const char kEnableSyncAutofill[];
extern const char kEnableSyncBookmarks[];
extern const char kEnableSyncPreferences[];
+extern const char kEnableTabbedBookmarkManager[];
extern const char kEnableUserDataDirProfiles[];
extern const char kEnableVerticalTabs[];
extern const char kEnableVideoLayering[];
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 39929f7..0130929 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -64,7 +64,11 @@ static bool IsAPIPermission(const std::string& str) {
if (str == Extension::kPermissionNames[i]) {
if (str == Extension::kExperimentalPermission &&
!CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableExperimentalExtensionApis)) {
+ switches::kEnableExperimentalExtensionApis) &&
+ // TODO(arv): Tighten this so that not all extensions can access the
+ // experimental APIs.
+ !CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableTabbedBookmarkManager)) {
return false;
}
return true;
@@ -1284,7 +1288,8 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_id,
// this check, but let's keep it simple for now.
// TODO(erikkay) enable other pages as well
std::string val;
- if ((page != chrome::kChromeUINewTabHost) ||
+ if ((page != chrome::kChromeUINewTabHost &&
+ page != chrome::kChromeUIBookmarksHost) ||
!overrides->GetStringWithoutPathExpansion(*iter, &val)) {
*error = errors::kInvalidChromeURLOverrides;
return false;
diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc
index 7d312d8..6ddf90c 100644
--- a/chrome/common/url_constants.cc
+++ b/chrome/common/url_constants.cc
@@ -49,6 +49,7 @@ const char kAboutTermsURL[] = "about:terms";
// to be used for testing.
const char kAboutBrowserCrash[] = "about:inducebrowsercrashforrealz";
+const char kChromeUIBookmarksURL[] = "chrome://bookmarks/";
const char kChromeUIDevToolsURL[] = "chrome://devtools/";
const char kChromeUIDownloadsURL[] = "chrome://downloads/";
const char kChromeUIExtensionsURL[] = "chrome://extensions/";
@@ -58,6 +59,7 @@ const char kChromeUIIPCURL[] = "chrome://about/ipc";
const char kChromeUINetworkURL[] = "chrome://about/network";
const char kChromeUINewTabURL[] = "chrome://newtab";
+const char kChromeUIBookmarksHost[] = "bookmarks";
const char kChromeUIDevToolsHost[] = "devtools";
const char kChromeUIDialogHost[] = "dialog";
const char kChromeUIDownloadsHost[] = "downloads";
diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h
index 3339ae2..f7f1476 100644
--- a/chrome/common/url_constants.h
+++ b/chrome/common/url_constants.h
@@ -46,6 +46,7 @@ extern const char kAboutTermsURL[];
// chrome: URLs (including schemes). Should be kept in sync with the
// components below.
+extern const char kChromeUIBookmarksURL[];
extern const char kChromeUIDevToolsURL[];
extern const char kChromeUIDownloadsURL[];
extern const char kChromeUIExtensionsURL[];
@@ -57,6 +58,7 @@ extern const char kChromeUINewTabURL[];
// chrome components of URLs. Should be kept in sync with the full URLs
// above.
+extern const char kChromeUIBookmarksHost[];
extern const char kChromeUIDevToolsHost[];
extern const char kChromeUIDialogHost[];
extern const char kChromeUIDownloadsHost[];