Commit aec07851 authored by Christopher Benson's avatar Christopher Benson Committed by Commit Bot

NewTabButton::OnWidgetDestroying notifies IPH when promo is dismissed

Changes on this CL
- Moved profile() declarations to virtual TabStripController class. 

Bug: 734132
Change-Id: I1a3b5ebb8aa75f40317aef88b25ff74454fc2778
Reviewed-on: https://chromium-review.googlesource.com/585355
Commit-Queue: Christopher Benson <chrisbenson@google.com>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491603}
parent bd970cbf
...@@ -357,9 +357,8 @@ void BrowserTabStripController::PerformDrop(bool drop_before, ...@@ -357,9 +357,8 @@ void BrowserTabStripController::PerformDrop(bool drop_before,
} }
bool BrowserTabStripController::IsCompatibleWith(TabStrip* other) const { bool BrowserTabStripController::IsCompatibleWith(TabStrip* other) const {
Profile* other_profile = Profile* other_profile = other->controller()->GetProfile();
static_cast<BrowserTabStripController*>(other->controller())->profile(); return other_profile == GetProfile();
return other_profile == profile();
} }
void BrowserTabStripController::CreateNewTab() { void BrowserTabStripController::CreateNewTab() {
...@@ -376,8 +375,9 @@ void BrowserTabStripController::CreateNewTabWithLocation( ...@@ -376,8 +375,9 @@ void BrowserTabStripController::CreateNewTabWithLocation(
// Use autocomplete to clean up the text, going so far as to turn it into // Use autocomplete to clean up the text, going so far as to turn it into
// a search query if necessary. // a search query if necessary.
AutocompleteMatch match; AutocompleteMatch match;
AutocompleteClassifierFactory::GetForProfile(profile())->Classify( AutocompleteClassifierFactory::GetForProfile(GetProfile())
location, false, false, metrics::OmniboxEventProto::BLANK, &match, NULL); ->Classify(location, false, false, metrics::OmniboxEventProto::BLANK,
&match, NULL);
if (match.destination_url.is_valid()) if (match.destination_url.is_valid())
model_->delegate()->AddTabAt(match.destination_url, -1, true); model_->delegate()->AddTabAt(match.destination_url, -1, true);
} }
...@@ -432,6 +432,10 @@ base::string16 BrowserTabStripController::GetAccessibleTabName( ...@@ -432,6 +432,10 @@ base::string16 BrowserTabStripController::GetAccessibleTabName(
false /* include_app_name */, tabstrip_->GetModelIndexOfTab(tab)); false /* include_app_name */, tabstrip_->GetModelIndexOfTab(tab));
} }
Profile* BrowserTabStripController::GetProfile() const {
return model_->profile();
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// BrowserTabStripController, TabStripModelObserver implementation: // BrowserTabStripController, TabStripModelObserver implementation:
......
...@@ -78,6 +78,7 @@ class BrowserTabStripController : public TabStripController, ...@@ -78,6 +78,7 @@ class BrowserTabStripController : public TabStripController,
void CheckFileSupported(const GURL& url) override; void CheckFileSupported(const GURL& url) override;
SkColor GetToolbarTopSeparatorColor() const override; SkColor GetToolbarTopSeparatorColor() const override;
base::string16 GetAccessibleTabName(const Tab* tab) const override; base::string16 GetAccessibleTabName(const Tab* tab) const override;
Profile* GetProfile() const override;
// TabStripModelObserver implementation: // TabStripModelObserver implementation:
void TabInsertedAt(TabStripModel* tab_strip_model, void TabInsertedAt(TabStripModel* tab_strip_model,
...@@ -119,8 +120,6 @@ class BrowserTabStripController : public TabStripController, ...@@ -119,8 +120,6 @@ class BrowserTabStripController : public TabStripController,
TabRendererData* data, TabRendererData* data,
TabStatus tab_status); TabStatus tab_status);
Profile* profile() const { return model_->profile(); }
const TabStrip* tabstrip() const { return tabstrip_; } const TabStrip* tabstrip() const { return tabstrip_; }
private: private:
......
...@@ -153,3 +153,7 @@ base::string16 FakeBaseTabStripController::GetAccessibleTabName( ...@@ -153,3 +153,7 @@ base::string16 FakeBaseTabStripController::GetAccessibleTabName(
const Tab* tab) const { const Tab* tab) const {
return base::string16(); return base::string16();
} }
Profile* FakeBaseTabStripController::GetProfile() const {
return nullptr;
}
...@@ -56,6 +56,7 @@ class FakeBaseTabStripController : public TabStripController { ...@@ -56,6 +56,7 @@ class FakeBaseTabStripController : public TabStripController {
void CheckFileSupported(const GURL& url) override; void CheckFileSupported(const GURL& url) override;
SkColor GetToolbarTopSeparatorColor() const override; SkColor GetToolbarTopSeparatorColor() const override;
base::string16 GetAccessibleTabName(const Tab* tab) const override; base::string16 GetAccessibleTabName(const Tab* tab) const override;
Profile* GetProfile() const override;
private: private:
TabStrip* tab_strip_; TabStrip* tab_strip_;
......
...@@ -4,8 +4,10 @@ ...@@ -4,8 +4,10 @@
#include "chrome/browser/ui/views/tabs/new_tab_button.h" #include "chrome/browser/ui/views/tabs/new_tab_button.h"
#include "build/build_config.h"
#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h"
#include "chrome/browser/ui/views/tabs/new_tab_promo.h" #include "chrome/browser/ui/views/tabs/new_tab_promo.h"
#include "third_party/skia/include/core/SkColorFilter.h" #include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/effects/SkBlurMaskFilter.h" #include "third_party/skia/include/effects/SkBlurMaskFilter.h"
...@@ -22,6 +24,11 @@ ...@@ -22,6 +24,11 @@
#include "ui/views/win/hwnd_util.h" #include "ui/views/win/hwnd_util.h"
#endif #endif
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) && !defined(OS_MACOSX)
#include "chrome/browser/feature_engagement/new_tab/new_tab_tracker.h"
#include "chrome/browser/feature_engagement/new_tab/new_tab_tracker_factory.h"
#endif
namespace { namespace {
sk_sp<SkDrawLooper> CreateShadowDrawLooper(SkColor color) { sk_sp<SkDrawLooper> CreateShadowDrawLooper(SkColor color) {
...@@ -177,6 +184,11 @@ bool NewTabButton::GetHitTestMask(gfx::Path* mask) const { ...@@ -177,6 +184,11 @@ bool NewTabButton::GetHitTestMask(gfx::Path* mask) const {
} }
void NewTabButton::OnWidgetDestroying(views::Widget* widget) { void NewTabButton::OnWidgetDestroying(views::Widget* widget) {
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) && !defined(OS_MACOSX)
feature_engagement::NewTabTrackerFactory::GetInstance()
->GetForProfile(tab_strip_->controller()->GetProfile())
->DismissNewTabTracker();
#endif
new_tab_promo_observer_.Remove(widget); new_tab_promo_observer_.Remove(widget);
// When the promo widget is destroyed, the NewTabButton needs to be // When the promo widget is destroyed, the NewTabButton needs to be
// recolored. // recolored.
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_CONTROLLER_H_ #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_CONTROLLER_H_
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/views/tabs/tab_strip_types.h" #include "chrome/browser/ui/views/tabs/tab_strip_types.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/base/ui_base_types.h" #include "ui/base/ui_base_types.h"
...@@ -126,6 +127,9 @@ class TabStripController { ...@@ -126,6 +127,9 @@ class TabStripController {
// Returns the accessible tab name. // Returns the accessible tab name.
virtual base::string16 GetAccessibleTabName(const Tab* tab) const = 0; virtual base::string16 GetAccessibleTabName(const Tab* tab) const = 0;
// Returns the profile associated with the Tabstrip.
virtual Profile* GetProfile() const = 0;
}; };
#endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_CONTROLLER_H_ #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_CONTROLLER_H_
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