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,
}
bool BrowserTabStripController::IsCompatibleWith(TabStrip* other) const {
Profile* other_profile =
static_cast<BrowserTabStripController*>(other->controller())->profile();
return other_profile == profile();
Profile* other_profile = other->controller()->GetProfile();
return other_profile == GetProfile();
}
void BrowserTabStripController::CreateNewTab() {
......@@ -376,8 +375,9 @@ void BrowserTabStripController::CreateNewTabWithLocation(
// Use autocomplete to clean up the text, going so far as to turn it into
// a search query if necessary.
AutocompleteMatch match;
AutocompleteClassifierFactory::GetForProfile(profile())->Classify(
location, false, false, metrics::OmniboxEventProto::BLANK, &match, NULL);
AutocompleteClassifierFactory::GetForProfile(GetProfile())
->Classify(location, false, false, metrics::OmniboxEventProto::BLANK,
&match, NULL);
if (match.destination_url.is_valid())
model_->delegate()->AddTabAt(match.destination_url, -1, true);
}
......@@ -432,6 +432,10 @@ base::string16 BrowserTabStripController::GetAccessibleTabName(
false /* include_app_name */, tabstrip_->GetModelIndexOfTab(tab));
}
Profile* BrowserTabStripController::GetProfile() const {
return model_->profile();
}
////////////////////////////////////////////////////////////////////////////////
// BrowserTabStripController, TabStripModelObserver implementation:
......
......@@ -78,6 +78,7 @@ class BrowserTabStripController : public TabStripController,
void CheckFileSupported(const GURL& url) override;
SkColor GetToolbarTopSeparatorColor() const override;
base::string16 GetAccessibleTabName(const Tab* tab) const override;
Profile* GetProfile() const override;
// TabStripModelObserver implementation:
void TabInsertedAt(TabStripModel* tab_strip_model,
......@@ -119,8 +120,6 @@ class BrowserTabStripController : public TabStripController,
TabRendererData* data,
TabStatus tab_status);
Profile* profile() const { return model_->profile(); }
const TabStrip* tabstrip() const { return tabstrip_; }
private:
......
......@@ -153,3 +153,7 @@ base::string16 FakeBaseTabStripController::GetAccessibleTabName(
const Tab* tab) const {
return base::string16();
}
Profile* FakeBaseTabStripController::GetProfile() const {
return nullptr;
}
......@@ -56,6 +56,7 @@ class FakeBaseTabStripController : public TabStripController {
void CheckFileSupported(const GURL& url) override;
SkColor GetToolbarTopSeparatorColor() const override;
base::string16 GetAccessibleTabName(const Tab* tab) const override;
Profile* GetProfile() const override;
private:
TabStrip* tab_strip_;
......
......@@ -4,8 +4,10 @@
#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/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 "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/effects/SkBlurMaskFilter.h"
......@@ -22,6 +24,11 @@
#include "ui/views/win/hwnd_util.h"
#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 {
sk_sp<SkDrawLooper> CreateShadowDrawLooper(SkColor color) {
......@@ -177,6 +184,11 @@ bool NewTabButton::GetHitTestMask(gfx::Path* mask) const {
}
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);
// When the promo widget is destroyed, the NewTabButton needs to be
// recolored.
......
......@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_CONTROLLER_H_
#include "base/strings/string16.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/views/tabs/tab_strip_types.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/ui_base_types.h"
......@@ -126,6 +127,9 @@ class TabStripController {
// Returns the accessible tab name.
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_
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