Commit d702978d authored by Cheick Cisse's avatar Cheick Cisse Committed by Chromium LUCI CQ

Create new factory action and set up histograms

Create Open javascript action and set up histograms for contextMenu actions

Bug: 1140387
Change-Id: I836eff307c6de1a8b233c3018a9856799bd43513
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2584646
Commit-Queue: Cheick Cisse <cheickcisse@google.com>
Reviewed-by: default avatarSebastien Lalancette <seblalancette@chromium.org>
Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836802}
parent bf1be9f4
...@@ -18,6 +18,7 @@ source_set("menu") { ...@@ -18,6 +18,7 @@ source_set("menu") {
"resources:mark_read", "resources:mark_read",
"resources:move_folder", "resources:move_folder",
"resources:offline", "resources:offline",
"resources:open",
"resources:open_in_incognito", "resources:open_in_incognito",
"resources:open_in_new_tab", "resources:open_in_new_tab",
"resources:open_new_window", "resources:open_new_window",
...@@ -47,6 +48,7 @@ source_set("unit_tests") { ...@@ -47,6 +48,7 @@ source_set("unit_tests") {
"resources:mark_read", "resources:mark_read",
"resources:move_folder", "resources:move_folder",
"resources:offline", "resources:offline",
"resources:open",
"resources:open_in_incognito", "resources:open_in_incognito",
"resources:open_in_new_tab", "resources:open_in_new_tab",
"resources:open_new_window", "resources:open_new_window",
......
...@@ -106,6 +106,10 @@ API_AVAILABLE(ios(13.0)) ...@@ -106,6 +106,10 @@ API_AVAILABLE(ios(13.0))
// invoke the |block| when executed. // invoke the |block| when executed.
- (UIAction*)actionToOpenOfflineVersionInNewTabWithBlock:(ProceduralBlock)block; - (UIAction*)actionToOpenOfflineVersionInNewTabWithBlock:(ProceduralBlock)block;
// Creates a UIAction instance configured for executing JavaScript evalutation
// The action will invoke the |block| when executed.
- (UIAction*)actionToOpenJavascriptWithBlock:(ProceduralBlock)block;
@end @end
#endif // IOS_CHROME_BROWSER_UI_MENU_ACTION_FACTORY_H_ #endif // IOS_CHROME_BROWSER_UI_MENU_ACTION_FACTORY_H_
...@@ -213,4 +213,12 @@ ...@@ -213,4 +213,12 @@
block:block]; block:block];
} }
- (UIAction*)actionToOpenJavascriptWithBlock:(ProceduralBlock)block {
return
[self actionWithTitle:l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_OPEN)
image:[UIImage imageNamed:@"open"]
type:MenuActionType::OpenJavascript
block:block];
}
@end @end
...@@ -376,4 +376,24 @@ TEST_F(ActionFactoryTest, viewOfflineVersion) { ...@@ -376,4 +376,24 @@ TEST_F(ActionFactoryTest, viewOfflineVersion) {
} }
} }
// Tests that the Open with JavaScript evaluation has have the right titles and
// image.
TEST_F(ActionFactoryTest, OpenWithJavaScript) {
if (@available(iOS 13.0, *)) {
ActionFactory* factory =
[[ActionFactory alloc] initWithBrowser:test_browser_.get()
scenario:kTestMenuScenario];
UIImage* expectedImage = [UIImage imageNamed:@"open"];
NSString* expectedTitle =
l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_OPEN);
UIAction* actionWithBlock = [factory actionToOpenJavascriptWithBlock:^{
}];
EXPECT_TRUE([expectedTitle isEqualToString:actionWithBlock.title]);
EXPECT_EQ(expectedImage, actionWithBlock.image);
}
}
#endif // defined(__IPHONE_13_0) #endif // defined(__IPHONE_13_0)
...@@ -23,7 +23,8 @@ enum class MenuActionType { ...@@ -23,7 +23,8 @@ enum class MenuActionType {
Read = 11, Read = 11,
Unread = 12, Unread = 12,
ViewOffline = 13, ViewOffline = 13,
kMaxValue = ViewOffline OpenJavascript = 14,
kMaxValue = OpenJavascript
}; };
#endif // IOS_CHROME_BROWSER_UI_MENU_MENU_ACTION_TYPE_H_ #endif // IOS_CHROME_BROWSER_UI_MENU_MENU_ACTION_TYPE_H_
...@@ -16,7 +16,10 @@ enum class MenuScenario { ...@@ -16,7 +16,10 @@ enum class MenuScenario {
kRecentTabsEntry = 4, kRecentTabsEntry = 4,
kHistoryEntry = 5, kHistoryEntry = 5,
kMostVisitedEntry = 6, kMostVisitedEntry = 6,
kMaxValue = kMostVisitedEntry kContextMenuImage = 7,
kContextMenuImageLink = 8,
kContextMenuLink = 9,
kMaxValue = kContextMenuLink,
}; };
// Records a menu shown histogram metric for the |scenario|. // Records a menu shown histogram metric for the |scenario|.
......
...@@ -29,6 +29,12 @@ const char kHistoryEntryActionsHistogram[] = ...@@ -29,6 +29,12 @@ const char kHistoryEntryActionsHistogram[] =
"Mobile.ContextMenu.HistoryEntry.Actions"; "Mobile.ContextMenu.HistoryEntry.Actions";
const char kMostVisitedEntryActionsHistogram[] = const char kMostVisitedEntryActionsHistogram[] =
"Mobile.ContextMenu.MostVisitedEntry.Actions"; "Mobile.ContextMenu.MostVisitedEntry.Actions";
const char KContextMenuImageActionsHistogram[] =
"Mobile.ContextMenu.WebImage.Actions";
const char KContextMenuImageLinkActionsHistogram[] =
"Mobile.ContextMenu.WebImageLink.Actions";
const char KContextMenuLinkActionsHistogram[] =
"Mobile.ContextMenu.WebLink.Actions";
} // namespace } // namespace
void RecordMenuShown(MenuScenario scenario) { void RecordMenuShown(MenuScenario scenario) {
...@@ -51,5 +57,11 @@ const char* GetActionsHistogramName(MenuScenario scenario) { ...@@ -51,5 +57,11 @@ const char* GetActionsHistogramName(MenuScenario scenario) {
return kMostVisitedEntryActionsHistogram; return kMostVisitedEntryActionsHistogram;
case MenuScenario::kBookmarkFolder: case MenuScenario::kBookmarkFolder:
return kBookmarkFolderActionsHistogram; return kBookmarkFolderActionsHistogram;
case MenuScenario::kContextMenuImage:
return KContextMenuImageActionsHistogram;
case MenuScenario::kContextMenuImageLink:
return KContextMenuImageLinkActionsHistogram;
case MenuScenario::kContextMenuLink:
return KContextMenuLinkActionsHistogram;
} }
} }
...@@ -91,3 +91,11 @@ imageset("offline") { ...@@ -91,3 +91,11 @@ imageset("offline") {
"offline.imageset/offline@3x.png", "offline.imageset/offline@3x.png",
] ]
} }
imageset("open") {
sources = [
"open.imageset/Contents.json",
"open.imageset/open@2x.png",
"open.imageset/open@3x.png",
]
}
{
"images": [
{
"idiom": "universal",
"filename": "open@2x.png",
"scale": "2x"
},
{
"idiom": "universal",
"filename": "open@3x.png",
"scale": "3x"
}
],
"info": {
"author": "xcode",
"version": 1
},
"properties": {
"template-rendering-intent": "template"
}
}
...@@ -39226,6 +39226,10 @@ Called by update_gpu_driver_bug_workaround_entries.py.--> ...@@ -39226,6 +39226,10 @@ Called by update_gpu_driver_bug_workaround_entries.py.-->
<int value="8" label="Delete"/> <int value="8" label="Delete"/>
<int value="9" label="Remove"/> <int value="9" label="Remove"/>
<int value="10" label="Hide"/> <int value="10" label="Hide"/>
<int value="11" label="Mark as Read"/>
<int value="12" label="Mark as Unread"/>
<int value="13" label="View Offline"/>
<int value="14" label="Open (JavaScript evaluation)"/>
</enum> </enum>
<enum name="IOSMenuScenario"> <enum name="IOSMenuScenario">
...@@ -39236,6 +39240,9 @@ Called by update_gpu_driver_bug_workaround_entries.py.--> ...@@ -39236,6 +39240,9 @@ Called by update_gpu_driver_bug_workaround_entries.py.-->
<int value="4" label="Recent Tabs Entry"/> <int value="4" label="Recent Tabs Entry"/>
<int value="5" label="History Entry"/> <int value="5" label="History Entry"/>
<int value="6" label="Most Visited Entry"/> <int value="6" label="Most Visited Entry"/>
<int value="7" label="Image on a Web page"/>
<int value="8" label="Image-Link on a Web page"/>
<int value="9" label="Link on a Web page"/>
</enum> </enum>
<enum name="IOSMultiWindowConfiguration"> <enum name="IOSMultiWindowConfiguration">
...@@ -105,6 +105,9 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -105,6 +105,9 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
<variant name="ReadingListEntry" summary="Reading List entry"/> <variant name="ReadingListEntry" summary="Reading List entry"/>
<variant name="RecentTabsEntry" summary="Recent Tabs entry"/> <variant name="RecentTabsEntry" summary="Recent Tabs entry"/>
<variant name="RecentTabsHeader" summary="Recent Tabs header/device"/> <variant name="RecentTabsHeader" summary="Recent Tabs header/device"/>
<variant name="WebImage" summary="Image on a Web page"/>
<variant name="WebImageLink" summary="Image-Link on a Web page"/>
<variant name="WebLink" summary="Link on a Web page"/>
</token> </token>
</histogram> </histogram>
......
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