-
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.
History sub menu item for all tabs from other synced devices
- Loading branch information
1 parent
8e1e204
commit dde2d41
Showing
5 changed files
with
100 additions
and
0 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
46 changes: 46 additions & 0 deletions
46
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,46 @@ | ||
/* 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 <limits> | ||
|
||
#include "chrome/browser/ui/singleton_tabs.h" | ||
|
||
namespace { | ||
|
||
const char kBraveStubSessionTag[] = "brave_stub_more_session_tag"; | ||
const char kBraveSyncedTabsUrl[] = "brave://history/syncedTabs"; | ||
const int kStubTabId = std::numeric_limits<int32_t>::max() - 1; | ||
|
||
} // namespace | ||
|
||
#define BRAVE_EXECUTE_COMMAND \ | ||
if (item.session_tag == kBraveStubSessionTag) { \ | ||
ShowSingletonTabOverwritingNTP( \ | ||
browser_, \ | ||
GetSingletonTabNavigateParams(browser_, GURL(kBraveSyncedTabsUrl))); \ | ||
return; \ | ||
} | ||
|
||
#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::FromSerializedValue(kStubTabId); \ | ||
} \ | ||
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 | ||
#undef BRAVE_EXECUTE_COMMAND |
19 changes: 19 additions & 0 deletions
19
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,19 @@ | ||
/* 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_; \ | ||
public: | ||
// define BRAVE_RECENT_TABS_SUB_MENU_MODEL_H_ | ||
|
||
#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_ |
20 changes: 20 additions & 0 deletions
20
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,20 @@ | ||
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..d9102ed0aedb4d7c5561438715ec4fa277fc3cde 100644 | ||
--- a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc | ||
+++ b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc | ||
@@ -270,6 +270,7 @@ void RecentTabsSubMenuModel::ExecuteCommand(int command_id, int event_flags) { | ||
const TabNavigationItem& item = (*tab_items)[tab_items_idx]; | ||
DCHECK(item.tab_id.is_valid() && item.url.is_valid()); | ||
|
||
+ BRAVE_EXECUTE_COMMAND | ||
if (item.session_tag.empty()) { // Restore tab of local session. | ||
if (service && context) { | ||
base::RecordAction( | ||
@@ -479,6 +480,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; |