-
Notifications
You must be signed in to change notification settings - Fork 891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get back Tabs from other devices
history section;
#7121
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,37 @@ | ||
# Copyright (c) 2020 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/. | ||
|
||
assert(!is_android && !is_ios) | ||
|
||
source_set("brave_app_menu_unit_test") { | ||
testonly = true | ||
|
||
public_deps = [ | ||
"//testing/gmock", | ||
"//testing/gtest", | ||
] | ||
|
||
sources = [ | ||
"//chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.cc", | ||
"//chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.h", | ||
"//chrome/browser/ui/toolbar/recent_tabs_sub_menu_model_unittest.cc", | ||
"//chrome/test/base/browser_with_test_window_test.cc", | ||
"//chrome/test/base/browser_with_test_window_test.h", | ||
"//chrome/test/base/menu_model_test.cc", | ||
"//chrome/test/base/menu_model_test.h", | ||
] | ||
|
||
deps = [ | ||
"//chrome/app:command_ids", | ||
"//chrome/browser/ui:ui", | ||
"//chrome/test:test_support", | ||
"//components/constrained_window:constrained_window", | ||
"//components/sessions:test_support", | ||
"//components/sync_preferences:sync_preferences", | ||
"//components/sync_sessions:sync_sessions", | ||
"//content/test:test_support", | ||
"//ui/views:test_support", | ||
] | ||
} |
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,30 @@ | ||
/* Copyright (c) 2020 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_TOOLBAR_BRAVE_RECENT_TABS_SUB_MENU_MODEL_H_ | ||
#define BRAVE_BROWSER_UI_TOOLBAR_BRAVE_RECENT_TABS_SUB_MENU_MODEL_H_ | ||
|
||
#include "chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h" | ||
|
||
class Browser; | ||
|
||
namespace ui { | ||
class AcceleratorProvider; | ||
} | ||
|
||
class BraveRecentTabsSubMenuModel : public RecentTabsSubMenuModel { | ||
public: | ||
BraveRecentTabsSubMenuModel(ui::AcceleratorProvider* accelerator_provider, | ||
Browser* browser); | ||
|
||
~BraveRecentTabsSubMenuModel() override; | ||
|
||
void ExecuteCommand(int command_id, int event_flags) override; | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(BraveRecentTabsSubMenuModel); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_UI_TOOLBAR_BRAVE_RECENT_TABS_SUB_MENU_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,12 @@ | ||
/* Copyright (c) 2020 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/toolbar/brave_recent_tabs_sub_menu_model.h" | ||
|
||
#define RecentTabsSubMenuModel BraveRecentTabsSubMenuModel | ||
|
||
#include "../../../../../../chrome/browser/ui/toolbar/app_menu_model.cc" | ||
|
||
#undef RecentTabsSubMenuModel |
66 changes: 66 additions & 0 deletions
66
chromium_src/chrome/browser/ui/toolbar/recent_tabs_sub_menu_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,66 @@ | ||
/* Copyright (c) 2020 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 "chrome/browser/ui/singleton_tabs.h" | ||
|
||
namespace { | ||
|
||
const char kBraveStubSessionTag[] = "brave_stub_more_session_tag"; | ||
const char kBraveSyncedTabsUrl[] = "brave://history/syncedTabs"; | ||
|
||
} // namespace | ||
|
||
#define BRAVE_BUILD_TABS_FROM_OTHER_DEVICES \ | ||
if (tabs_in_session.size() > kMaxTabsPerSessionToShow) { \ | ||
/* Not all the tabs are shown in menu */ \ | ||
if (!stub_tab_.get()) { \ | ||
stub_tab_.reset(new sessions::SessionTab()); \ | ||
sessions::SerializedNavigationEntry stub_nav_entry; \ | ||
stub_nav_entry.set_title( \ | ||
l10n_util::GetStringUTF16(IDS_OPEN_MORE_OTHER_DEVICES_SESSIONS)); \ | ||
stub_nav_entry.set_virtual_url(GURL(kBraveSyncedTabsUrl)); \ | ||
stub_tab_->navigations.push_back(stub_nav_entry); \ | ||
stub_tab_->tab_id = SessionID::NewUnique(); \ | ||
} \ | ||
tabs_in_session[kMaxTabsPerSessionToShow] = stub_tab_.get(); \ | ||
BuildOtherDevicesTabItem(kBraveStubSessionTag, \ | ||
*tabs_in_session[kMaxTabsPerSessionToShow]); \ | ||
} | ||
|
||
#include "../../../../../../chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc" | ||
|
||
#undef BRAVE_BUILD_TABS_FROM_OTHER_DEVICES | ||
|
||
#include "brave/browser/ui/toolbar/brave_recent_tabs_sub_menu_model.h" | ||
|
||
// Methods of BraveRecentTabsSubMenuModel are implemented below instead of | ||
// brave_recent_tabs_sub_menu_model.cc to have the access to functions in | ||
// anonymous namespace in recent_tabs_sub_menu_model.cc | ||
|
||
BraveRecentTabsSubMenuModel::BraveRecentTabsSubMenuModel( | ||
ui::AcceleratorProvider* accelerator_provider, | ||
Browser* browser) | ||
: RecentTabsSubMenuModel(accelerator_provider, browser) {} | ||
|
||
BraveRecentTabsSubMenuModel::~BraveRecentTabsSubMenuModel() {} | ||
|
||
void BraveRecentTabsSubMenuModel::ExecuteCommand(int command_id, | ||
int event_flags) { | ||
if (IsTabModelCommandId(command_id)) { | ||
TabNavigationItems* tab_items = NULL; | ||
int tab_items_idx = CommandIdToTabVectorIndex(command_id, &tab_items); | ||
const TabNavigationItem& item = (*tab_items)[tab_items_idx]; | ||
DCHECK(item.tab_id.is_valid() && item.url.is_valid()); | ||
|
||
if (item.session_tag == kBraveStubSessionTag) { | ||
ShowSingletonTabOverwritingNTP( | ||
browser_, | ||
GetSingletonTabNavigateParams(browser_, GURL(kBraveSyncedTabsUrl))); | ||
return; | ||
} | ||
} | ||
|
||
RecentTabsSubMenuModel::ExecuteCommand(command_id, event_flags); | ||
} |
18 changes: 18 additions & 0 deletions
18
chromium_src/chrome/browser/ui/toolbar/recent_tabs_sub_menu_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,18 @@ | ||
/* Copyright (c) 2020 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_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_ | ||
#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_ | ||
|
||
#define BRAVE_RECENT_TABS_SUB_MENU_MODEL_H_ \ | ||
private: \ | ||
std::auto_ptr<sessions::SessionTab> stub_tab_; \ | ||
friend class BraveRecentTabsSubMenuModel; \ | ||
public: | ||
#include "../../../../../../chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h" | ||
|
||
#undef BRAVE_RECENT_TABS_SUB_MENU_MODEL_H_ | ||
|
||
#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_ |
32 changes: 32 additions & 0 deletions
32
chromium_src/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model_unittest.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,32 @@ | ||
/* Copyright (c) 2020 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/. */ | ||
|
||
// Disabling these tests because they refer g_brave_browser_process which is not | ||
// initialized in unit tests, is null and so they are crashing. | ||
// Not related to change in RecentTabsSubMenuModel for additional `More...` | ||
// menu item | ||
#define RecentlyClosedTabsFromCurrentSession \ | ||
DISABLED_RecentlyClosedTabsFromCurrentSession | ||
|
||
#define RecentlyClosedTabsAndWindowsFromLastSession \ | ||
DISABLED_RecentlyClosedTabsAndWindowsFromLastSession | ||
|
||
// Need to expect more items at that place, because Brave has additional item | ||
// `More...` which redirects to brave://history/syncedTabs | ||
// The perfect way is to have | ||
// EXPECT_EQ(10, num_items) | ||
// instead | ||
// EXPECT_EQ(9, num_items); | ||
// But in favor to reduce patch, just decrease num_items: | ||
#define BRAVE_MAX_TABS_PER_SESSION_AND_RECENCY \ | ||
--num_items; | ||
|
||
// The case when number of tabs on other device is <=4 so we do not add | ||
// `More...` item is tested by RecentTabsSubMenuModelTest.MaxSessionsAndRecency | ||
|
||
#include "../../../../../../chrome/browser/ui/toolbar/recent_tabs_sub_menu_model_unittest.cc" | ||
|
||
#undef RecentlyClosedTabsAndWindowsFromLastSession | ||
#undef RecentlyClosedTabsFromCurrentSession |
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 was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
patches/chrome-browser-resources-history-side_bar.html.patch
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
patches/chrome-browser-resources-history-synced_device_manager.html.patch
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,20 @@ | ||
diff --git a/chrome/browser/resources/history/synced_device_manager.html b/chrome/browser/resources/history/synced_device_manager.html | ||
index d03a367a7cb1ea6ccad6478a2300606b4c20829a..bfa8a2debda7e0c35b217cea85df668232c5507b 100644 | ||
--- a/chrome/browser/resources/history/synced_device_manager.html | ||
+++ b/chrome/browser/resources/history/synced_device_manager.html | ||
@@ -73,6 +73,7 @@ | ||
guestSession_)]]"> | ||
[[noSyncedTabsMessage(fetchingSyncedTabs_, searchTerm)]] | ||
</div> | ||
+<!-- | ||
<div id="sign-in-guide" | ||
hidden="[[!showSignInGuide(signInState, guestSession_)]]"> | ||
<div id="illustration"></div> | ||
@@ -83,6 +84,7 @@ | ||
$i18n{signInButton} | ||
</cr-button> | ||
</div> | ||
+--> | ||
|
||
<cr-lazy-render id="menu"> | ||
<template> |
12 changes: 12 additions & 0 deletions
12
patches/chrome-browser-ui-toolbar-recent_tabs_sub_menu_model.cc.patch
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,12 @@ | ||
diff --git a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc | ||
index 8cdfc6fbdddcb13bcd5e198cd6ebf53abfb0269d..719d296a16ae05e6d8c897af91684b4efa3527fa 100644 | ||
--- a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc | ||
+++ b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc | ||
@@ -479,6 +479,7 @@ void RecentTabsSubMenuModel::BuildTabsFromOtherDevices() { | ||
BuildOtherDevicesTabItem(session_tag, *tabs_in_session[k]); | ||
} // for all tabs in one session | ||
|
||
+ BRAVE_BUILD_TABS_FROM_OTHER_DEVICES | ||
++num_sessions_added; | ||
} // for all sessions | ||
|
12 changes: 12 additions & 0 deletions
12
patches/chrome-browser-ui-toolbar-recent_tabs_sub_menu_model.h.patch
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,12 @@ | ||
diff --git a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h | ||
index 911131f854b202f2aa8b48377d7e287ce27c652b..46aee818d4872246cc531a78fcace8b2fa25cb15 100644 | ||
--- a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h | ||
+++ b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h | ||
@@ -75,6 +75,7 @@ class RecentTabsSubMenuModel : public ui::SimpleMenuModel, | ||
bool GetURLAndTitleForItemAtIndex(int index, | ||
std::string* url, | ||
base::string16* title); | ||
+ BRAVE_RECENT_TABS_SUB_MENU_MODEL_H_ | ||
|
||
private: | ||
struct TabNavigationItem; |
12 changes: 12 additions & 0 deletions
12
patches/chrome-browser-ui-toolbar-recent_tabs_sub_menu_model_unittest.cc.patch
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,12 @@ | ||
diff --git a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model_unittest.cc b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model_unittest.cc | ||
index 737e6bae0885c335ee8028704827563fc1bd2eea..1fa69f30bf2bd62f7f4aa0faf1ab0beea4ddefcd 100644 | ||
--- a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model_unittest.cc | ||
+++ b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model_unittest.cc | ||
@@ -675,6 +675,7 @@ TEST_F(RecentTabsSubMenuModelTest, MaxTabsPerSessionAndRecency) { | ||
|
||
TestRecentTabsSubMenuModel model(nullptr, browser()); | ||
int num_items = model.GetItemCount(); | ||
+ BRAVE_MAX_TABS_PER_SESSION_AND_RECENCY | ||
EXPECT_EQ(9, num_items); | ||
|
||
std::vector<base::string16> tab_titles = |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This patch shouldn't be in the PR. No need to rerun CI if you remove it.