-
Notifications
You must be signed in to change notification settings - Fork 893
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3620 from brave/hide-other-bookmarks
Hide other bookmarks
- Loading branch information
Showing
30 changed files
with
811 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<!--This file is created by l10nUtil.js. Do not edit manually.--> | ||
<grit-part> | ||
<if expr="not is_ios and not use_titlecase"> | ||
<message name="IDS_BOOKMARK_BAR_FOLDER_NAME" desc="Name shown in the tree for the Bookmarks Bar folder."> | ||
Bookmarks | ||
</message> | ||
</if> | ||
<if expr="not is_ios and use_titlecase"> | ||
<message name="IDS_BOOKMARK_BAR_FOLDER_NAME" desc="In Title Case: Name shown in the tree for the Bookmarks Bar folder."> | ||
Bookmarks | ||
</message> | ||
</if> | ||
<if expr="is_ios"> | ||
<message name="IDS_BOOKMARK_BAR_FOLDER_NAME" desc="Mobile: Name shown in the tree for the desktop bookmarks folder"> | ||
Desktop Bookmarks | ||
</message> | ||
</if> | ||
|
||
<if expr="not use_titlecase"> | ||
<message name="IDS_BOOKMARK_BAR_MOBILE_FOLDER_NAME" desc="Name shown in the tree for the mobile bookmarks folder"> | ||
Mobile bookmarks | ||
</message> | ||
<message name="IDS_BOOKMARK_BAR_OTHER_FOLDER_NAME" desc="Name shown in the tree for the other bookmarks folder"> | ||
Other bookmarks | ||
</message> | ||
<message name="IDS_BOOKMARK_BAR_MANAGED_FOLDER_DOMAIN_NAME" desc="Name shown in the tree for the managed bookmarks folder, when the managed bookmarks come from a domain"> | ||
<ph name="DOMAIN">$1<ex>google.com</ex></ph> bookmarks | ||
</message> | ||
<message name="IDS_BOOKMARK_BAR_MANAGED_FOLDER_DEFAULT_NAME" desc="Name shown in the tree for the managed bookmarks folder, when the managed bookmarks don't come from a domain"> | ||
Managed bookmarks | ||
</message> | ||
</if> | ||
<if expr="use_titlecase"> | ||
<message name="IDS_BOOKMARK_BAR_MOBILE_FOLDER_NAME" desc="In Title Case: Name shown in the tree for the mobile bookmarks folder"> | ||
Mobile Bookmarks | ||
</message> | ||
<message name="IDS_BOOKMARK_BAR_OTHER_FOLDER_NAME" desc="In Title Case: Name shown in the tree for the other bookmarks folder"> | ||
Other Bookmarks | ||
</message> | ||
<message name="IDS_BOOKMARK_BAR_MANAGED_FOLDER_DOMAIN_NAME" desc="In Title Case: Name shown in the tree for the managed bookmarks folder, when the managed bookmarks come from a domain"> | ||
<ph name="DOMAIN">$1<ex>google.com</ex></ph> Bookmarks | ||
</message> | ||
<message name="IDS_BOOKMARK_BAR_MANAGED_FOLDER_DEFAULT_NAME" desc="In Title Case: Name shown in the tree for the managed bookmarks folder, when the managed bookmarks don't come from a domain"> | ||
Managed Bookmarks | ||
</message> | ||
</if> | ||
</grit-part> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* Copyright 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/bookmarks/brave_bookmark_client.h" | ||
|
||
BraveBookmarkClient::BraveBookmarkClient( | ||
Profile* profile, | ||
bookmarks::ManagedBookmarkService* managed_bookmark_service, | ||
sync_bookmarks::BookmarkSyncService* bookmark_sync_service) : | ||
ChromeBookmarkClient(profile, managed_bookmark_service, | ||
bookmark_sync_service) { | ||
} | ||
|
||
BraveBookmarkClient::~BraveBookmarkClient() {} | ||
|
||
bool BraveBookmarkClient::IsPermanentNodeVisible( | ||
const bookmarks::BookmarkPermanentNode* node) { | ||
if (node->type() == bookmarks::BookmarkNode::OTHER_NODE) | ||
return false; | ||
return ChromeBookmarkClient::IsPermanentNodeVisible(node); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* Copyright 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_BOOKMARKS_BRAVE_BOOKMARK_CLIENT_H_ | ||
#define BRAVE_BROWSER_BOOKMARKS_BRAVE_BOOKMARK_CLIENT_H_ | ||
|
||
#include "chrome/browser/bookmarks/chrome_bookmark_client.h" | ||
|
||
class BraveBookmarkClient : public ChromeBookmarkClient { | ||
public: | ||
BraveBookmarkClient( | ||
Profile* profile, | ||
bookmarks::ManagedBookmarkService* managed_bookmark_service, | ||
sync_bookmarks::BookmarkSyncService* bookmark_sync_service); | ||
~BraveBookmarkClient() override; | ||
|
||
// bookmarks::BookmarkClient: | ||
bool IsPermanentNodeVisible( | ||
const bookmarks::BookmarkPermanentNode* node) override; | ||
private: | ||
DISALLOW_COPY_AND_ASSIGN(BraveBookmarkClient); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_BOOKMARKS_BRAVE_BOOKMARK_CLIENT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* Copyright (c) 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "base/strings/utf_string_conversions.h" | ||
#include "chrome/browser/bookmarks/bookmark_model_factory.h" | ||
#include "chrome/browser/profiles/profile.h" | ||
#include "chrome/browser/ui/browser.h" | ||
#include "chrome/test/base/in_process_browser_test.h" | ||
#include "components/bookmarks/browser/bookmark_model.h" | ||
|
||
using BraveBookmarkClientTest = InProcessBrowserTest; | ||
|
||
IN_PROC_BROWSER_TEST_F(BraveBookmarkClientTest, IsPermanentNodeVisible) { | ||
bookmarks::BookmarkModel* bookmark_model = | ||
BookmarkModelFactory::GetForBrowserContext(browser()->profile()); | ||
EXPECT_TRUE(bookmark_model->bookmark_bar_node()->IsVisible()); | ||
// Other node invisible by default | ||
EXPECT_FALSE(bookmark_model->other_node()->IsVisible()); | ||
EXPECT_FALSE(bookmark_model->mobile_node()->IsVisible()); | ||
|
||
bookmark_model->AddURL(bookmark_model->other_node(), 0, | ||
base::ASCIIToUTF16("A"), GURL("https://A.com")); | ||
EXPECT_TRUE(bookmark_model->other_node()->IsVisible()); | ||
BraveMigrateOtherNode(bookmark_model); | ||
EXPECT_FALSE(bookmark_model->other_node()->IsVisible()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* Copyright 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/profiles/brave_bookmark_model_loaded_observer.h" | ||
|
||
#include "chrome/browser/sync/profile_sync_service_factory.h" | ||
#include "components/bookmarks/browser/bookmark_model.h" | ||
|
||
#include "brave/components/brave_sync/buildflags/buildflags.h" | ||
#if BUILDFLAG(ENABLE_BRAVE_SYNC) | ||
#include "brave/components/brave_sync/brave_profile_sync_service_impl.h" | ||
using brave_sync::BraveProfileSyncServiceImpl; | ||
#endif | ||
|
||
using bookmarks::BookmarkModel; | ||
|
||
BraveBookmarkModelLoadedObserver::BraveBookmarkModelLoadedObserver( | ||
Profile* profile) | ||
: BookmarkModelLoadedObserver(profile) {} | ||
|
||
void BraveBookmarkModelLoadedObserver::BookmarkModelLoaded( | ||
BookmarkModel* model, | ||
bool ids_reassigned) { | ||
#if BUILDFLAG(ENABLE_BRAVE_SYNC) | ||
BraveProfileSyncServiceImpl* brave_profile_service = | ||
static_cast<BraveProfileSyncServiceImpl*>( | ||
ProfileSyncServiceFactory::GetForProfile(profile_)); | ||
// When sync is enabled, we need to send migration records to other devices so | ||
// it is handled in BraveProfileSyncServiceImpl::OnSyncReady | ||
if (!brave_profile_service->IsBraveSyncEnabled()) | ||
BraveMigrateOtherNode(model); | ||
#else | ||
BraveMigrateOtherNode(model); | ||
#endif | ||
BookmarkModelLoadedObserver::BookmarkModelLoaded(model, ids_reassigned); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* Copyright 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_PROFILES_BRAVE_BOOKMARK_MODEL_LOADED_OBSERVER_H_ | ||
#define BRAVE_BROWSER_PROFILES_BRAVE_BOOKMARK_MODEL_LOADED_OBSERVER_H_ | ||
|
||
#include "chrome/browser/profiles/bookmark_model_loaded_observer.h" | ||
|
||
class BraveBookmarkModelLoadedObserver | ||
: public BookmarkModelLoadedObserver { | ||
public: | ||
explicit BraveBookmarkModelLoadedObserver(Profile* profile); | ||
|
||
private: | ||
void BookmarkModelLoaded(bookmarks::BookmarkModel* model, | ||
bool ids_reassigned) override; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(BraveBookmarkModelLoadedObserver); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_PROFILES_BRAVE_BOOKMARK_MODEL_LOADED_OBSERVER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* Copyright 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/ui/bookmark/recently_used_folders_combo_model.h" | ||
|
||
#include "components/bookmarks/browser/bookmark_model.h" | ||
|
||
BraveRecentlyUsedFoldersComboModel::BraveRecentlyUsedFoldersComboModel( | ||
bookmarks::BookmarkModel* model, | ||
const bookmarks::BookmarkNode* node) | ||
: RecentlyUsedFoldersComboModel(model, node) { | ||
RecentlyUsedFoldersComboModel::RemoveNode(model->other_node()); | ||
} | ||
|
||
BraveRecentlyUsedFoldersComboModel::~BraveRecentlyUsedFoldersComboModel() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* Copyright 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_UI_BOOKMARK_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_ | ||
#define BRAVE_BROWSER_UI_BOOKMARK_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_ | ||
|
||
#include "chrome/browser/ui/bookmarks/recently_used_folders_combo_model.h" | ||
|
||
class BraveRecentlyUsedFoldersComboModel | ||
: public RecentlyUsedFoldersComboModel { | ||
public: | ||
BraveRecentlyUsedFoldersComboModel(bookmarks::BookmarkModel* model, | ||
const bookmarks::BookmarkNode* node); | ||
~BraveRecentlyUsedFoldersComboModel() override; | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(BraveRecentlyUsedFoldersComboModel); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_UI_BOOKMARK_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
chromium_src/chrome/browser/profiles/bookmark_model_loaded_observer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* Copyright 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_PROFILES_BOOKMARK_MODEL_LOADED_OBSERVER_H_ | ||
#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_PROFILES_BOOKMARK_MODEL_LOADED_OBSERVER_H_ | ||
|
||
#define BRAVE_BOOKMARK_MODEL_LOADED_OBSERVER_H_ \ | ||
private: \ | ||
friend class BraveBookmarkModelLoadedObserver; \ | ||
\ | ||
public: | ||
#include "../../../../../chrome/browser/profiles/bookmark_model_loaded_observer.h" | ||
|
||
#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_PROFILES_BOOKMARK_MODEL_LOADED_OBSERVER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
chromium_src/chrome/browser/ui/bookmarks/recently_used_folders_combo_model.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* Copyright 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_BOOKMARKS_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_ | ||
#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_BOOKMARKS_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_ | ||
|
||
#define BRAVE_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_ \ | ||
private: \ | ||
friend class BraveRecentlyUsedFoldersComboModel; \ | ||
public: | ||
#include "../../../../../../chrome/browser/ui/bookmarks/recently_used_folders_combo_model.h" // NOLINT | ||
#undef BRAVE_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_ | ||
|
||
#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_BOOKMARKS_RECENTLY_USED_FOLDERS_COMBO_MODEL_H_ |
10 changes: 10 additions & 0 deletions
10
chromium_src/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* Copyright 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/ui/bookmark/recently_used_folders_combo_model.h" | ||
|
||
#define RecentlyUsedFoldersComboModel BraveRecentlyUsedFoldersComboModel | ||
#include "../../../../../../../chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc" | ||
#undef RecentlyUsedFoldersComboModel |
27 changes: 27 additions & 0 deletions
27
chromium_src/components/bookmarks/browser/bookmark_model.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* Copyright 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "../../../../../components/bookmarks/browser/bookmark_model.cc" | ||
|
||
namespace bookmarks { | ||
|
||
// Move bookmarks under "Other Bookmarks" permanent node to a same name folder | ||
// at the end of "Bookmark Bar" permanent node | ||
void BraveMigrateOtherNode(BookmarkModel* model) { | ||
DCHECK(model); | ||
if (!model->other_node()->children().empty()) { | ||
const bookmarks::BookmarkNode* new_other_node = | ||
model->AddFolder(model->bookmark_bar_node(), | ||
model->bookmark_bar_node()->children().size(), | ||
model->other_node()->GetTitledUrlNodeTitle()); | ||
size_t children_size = model->other_node()->children().size(); | ||
for (size_t i = 0; i < children_size; ++i) { | ||
model->Move(model->other_node()->children().front().get(), new_other_node, | ||
i); | ||
} | ||
} | ||
} | ||
|
||
} // namespace bookmarks |
Oops, something went wrong.