Commit e5176cd6 authored by mlerman's avatar mlerman Committed by Commit bot

Guest mode doesn't show the Bookmarks item in Wrench Menu.

BUG=436834
TEST=In guest mode (across browsers), Bookmarks doesn't show in the
wrench menu.

Review URL: https://codereview.chromium.org/953723003

Cr-Commit-Position: refs/heads/master@{#318133}
parent c021bb36
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/history/history_service.h" #include "chrome/browser/history/history_service.h"
...@@ -16,6 +17,7 @@ ...@@ -16,6 +17,7 @@
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/toolbar/wrench_menu_model.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h" #include "chrome/test/base/ui_test_utils.h"
#include "components/history/core/browser/history_db_task.h" #include "components/history/core/browser/history_db_task.h"
...@@ -68,6 +70,15 @@ void WaitForHistoryBackendToRun(Profile* profile) { ...@@ -68,6 +70,15 @@ void WaitForHistoryBackendToRun(Profile* profile) {
content::RunMessageLoop(); content::RunMessageLoop();
} }
class EmptyAcceleratorHandler : public ui::AcceleratorProvider {
public:
// Don't handle accelerators.
bool GetAcceleratorForCommandId(int command_id,
ui::Accelerator* accelerator) override {
return false;
}
};
} // namespace } // namespace
class ProfileWindowBrowserTest : public InProcessBrowserTest { class ProfileWindowBrowserTest : public InProcessBrowserTest {
...@@ -188,4 +199,16 @@ IN_PROC_BROWSER_TEST_F(ProfileWindowBrowserTest, GuestCannotSignin) { ...@@ -188,4 +199,16 @@ IN_PROC_BROWSER_TEST_F(ProfileWindowBrowserTest, GuestCannotSignin) {
ASSERT_FALSE(signin_manager); ASSERT_FALSE(signin_manager);
} }
IN_PROC_BROWSER_TEST_F(ProfileWindowBrowserTest, GuestWrenchLacksBookmarks) {
EmptyAcceleratorHandler accelerator_handler;
// Verify the normal browser has a bookmark menu.
WrenchMenuModel model_normal_profile(&accelerator_handler, browser());
EXPECT_NE(-1, model_normal_profile.GetIndexOfCommandId(IDC_BOOKMARKS_MENU));
// Guest browser has no bookmark menu.
Browser* guest_browser = OpenGuestBrowser();
WrenchMenuModel model_guest_profile(&accelerator_handler, guest_browser);
EXPECT_EQ(-1, model_guest_profile.GetIndexOfCommandId(IDC_BOOKMARKS_MENU));
}
#endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS) #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
...@@ -845,9 +845,11 @@ void WrenchMenuModel::Build() { ...@@ -845,9 +845,11 @@ void WrenchMenuModel::Build() {
if (ShouldShowNewIncognitoWindowMenuItem()) if (ShouldShowNewIncognitoWindowMenuItem())
AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW); AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW);
bookmark_sub_menu_model_.reset(new BookmarkSubMenuModel(this, browser_)); if (!browser_->profile()->IsGuestSession()) {
AddSubMenuWithStringId(IDC_BOOKMARKS_MENU, IDS_BOOKMARKS_MENU, bookmark_sub_menu_model_.reset(new BookmarkSubMenuModel(this, browser_));
bookmark_sub_menu_model_.get()); AddSubMenuWithStringId(IDC_BOOKMARKS_MENU, IDS_BOOKMARKS_MENU,
bookmark_sub_menu_model_.get());
}
if (!browser_->profile()->IsOffTheRecord()) { if (!browser_->profile()->IsOffTheRecord()) {
recent_tabs_sub_menu_model_.reset(new RecentTabsSubMenuModel(provider_, recent_tabs_sub_menu_model_.reset(new RecentTabsSubMenuModel(provider_,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment