Commit 2be56ad4 authored by Collin Baker's avatar Collin Baker Committed by Commit Bot

Add BrowserWindow method for showing in-product help

This method will show our in-product help and notify when the promo is
finished. This will serve as the plumbing between chrome/browser/ui/
and chrome/browser/ui/views for in-product help.

Bug: 887991
Change-Id: I357853b7f21910945b19022eddda9294a8bebcf3
Reviewed-on: https://chromium-review.googlesource.com/c/1310494
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606252}
parent 3ca3b8cf
...@@ -3283,6 +3283,7 @@ jumbo_split_static_library("ui") { ...@@ -3283,6 +3283,7 @@ jumbo_split_static_library("ui") {
sources += [ sources += [
"in_product_help/active_tab_tracker.cc", "in_product_help/active_tab_tracker.cc",
"in_product_help/active_tab_tracker.h", "in_product_help/active_tab_tracker.h",
"in_product_help/in_product_help.h",
"in_product_help/reopen_tab_in_product_help.cc", "in_product_help/reopen_tab_in_product_help.cc",
"in_product_help/reopen_tab_in_product_help.h", "in_product_help/reopen_tab_in_product_help.h",
"in_product_help/reopen_tab_in_product_help_factory.cc", "in_product_help/reopen_tab_in_product_help_factory.cc",
......
...@@ -21,12 +21,17 @@ ...@@ -21,12 +21,17 @@
#include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h"
#include "chrome/common/buildflags.h" #include "chrome/common/buildflags.h"
#include "components/content_settings/core/common/content_settings_types.h" #include "components/content_settings/core/common/content_settings_types.h"
#include "components/feature_engagement/buildflags.h"
#include "components/signin/core/browser/signin_header_helper.h" #include "components/signin/core/browser/signin_header_helper.h"
#include "components/translate/core/common/translate_errors.h" #include "components/translate/core/common/translate_errors.h"
#include "ui/base/base_window.h" #include "ui/base/base_window.h"
#include "ui/base/window_open_disposition.h" #include "ui/base/window_open_disposition.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
#include "chrome/browser/ui/in_product_help/in_product_help.h"
#endif // BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/apps/intent_helper/apps_navigation_types.h" #include "chrome/browser/chromeos/apps/intent_helper/apps_navigation_types.h"
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
...@@ -433,6 +438,11 @@ class BrowserWindow : public ui::BaseWindow { ...@@ -433,6 +438,11 @@ class BrowserWindow : public ui::BaseWindow {
const base::Callback<void(ImeWarningBubblePermissionStatus status)>& const base::Callback<void(ImeWarningBubblePermissionStatus status)>&
callback) = 0; callback) = 0;
#if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
// Shows in-product help for the given feature.
virtual void ShowInProductHelpPromo(InProductHelpFeature iph_feature) = 0;
#endif
// Returns the platform-specific ID of the workspace the browser window // Returns the platform-specific ID of the workspace the browser window
// currently resides in. // currently resides in.
virtual std::string GetWorkspace() const = 0; virtual std::string GetWorkspace() const = 0;
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_IN_PRODUCT_HELP_IN_PRODUCT_HELP_H_
#define CHROME_BROWSER_UI_IN_PRODUCT_HELP_IN_PRODUCT_HELP_H_
// Identifies a feature that has in-product help. This is used for dispatching
// in-product help promos from a |BrowserWindow| object.
enum class InProductHelpFeature {
// For |ReopenTabInProductHelp|
kReopenTab,
};
#endif // CHROME_BROWSER_UI_IN_PRODUCT_HELP_IN_PRODUCT_HELP_H_
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include "chrome/browser/feature_engagement/tracker_factory.h" #include "chrome/browser/feature_engagement/tracker_factory.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/in_product_help/in_product_help.h"
#include "components/feature_engagement/public/event_constants.h" #include "components/feature_engagement/public/event_constants.h"
#include "components/feature_engagement/public/feature_constants.h" #include "components/feature_engagement/public/feature_constants.h"
#include "components/feature_engagement/public/tracker.h" #include "components/feature_engagement/public/tracker.h"
...@@ -56,6 +58,10 @@ void ReopenTabInProductHelp::TabReopened() { ...@@ -56,6 +58,10 @@ void ReopenTabInProductHelp::TabReopened() {
GetTracker()->NotifyEvent(feature_engagement::events::kTabReopened); GetTracker()->NotifyEvent(feature_engagement::events::kTabReopened);
} }
void ReopenTabInProductHelp::HelpDismissed() {
trigger_.HelpDismissed();
}
void ReopenTabInProductHelp::OnActiveTabClosed( void ReopenTabInProductHelp::OnActiveTabClosed(
TabStripModel* tab_strip_model, TabStripModel* tab_strip_model,
base::TimeDelta active_duration) { base::TimeDelta active_duration) {
...@@ -63,10 +69,9 @@ void ReopenTabInProductHelp::OnActiveTabClosed( ...@@ -63,10 +69,9 @@ void ReopenTabInProductHelp::OnActiveTabClosed(
} }
void ReopenTabInProductHelp::OnShowHelp() { void ReopenTabInProductHelp::OnShowHelp() {
// Here, we would get the last active browser and trigger our IPH in it. For auto* browser = BrowserList::GetInstance()->GetLastActive();
// now, we just say IPH was immediately dismissed. TODO(collinbaker): DCHECK(browser);
// implement call into views-side to display IPH. browser->window()->ShowInProductHelpPromo(InProductHelpFeature::kReopenTab);
trigger_.HelpDismissed();
} }
void ReopenTabInProductHelp::OnBrowserAdded(Browser* browser) { void ReopenTabInProductHelp::OnBrowserAdded(Browser* browser) {
......
...@@ -37,13 +37,19 @@ class ReopenTabInProductHelp : public BrowserListObserver, public KeyedService { ...@@ -37,13 +37,19 @@ class ReopenTabInProductHelp : public BrowserListObserver, public KeyedService {
// Should be called when the user opens a blank new tab. // Should be called when the user opens a blank new tab.
void NewTabOpened(); void NewTabOpened();
// Should be called when the user focuses on the omnibox. Possibly triggers // Should be called when the user focuses on the omnibox. Possibly triggers
// IPH. // IPH.
void OmniboxFocused(); void OmniboxFocused();
// Should be called when the user reopens a previously closed tab, either // Should be called when the user reopens a previously closed tab, either
// through CTRL+SHIFT+T or through the recent tabs menu. // through CTRL+SHIFT+T or through the recent tabs menu.
void TabReopened(); void TabReopened();
// Must be called when IPH promo finishes showing, whether by use of the
// feature or by timing out.
void HelpDismissed();
private: private:
// BrowserListObserver: // BrowserListObserver:
void OnBrowserAdded(Browser* browser) override; void OnBrowserAdded(Browser* browser) override;
......
...@@ -61,7 +61,6 @@ TEST_F(ReopenTabInProductHelpTest, TriggersIPH) { ...@@ -61,7 +61,6 @@ TEST_F(ReopenTabInProductHelpTest, TriggersIPH) {
EXPECT_CALL(*mock_tracker, ShouldTriggerHelpUI(_)) EXPECT_CALL(*mock_tracker, ShouldTriggerHelpUI(_))
.Times(1) .Times(1)
.WillOnce(Return(true)); .WillOnce(Return(true));
EXPECT_CALL(*mock_tracker, Dismissed(_)).Times(1);
AddTab(browser(), GURL("chrome://blank")); AddTab(browser(), GURL("chrome://blank"));
AddTab(browser(), GURL("chrome://blank")); AddTab(browser(), GURL("chrome://blank"));
......
...@@ -191,6 +191,11 @@ ...@@ -191,6 +191,11 @@
#include "ui/views/win/scoped_fullscreen_visibility.h" #include "ui/views/win/scoped_fullscreen_visibility.h"
#endif #endif
#if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
#include "chrome/browser/ui/in_product_help/reopen_tab_in_product_help.h"
#include "chrome/browser/ui/in_product_help/reopen_tab_in_product_help_factory.h"
#endif // BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
#if BUILDFLAG(ENABLE_ONE_CLICK_SIGNIN) #if BUILDFLAG(ENABLE_ONE_CLICK_SIGNIN)
#include "chrome/browser/ui/sync/one_click_signin_links_delegate_impl.h" #include "chrome/browser/ui/sync/one_click_signin_links_delegate_impl.h"
#include "chrome/browser/ui/views/sync/one_click_signin_dialog_view.h" #include "chrome/browser/ui/views/sync/one_click_signin_dialog_view.h"
...@@ -2944,6 +2949,18 @@ bool BrowserView::IsVisibleOnAllWorkspaces() const { ...@@ -2944,6 +2949,18 @@ bool BrowserView::IsVisibleOnAllWorkspaces() const {
return frame_->IsVisibleOnAllWorkspaces(); return frame_->IsVisibleOnAllWorkspaces();
} }
#if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
void BrowserView::ShowInProductHelpPromo(InProductHelpFeature iph_feature) {
switch (iph_feature) {
case InProductHelpFeature::kReopenTab:
// TODO(collinbaker): start in-product help flow here.
ReopenTabInProductHelpFactory::GetForProfile(browser()->profile())
->HelpDismissed();
break;
}
}
#endif
bool BrowserView::DoCutCopyPasteForWebContents( bool BrowserView::DoCutCopyPasteForWebContents(
WebContents* contents, WebContents* contents,
void (WebContents::*method)()) { void (WebContents::*method)()) {
......
...@@ -417,6 +417,10 @@ class BrowserView : public BrowserWindow, ...@@ -417,6 +417,10 @@ class BrowserView : public BrowserWindow,
BookmarkBarView* GetBookmarkBarView() const; BookmarkBarView* GetBookmarkBarView() const;
LocationBarView* GetLocationBarView() const; LocationBarView* GetLocationBarView() const;
#if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
void ShowInProductHelpPromo(InProductHelpFeature iph_feature) override;
#endif
// TabStripModelObserver: // TabStripModelObserver:
void OnTabStripModelChanged( void OnTabStripModelChanged(
TabStripModel* tab_strip_model, TabStripModel* tab_strip_model,
......
...@@ -169,6 +169,10 @@ class TestBrowserWindow : public BrowserWindow { ...@@ -169,6 +169,10 @@ class TestBrowserWindow : public BrowserWindow {
std::string GetWorkspace() const override; std::string GetWorkspace() const override;
bool IsVisibleOnAllWorkspaces() const override; bool IsVisibleOnAllWorkspaces() const override;
#if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
void ShowInProductHelpPromo(InProductHelpFeature iph_feature) override {}
#endif
protected: protected:
void DestroyBrowser() override {} void DestroyBrowser() override {}
......
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