Commit 813b39ff authored by Tina Wang's avatar Tina Wang Committed by Commit Bot

[SendTabToSelf] Add specific target device ID and name to CreateNewEntry Calls on Desktop

Add target device id and name when create a new entry on desktop.

Bug: 946804
Change-Id: I1b5dab7f7edbdb27779aec8756fb785508548a59
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1617124Reviewed-by: default avatarJeffrey Cohen <jeffreycohen@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Tina Wang <tinazwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#661080}
parent cf6f77a2
...@@ -2078,14 +2078,13 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) { ...@@ -2078,14 +2078,13 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) {
case IDC_SEND_TAB_TO_SELF: case IDC_SEND_TAB_TO_SELF:
send_tab_to_self::RecordSendTabToSelfClickResult( send_tab_to_self::RecordSendTabToSelfClickResult(
send_tab_to_self::kContentMenu, SendTabToSelfClickResult::kClickItem); send_tab_to_self::kContentMenu, SendTabToSelfClickResult::kClickItem);
send_tab_to_self::CreateNewEntry(embedder_web_contents_); // TODO(crbug/945988): add histograms to count valid device number.
break; break;
case IDC_CONTENT_LINK_SEND_TAB_TO_SELF: case IDC_CONTENT_LINK_SEND_TAB_TO_SELF:
send_tab_to_self::RecordSendTabToSelfClickResult( send_tab_to_self::RecordSendTabToSelfClickResult(
send_tab_to_self::kLinkMenu, SendTabToSelfClickResult::kClickItem); send_tab_to_self::kLinkMenu, SendTabToSelfClickResult::kClickItem);
send_tab_to_self::CreateNewEntry(embedder_web_contents_, // TODO(crbug/945988): add histograms to count valid device number.
params_.link_url);
break; break;
case IDC_RELOAD: case IDC_RELOAD:
......
...@@ -27,7 +27,10 @@ ...@@ -27,7 +27,10 @@
namespace send_tab_to_self { namespace send_tab_to_self {
void CreateNewEntry(content::WebContents* tab, const GURL& link_url) { void CreateNewEntry(content::WebContents* tab,
const std::string& target_device_name,
const std::string& target_device_guid,
const GURL& link_url) {
content::NavigationEntry* navigation_entry = content::NavigationEntry* navigation_entry =
tab->GetController().GetLastCommittedEntry(); tab->GetController().GetLastCommittedEntry();
Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext());
...@@ -35,9 +38,6 @@ void CreateNewEntry(content::WebContents* tab, const GURL& link_url) { ...@@ -35,9 +38,6 @@ void CreateNewEntry(content::WebContents* tab, const GURL& link_url) {
std::string title = base::UTF16ToUTF8(navigation_entry->GetTitle()); std::string title = base::UTF16ToUTF8(navigation_entry->GetTitle());
base::Time navigation_time = navigation_entry->GetTimestamp(); base::Time navigation_time = navigation_entry->GetTimestamp();
// TODO(crbug/946804) Add target device.
std::string target_device_guid;
std::string target_device_name;
SendTabToSelfModel* model = SendTabToSelfModel* model =
SendTabToSelfSyncServiceFactory::GetForProfile(profile) SendTabToSelfSyncServiceFactory::GetForProfile(profile)
->GetSendTabToSelfModel(); ->GetSendTabToSelfModel();
......
...@@ -37,7 +37,10 @@ const char kTabMenu[] = "TabMenu"; ...@@ -37,7 +37,10 @@ const char kTabMenu[] = "TabMenu";
// Add a new entry to SendTabToSelfModel when user click "Share to your // Add a new entry to SendTabToSelfModel when user click "Share to your
// devices" option. // devices" option.
void CreateNewEntry(content::WebContents* tab, const GURL& link_url = GURL()); void CreateNewEntry(content::WebContents* tab,
const std::string& target_device_name,
const std::string& target_device_guid,
const GURL& link_url = GURL());
// Get the icon for send tab to self menu item. // Get the icon for send tab to self menu item.
gfx::ImageSkia* GetImageSkia(); gfx::ImageSkia* GetImageSkia();
......
...@@ -96,23 +96,25 @@ TEST_F(SendTabToSelfDesktopUtilTest, CreateNewEntry) { ...@@ -96,23 +96,25 @@ TEST_F(SendTabToSelfDesktopUtilTest, CreateNewEntry) {
GURL url = entry->GetURL(); GURL url = entry->GetURL();
std::string title = base::UTF16ToUTF8(entry->GetTitle()); std::string title = base::UTF16ToUTF8(entry->GetTitle());
base::Time navigation_time = entry->GetTimestamp(); base::Time navigation_time = entry->GetTimestamp();
std::string target_device_sync_cache_name;
std::string target_device_sync_cache_guid; std::string target_device_sync_cache_guid;
SendTabToSelfModelMock* model_mock = static_cast<SendTabToSelfModelMock*>( SendTabToSelfModelMock* model_mock = static_cast<SendTabToSelfModelMock*>(
SendTabToSelfSyncServiceFactory::GetForProfile(profile()) SendTabToSelfSyncServiceFactory::GetForProfile(profile())
->GetSendTabToSelfModel()); ->GetSendTabToSelfModel());
// TODO(crbug/946804) Add target Device to createNewEntry call.
EXPECT_CALL(*model_mock, AddEntry(url, title, navigation_time, EXPECT_CALL(*model_mock, AddEntry(url, title, navigation_time,
target_device_sync_cache_guid)) target_device_sync_cache_guid))
.WillOnce(testing::Return(nullptr)); .WillOnce(testing::Return(nullptr));
CreateNewEntry(tab); CreateNewEntry(tab, target_device_sync_cache_name,
target_device_sync_cache_guid);
GURL link_url = GURL("https://www.1112233.com"); GURL link_url = GURL("https://www.1112233.com");
EXPECT_CALL(*model_mock, AddEntry(link_url, "", base::Time(), EXPECT_CALL(*model_mock, AddEntry(link_url, "", base::Time(),
target_device_sync_cache_guid)) target_device_sync_cache_guid))
.WillOnce(testing::Return(nullptr)); .WillOnce(testing::Return(nullptr));
CreateNewEntry(tab, link_url); CreateNewEntry(tab, target_device_sync_cache_name,
target_device_sync_cache_guid, link_url);
} }
} // namespace } // namespace
......
...@@ -1191,7 +1191,7 @@ void TabStripModel::ExecuteContextMenuCommand(int context_index, ...@@ -1191,7 +1191,7 @@ void TabStripModel::ExecuteContextMenuCommand(int context_index,
case CommandSendTabToSelf: { case CommandSendTabToSelf: {
send_tab_to_self::RecordSendTabToSelfClickResult( send_tab_to_self::RecordSendTabToSelfClickResult(
send_tab_to_self::kTabMenu, SendTabToSelfClickResult::kClickItem); send_tab_to_self::kTabMenu, SendTabToSelfClickResult::kClickItem);
send_tab_to_self::CreateNewEntry(GetActiveWebContents()); // TODO(crbug/945988): add histograms to count valid device number.
break; break;
} }
......
...@@ -497,7 +497,7 @@ void OmniboxViewViews::ExecuteCommand(int command_id, int event_flags) { ...@@ -497,7 +497,7 @@ void OmniboxViewViews::ExecuteCommand(int command_id, int event_flags) {
case IDC_SEND_TAB_TO_SELF: case IDC_SEND_TAB_TO_SELF:
send_tab_to_self::RecordSendTabToSelfClickResult( send_tab_to_self::RecordSendTabToSelfClickResult(
send_tab_to_self::kOmniboxMenu, SendTabToSelfClickResult::kClickItem); send_tab_to_self::kOmniboxMenu, SendTabToSelfClickResult::kClickItem);
send_tab_to_self::CreateNewEntry(location_bar_view_->GetWebContents()); // TODO(crbug/945988): add histograms to count valid device number.
return; return;
// These commands do invoke the popup. // These commands do invoke the popup.
......
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