Commit 6a5ed4d6 authored by Kristi Park's avatar Kristi Park Committed by Commit Bot

[SendTabToSelf] Limit initial "Send" animation to once per profile

Show the initial "Send" animation once per profile instead of once per
window.

Bug: 1013258
Change-Id: I2a041e597d51a1acdd3a0fdd156627c34935390f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2020535Reviewed-by: default avatarJeffrey Cohen <jeffreycohen@chromium.org>
Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Commit-Queue: Kristi Park <kristipark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735526}
parent c512b0b0
......@@ -75,6 +75,7 @@
#include "chrome/browser/ui/network_profile_bubble.h"
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
#include "chrome/browser/ui/search_engines/keyword_editor_controller.h"
#include "chrome/browser/ui/send_tab_to_self/send_tab_to_self_bubble_controller.h"
#include "chrome/browser/ui/tabs/pinned_tab_codec.h"
#include "chrome/browser/ui/webui/flags_ui.h"
#include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
......@@ -946,6 +947,8 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry,
PromoService::RegisterProfilePrefs(registry);
SearchSuggestService::RegisterProfilePrefs(registry);
settings::SettingsUI::RegisterProfilePrefs(registry);
send_tab_to_self::SendTabToSelfBubbleController::RegisterProfilePrefs(
registry);
signin::RegisterProfilePrefs(registry);
StartupBrowserCreator::RegisterProfilePrefs(registry);
UnifiedAutoplayConfig::RegisterProfilePrefs(registry);
......
......@@ -13,6 +13,8 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/send_tab_to_self/send_tab_to_self_bubble_view.h"
#include "chrome/grit/generated_resources.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/send_tab_to_self/pref_names.h"
#include "components/send_tab_to_self/send_tab_to_self_model.h"
#include "components/send_tab_to_self/send_tab_to_self_sync_service.h"
#include "components/send_tab_to_self/target_device_info.h"
......@@ -86,6 +88,22 @@ void SendTabToSelfBubbleController::OnBubbleClosed() {
send_tab_to_self_bubble_view_ = nullptr;
}
bool SendTabToSelfBubbleController::InitialSendAnimationShown() const {
return GetProfile()->GetPrefs()->GetBoolean(
prefs::kInitialSendAnimationShown);
}
void SendTabToSelfBubbleController::SetInitialSendAnimationShown(bool shown) {
GetProfile()->GetPrefs()->SetBoolean(prefs::kInitialSendAnimationShown,
shown);
}
// Static:
void SendTabToSelfBubbleController::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* user_prefs) {
user_prefs->RegisterBooleanPref(prefs::kInitialSendAnimationShown, false);
}
SendTabToSelfBubbleController::SendTabToSelfBubbleController() = default;
SendTabToSelfBubbleController::SendTabToSelfBubbleController(
......
......@@ -16,7 +16,11 @@ class Profile;
namespace content {
class WebContents;
}
} // namespace content
namespace user_prefs {
class PrefRegistrySyncable;
} // namespace user_prefs
namespace send_tab_to_self {
......@@ -51,9 +55,18 @@ class SendTabToSelfBubbleController
// Close the bubble when the user click on the close button.
void OnBubbleClosed();
// Returns true if the initial "Send" animation that's displayed once per
// profile was shown.
bool InitialSendAnimationShown() const;
void SetInitialSendAnimationShown(bool shown);
bool show_message() const { return show_message_; }
void set_show_message(bool show_message) { show_message_ = show_message; }
// Register SendTabToSelfBubbleController related prefs in the Profile prefs.
static void RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* user_prefs);
protected:
SendTabToSelfBubbleController();
explicit SendTabToSelfBubbleController(content::WebContents* web_contents);
......
......@@ -69,10 +69,13 @@ void SendTabToSelfIconView::UpdateImpl() {
}
} else if (omnibox_view->model()->has_focus() &&
!omnibox_view->model()->user_input_in_progress()) {
// Shows the "Send" animation one time per window.
if (initial_animation_state_ == AnimationState::kNotShown) {
SendTabToSelfBubbleController* controller = GetController();
// Shows the "Send" animation once per profile.
if (controller && !controller->InitialSendAnimationShown() &&
initial_animation_state_ == AnimationState::kNotShown) {
AnimateIn(IDS_OMNIBOX_ICON_SEND_TAB_TO_SELF);
initial_animation_state_ = AnimationState::kShowing;
controller->SetInitialSendAnimationShown(true);
}
SetVisible(true);
}
......
......@@ -6,6 +6,8 @@ static_library("send_tab_to_self") {
sources = [
"features.cc",
"features.h",
"pref_names.cc",
"pref_names.h",
"send_tab_to_self_bridge.cc",
"send_tab_to_self_bridge.h",
"send_tab_to_self_entry.cc",
......
// Copyright 2020 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.
#include "components/send_tab_to_self/pref_names.h"
namespace send_tab_to_self {
namespace prefs {
const char kInitialSendAnimationShown[] =
"send_tab_to_self.initial_animation_shown";
} // namespace prefs
} // namespace send_tab_to_self
// Copyright 2020 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 COMPONENTS_SEND_TAB_TO_SELF_PREF_NAMES_H_
#define COMPONENTS_SEND_TAB_TO_SELF_PREF_NAMES_H_
namespace send_tab_to_self {
namespace prefs {
// Boolean indicating whether the initial omnibox "Send" animation was shown
// once for this profile.
extern const char kInitialSendAnimationShown[];
} // namespace prefs
} // namespace send_tab_to_self
#endif // COMPONENTS_SEND_TAB_TO_SELF_PREF_NAMES_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