diff options
author | gbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-16 01:37:02 +0000 |
---|---|---|
committer | gbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-16 01:37:02 +0000 |
commit | 0af8f13ec70d3db6df8bcf308b943dfc5a8f17e7 (patch) | |
tree | 5523938698575107abe9eeec262f5a82417edc56 | |
parent | a5768f861ba75bb190073dfc9a4bf39fe78aadd0 (diff) | |
download | chromium_src-0af8f13ec70d3db6df8bcf308b943dfc5a8f17e7.zip chromium_src-0af8f13ec70d3db6df8bcf308b943dfc5a8f17e7.tar.gz chromium_src-0af8f13ec70d3db6df8bcf308b943dfc5a8f17e7.tar.bz2 |
Make bookmark manager from context menu open open in the selected folder.
BUG=23159
TEST=none
Review URL: http://codereview.chromium.org/7352020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92777 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/bookmarks/bookmark_context_menu_controller.cc | 22 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 21 | ||||
-rw-r--r-- | chrome/browser/ui/browser.h | 2 | ||||
-rw-r--r-- | chrome/browser/ui/browser_navigator_browsertest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.cc | 21 |
5 files changed, 42 insertions, 26 deletions
diff --git a/chrome/browser/bookmarks/bookmark_context_menu_controller.cc b/chrome/browser/bookmarks/bookmark_context_menu_controller.cc index 95cb5ff..644f513 100644 --- a/chrome/browser/bookmarks/bookmark_context_menu_controller.cc +++ b/chrome/browser/bookmarks/bookmark_context_menu_controller.cc @@ -188,16 +188,22 @@ void BookmarkContextMenuController::ExecuteCommand(int id) { bookmark_utils::ToggleWhenVisible(profile_); break; - case IDC_BOOKMARK_MANAGER: + case IDC_BOOKMARK_MANAGER: { UserMetrics::RecordAction(UserMetricsAction("ShowBookmarkManager")); - { - Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); - if (browser) - browser->OpenBookmarkManager(); - else - NOTREACHED(); - } + Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); + if (!browser) NOTREACHED(); + + if (selection_.size() != 1) + browser->OpenBookmarkManager(); + else if (selection_[0]->is_folder()) + browser->OpenBookmarkManagerForNode(selection_[0]->id()); + else if (parent_) + browser->OpenBookmarkManagerForNode(parent_->id()); + else + browser->OpenBookmarkManager(); break; + } + case IDC_CUT: bookmark_utils::CopyToClipboard(model_, selection_, true); diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 2d2648f..b56efb3 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -18,6 +18,7 @@ #include "base/metrics/histogram.h" #include "base/path_service.h" #include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/threading/thread.h" #include "base/threading/thread_restrictions.h" #include "base/time.h" @@ -747,7 +748,7 @@ TabContents* Browser::OpenApplicationTab(Profile* profile, // static void Browser::OpenBookmarkManagerWindow(Profile* profile) { Browser* browser = Browser::Create(profile); - browser->ShowBookmarkManagerTab(); + browser->OpenBookmarkManager(); browser->window()->Show(); } @@ -1926,7 +1927,17 @@ void Browser::ToggleBookmarkBar() { void Browser::OpenBookmarkManager() { UserMetrics::RecordAction(UserMetricsAction("ShowBookmarkManager")); - ShowBookmarkManagerTab(); + UserMetrics::RecordAction(UserMetricsAction("ShowBookmarks")); + ShowSingletonTabOverwritingNTP( + GetSingletonTabNavigateParams(GURL(chrome::kChromeUIBookmarksURL))); +} + +void Browser::OpenBookmarkManagerForNode(int64 node_id) { + UserMetrics::RecordAction(UserMetricsAction("ShowBookmarkManager")); + UserMetrics::RecordAction(UserMetricsAction("ShowBookmarks")); + ShowSingletonTabOverwritingNTP( + GetSingletonTabNavigateParams(GURL(chrome::kChromeUIBookmarksURL).Resolve( + StringPrintf("/#%s", base::Int64ToString(node_id).c_str())))); } void Browser::ShowAppMenu() { @@ -1934,12 +1945,6 @@ void Browser::ShowAppMenu() { window_->ShowAppMenu(); } -void Browser::ShowBookmarkManagerTab() { - UserMetrics::RecordAction(UserMetricsAction("ShowBookmarks")); - ShowSingletonTabOverwritingNTP( - GetSingletonTabNavigateParams(GURL(chrome::kChromeUIBookmarksURL))); -} - void Browser::ShowHistoryTab() { UserMetrics::RecordAction(UserMetricsAction("ShowHistory")); ShowSingletonTabOverwritingNTP( diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index 22e8a03..9e6f432 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -564,8 +564,8 @@ class Browser : public TabHandlerDelegate, void ToggleBookmarkBar(); void OpenBookmarkManager(); + void OpenBookmarkManagerForNode(int64 node_id); void ShowAppMenu(); - void ShowBookmarkManagerTab(); void ShowHistoryTab(); void ShowDownloadsTab(); void ShowExtensionsTab(); diff --git a/chrome/browser/ui/browser_navigator_browsertest.cc b/chrome/browser/ui/browser_navigator_browsertest.cc index 9de8886..3b85cb7 100644 --- a/chrome/browser/ui/browser_navigator_browsertest.cc +++ b/chrome/browser/ui/browser_navigator_browsertest.cc @@ -1124,7 +1124,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, { ui_test_utils::WindowedNotificationObserver observer( content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); - browser()->ShowBookmarkManagerTab(); + browser()->OpenBookmarkManager(); observer.Wait(); } EXPECT_EQ(1, browser()->tab_count()); diff --git a/chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.cc b/chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.cc index 926f97b..be87e71 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.cc @@ -178,16 +178,21 @@ void BookmarkContextMenuControllerViews::ExecuteCommand(int id) { bookmark_utils::ToggleWhenVisible(profile_); break; - case IDC_BOOKMARK_MANAGER: + case IDC_BOOKMARK_MANAGER: { UserMetrics::RecordAction(UserMetricsAction("ShowBookmarkManager")); - { - Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); - if (browser) - browser->OpenBookmarkManager(); - else - NOTREACHED(); - } + Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); + if (!browser) NOTREACHED(); + + if (selection_.size() != 1) + browser->OpenBookmarkManager(); + else if (selection_[0]->is_folder()) + browser->OpenBookmarkManagerForNode(selection_[0]->id()); + else if (parent_) + browser->OpenBookmarkManagerForNode(parent_->id()); + else + browser->OpenBookmarkManager(); break; + } case IDC_CUT: delegate_->WillRemoveBookmarks(selection_); |