summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-08 04:27:22 +0000
committerdbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-08 04:27:22 +0000
commit4a5ab9e0cbc192a7133e6967fed3149ba95ec74e (patch)
tree45f307ef30c592600400cf98e4e18761e96cba40
parent0e9ceb7af1a1abead376c821936ab62e4894e51c (diff)
downloadchromium_src-4a5ab9e0cbc192a7133e6967fed3149ba95ec74e.zip
chromium_src-4a5ab9e0cbc192a7133e6967fed3149ba95ec74e.tar.gz
chromium_src-4a5ab9e0cbc192a7133e6967fed3149ba95ec74e.tar.bz2
Revert 249921 "Adding application name message in kiosk mode aft..."
Leaking memory on Linux Chromium OS ASAN Tests (3) bot, ex.: https://gist.github.com/anonymous/4e2f8f182a41a09641c4/raw/63429ed5ac896ba13174286e5d553346494bce55/gistfile1.txt > Adding application name message in kiosk mode after user timeout > > This is a security feature for a user who interacts with a kiosk device - making sure that he/she knows which application is running. > > When a user interacts with the device after 2 minutes of inactivity, a message shows which application is running and who was the author. > > When spoken feedback is turned on, the device will also narrowate the content of the message. > > The message itself will slide in from the top and - after a short timeout - will automatically slide out again. > > BUG=268453 > TEST=unit test & visual test > > Review URL: https://codereview.chromium.org/131353007 TBR=skuhne@chromium.org Review URL: https://codereview.chromium.org/158263002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249931 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/chromeos_strings.grdp14
-rw-r--r--chrome/browser/chromeos/app_mode/app_session_lifetime.cc6
-rw-r--r--chrome/browser/chromeos/app_mode/kiosk_mode_idle_app_name_notification.cc127
-rw-r--r--chrome/browser/chromeos/app_mode/kiosk_mode_idle_app_name_notification.h60
-rw-r--r--chrome/browser/chromeos/chrome_browser_main_chromeos.cc4
-rw-r--r--chrome/browser/chromeos/ui/idle_app_name_notification_view.cc310
-rw-r--r--chrome/browser/chromeos/ui/idle_app_name_notification_view.h58
-rw-r--r--chrome/browser/chromeos/ui/idle_app_name_notification_view_unittest.cc142
-rw-r--r--chrome/chrome_browser_chromeos.gypi4
-rw-r--r--chrome/chrome_tests_unit.gypi1
10 files changed, 1 insertions, 725 deletions
diff --git a/chrome/app/chromeos_strings.grdp b/chrome/app/chromeos_strings.grdp
index 35a64fd..9438cd1 100644
--- a/chrome/app/chromeos_strings.grdp
+++ b/chrome/app/chromeos_strings.grdp
@@ -20,20 +20,6 @@ Press any key to continue exploring.
Going.. Going... Gone.
</message>
- <!-- Application name notification upon idle -->
- <message name="IDS_IDLE_APP_NAME_NOTIFICATION" desc="A kiosk mode notification which shows the author of the running application (and in front the application name itself in a different font) after some idle timeout.">
- App by: <ph name="COMPANY_NAME">$1<ex>Example company</ex></ph>
- </message>
- <message name="IDS_IDLE_APP_NAME_INVALID_AUTHOR_NOTIFICATION" desc="A notification which shows that the author of the running kiosk application is unknown or invalid.">
- The author cannot be determined.
- </message>
- <message name="IDS_IDLE_APP_NAME_UNKNOWN_APPLICATION_NOTIFICATION" desc="A notification which shows that the name of the running Kiosk application cannot be determined and is probably invalid.">
- The application appears to be invalid.
- </message>
- <message name="IDS_IDLE_APP_NAME_SPOKEN_NOTIFICATION" desc="The accessibility spoken string for the message which tells the user about the application and the author in Kisok mode.">
- <ph name="APPLICATION_NAME">$1<ex>My application</ex></ph> <ph name="COMPANY_NAME">$2<ex>Example company</ex></ph>
- </message>
-
<!-- User Image default image accessible descriptions -->
<message name="IDS_LOGIN_DEFAULT_USER_DESC_19" desc="Description of the default user icon with a picture of a bicycle">
Bicycle
diff --git a/chrome/browser/chromeos/app_mode/app_session_lifetime.cc b/chrome/browser/chromeos/app_mode/app_session_lifetime.cc
index d3c1cb25..45f1023 100644
--- a/chrome/browser/chromeos/app_mode/app_session_lifetime.cc
+++ b/chrome/browser/chromeos/app_mode/app_session_lifetime.cc
@@ -14,7 +14,6 @@
#include "base/prefs/pref_service.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_update_service.h"
-#include "chrome/browser/chromeos/app_mode/kiosk_mode_idle_app_name_notification.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
@@ -130,15 +129,12 @@ void InitAppSession(Profile* profile, const std::string& app_id) {
if (update_service)
update_service->set_app_id(app_id);
- // If the device is not enterprise managed, set prefs to reboot after update
- // and create a user security message which shows the user the application
- // name and author after some idle timeout.
+ // If the device is not enterprise managed, set prefs to reboot after update.
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
if (!connector->IsEnterpriseManaged()) {
PrefService* local_state = g_browser_process->local_state();
local_state->SetBoolean(prefs::kRebootAfterUpdate, true);
- KioskModeIdleAppNameNotification::Initialize();
}
}
diff --git a/chrome/browser/chromeos/app_mode/kiosk_mode_idle_app_name_notification.cc b/chrome/browser/chromeos/app_mode/kiosk_mode_idle_app_name_notification.cc
deleted file mode 100644
index 6fe3554..0000000
--- a/chrome/browser/chromeos/app_mode/kiosk_mode_idle_app_name_notification.cc
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright 2014 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 "chrome/browser/chromeos/app_mode/kiosk_mode_idle_app_name_notification.h"
-
-#include "ash/shell.h"
-#include "ash/wm/user_activity_detector.h"
-#include "base/bind.h"
-#include "base/command_line.h"
-#include "base/logging.h"
-#include "chrome/browser/chromeos/login/user_manager.h"
-#include "chrome/browser/chromeos/ui/idle_app_name_notification_view.h"
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/common/chrome_switches.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "extensions/browser/extension_system.h"
-
-namespace chromeos {
-
-namespace {
-
-// The timeout in ms before the message shows up.
-const int kIdleAppNameNotificationTimeoutMs = 2 * 60 * 1000;
-
-// The duration of visibility for the message.
-const int kMessageVisibilityTimeMs = 3000;
-
-// The anomation time to show / hide the message.
-const int kMessageAnimationTimeMs = 200;
-
-// Our global instance of the Kiosk mode message.
-KioskModeIdleAppNameNotification* g_kiosk_mode_idle_app_message = NULL;
-
-} // namespace
-
-// static
-void KioskModeIdleAppNameNotification::Initialize() {
- DCHECK(!g_kiosk_mode_idle_app_message);
- g_kiosk_mode_idle_app_message = new KioskModeIdleAppNameNotification();
-}
-
-// static
-void KioskModeIdleAppNameNotification::Shutdown() {
- if (g_kiosk_mode_idle_app_message) {
- delete g_kiosk_mode_idle_app_message;
- g_kiosk_mode_idle_app_message = NULL;
- }
-}
-
-KioskModeIdleAppNameNotification::KioskModeIdleAppNameNotification()
- : show_notification_upon_next_user_activity_(false) {
- // Note: The timeout is currently fixed. If that changes we need to check if
- // the KioskModeSettings were already initialized.
- Setup();
-}
-
-KioskModeIdleAppNameNotification::~KioskModeIdleAppNameNotification() {
- if (ash::Shell::HasInstance() &&
- ash::Shell::GetInstance()->user_activity_detector()->HasObserver(this)) {
- ash::Shell::GetInstance()->user_activity_detector()->RemoveObserver(this);
- // At this time the DBusThreadManager might already be gone.
- if (chromeos::DBusThreadManager::IsInitialized())
- chromeos::DBusThreadManager::Get()->GetPowerManagerClient(
- )->RemoveObserver(this);
- }
-}
-
-void KioskModeIdleAppNameNotification::Setup() {
- DCHECK(UserManager::Get()->IsUserLoggedIn());
- Start();
-}
-
-void KioskModeIdleAppNameNotification::OnUserActivity(const ui::Event* event) {
- if (show_notification_upon_next_user_activity_) {
- CommandLine* command_line = CommandLine::ForCurrentProcess();
- const std::string app_id =
- command_line->GetSwitchValueASCII(::switches::kAppId);
- Profile* profile = ProfileManager::GetActiveUserProfile();
- notification_.reset(
- new IdleAppNameNotificationView(
- kMessageVisibilityTimeMs,
- kMessageAnimationTimeMs,
- extensions::ExtensionSystem::Get(profile
- )->extension_service()->GetInstalledExtension(app_id)));
- show_notification_upon_next_user_activity_ = false;
- }
- ResetTimer();
-}
-
-void KioskModeIdleAppNameNotification::SystemResumed(
- const base::TimeDelta& sleep_duration) {
- // When we come back from a system resume we stop the timer and show the
- // message.
- timer_.Stop();
- OnTimeout();
-}
-
-void KioskModeIdleAppNameNotification::Start() {
- if (!ash::Shell::GetInstance()->user_activity_detector()->HasObserver(this)) {
- ash::Shell::GetInstance()->user_activity_detector()->AddObserver(this);
- chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(
- this);
- }
- ResetTimer();
-}
-
-void KioskModeIdleAppNameNotification::ResetTimer() {
- if (timer_.IsRunning()) {
- timer_.Reset();
- } else {
- // OneShotTimer destroys the posted task after running it, so Reset()
- // isn't safe to call on a timer that's already fired.
- timer_.Start(
- FROM_HERE,
- base::TimeDelta::FromMilliseconds(kIdleAppNameNotificationTimeoutMs),
- base::Bind(&KioskModeIdleAppNameNotification::OnTimeout,
- base::Unretained(this)));
- }
-}
-
-void KioskModeIdleAppNameNotification::OnTimeout() {
- show_notification_upon_next_user_activity_ = true;
-}
-
-} // namespace chromeos
diff --git a/chrome/browser/chromeos/app_mode/kiosk_mode_idle_app_name_notification.h b/chrome/browser/chromeos/app_mode/kiosk_mode_idle_app_name_notification.h
deleted file mode 100644
index 6a2b2f1..0000000
--- a/chrome/browser/chromeos/app_mode/kiosk_mode_idle_app_name_notification.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright 2014 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_CHROMEOS_APP_MODE_KIOSK_MODE_IDLE_APP_NAME_NOTIFICATION_H_
-#define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_MODE_IDLE_APP_NAME_NOTIFICATION_H_
-
-#include "ash/wm/user_activity_observer.h"
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/timer/timer.h"
-#include "chromeos/dbus/power_manager_client.h"
-
-namespace chromeos {
-class IdleAppNameNotificationView;
-
-class KioskModeIdleAppNameNotification : public ash::UserActivityObserver,
- public PowerManagerClient::Observer {
- public:
- static void Initialize();
-
- static void Shutdown();
-
- KioskModeIdleAppNameNotification();
- virtual ~KioskModeIdleAppNameNotification();
-
- private:
- // Initialize idle app message when KioskModeHelper is initialized.
- void Setup();
-
- // UserActivityObserver overrides:
- virtual void OnUserActivity(const ui::Event* event) OVERRIDE;
-
- // PowerManagerClient::Observer overrides:
- virtual void SystemResumed(const base::TimeDelta& sleep_duration) OVERRIDE;
-
- // Begins listening for user activity and calls ResetTimer().
- void Start();
-
- // Resets |timer_| to fire when the application idle message should be shown.
- void ResetTimer();
-
- // Invoked by |timer_| to display the application idle message.
- void OnTimeout();
-
- base::OneShotTimer<KioskModeIdleAppNameNotification> timer_;
-
- // If set the notification should get shown upon next user activity.
- bool show_notification_upon_next_user_activity_;
-
- // The notification object which owns and shows the notification.
- scoped_ptr<IdleAppNameNotificationView> notification_;
-
- DISALLOW_COPY_AND_ASSIGN(KioskModeIdleAppNameNotification);
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_MODE_IDLE_APP_NAME_NOTIFICATION_H_
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
index d1f76ce..2e11fd5 100644
--- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
+++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
@@ -28,7 +28,6 @@
#include "chrome/browser/chromeos/accessibility/magnification_manager.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
-#include "chrome/browser/chromeos/app_mode/kiosk_mode_idle_app_name_notification.h"
#include "chrome/browser/chromeos/boot_times_loader.h"
#include "chrome/browser/chromeos/contacts/contact_manager.h"
#include "chrome/browser/chromeos/dbus/cros_dbus_service.h"
@@ -734,9 +733,6 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() {
g_browser_process->platform_part()->oom_priority_manager()->Stop();
- // Destroy the application name notifier for Kiosk mode.
- KioskModeIdleAppNameNotification::Shutdown();
-
// Stops all in-flight OAuth2 token fetchers before the IO thread stops.
DeviceOAuth2TokenServiceFactory::Shutdown();
diff --git a/chrome/browser/chromeos/ui/idle_app_name_notification_view.cc b/chrome/browser/chromeos/ui/idle_app_name_notification_view.cc
deleted file mode 100644
index ae4795f..0000000
--- a/chrome/browser/chromeos/ui/idle_app_name_notification_view.cc
+++ /dev/null
@@ -1,310 +0,0 @@
-// Copyright 2014 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 "chrome/browser/chromeos/ui/idle_app_name_notification_view.h"
-
-#include <string>
-
-#include "ash/shell.h"
-#include "ash/shell_delegate.h"
-#include "ash/shell_window_ids.h"
-#include "ash/wm/window_animations.h"
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/time/time.h"
-#include "base/timer/timer.h"
-#include "extensions/common/extension.h"
-#include "grit/generated_resources.h"
-#include "ui/aura/window.h"
-#include "ui/base/accessibility/accessible_view_state.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/compositor/layer_animation_observer.h"
-#include "ui/compositor/scoped_layer_animation_settings.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/font_list.h"
-#include "ui/gfx/text_utils.h"
-#include "ui/views/controls/label.h"
-#include "ui/views/layout/box_layout.h"
-#include "ui/views/layout/fill_layout.h"
-#include "ui/views/view.h"
-#include "ui/views/widget/widget.h"
-#include "ui/views/widget/widget_delegate.h"
-
-namespace ui {
-class LayerAnimationSequence;
-}
-
-namespace chromeos {
-namespace {
-
-// Color of the text of the warning message.
-const SkColor kTextColor = SK_ColorBLACK;
-
-// Color of the text of the warning message.
-const SkColor kErrorTextColor = SK_ColorRED;
-
-// Color of the window background.
-const SkColor kWindowBackgroundColor = SK_ColorWHITE;
-
-// Radius of the rounded corners of the window.
-const int kWindowCornerRadius = 4;
-
-// Spacing around the text.
-const int kHorizontalMarginAroundText = 50;
-const int kVerticalMarginAroundText = 25;
-const int kVerticalSpacingBetweenText = 10;
-
-// Creates and shows the message widget for |view| with |animation_time_ms|.
-void CreateAndShowWidgetWithContent(views::WidgetDelegate* delegate,
- views::View* view,
- int animation_time_ms) {
- aura::Window* root_window = ash::Shell::GetTargetRootWindow();
- gfx::Size rs = root_window->bounds().size();
- gfx::Size ps = view->GetPreferredSize();
- gfx::Rect bounds((rs.width() - ps.width()) / 2,
- -ps.height(),
- ps.width(),
- ps.height());
- views::Widget::InitParams params;
- params.type = views::Widget::InitParams::TYPE_POPUP;
- params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
- params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- params.accept_events = false;
- params.can_activate = false;
- params.keep_on_top = true;
- params.remove_standard_frame = true;
- params.delegate = delegate;
- params.bounds = bounds;
- params.parent = ash::Shell::GetContainer(
- root_window,
- ash::internal::kShellWindowId_SettingBubbleContainer);
- views::Widget* widget = new views::Widget;
- widget->Init(params);
- widget->SetContentsView(view);
- gfx::NativeView native_view = widget->GetNativeView();
- native_view->SetName("KioskIdleAppNameNotification");
-
- // Note: We cannot use the Window show/hide animations since they are disabled
- // for kiosk by command line.
- ui::LayerAnimator* animator = new ui::LayerAnimator(
- base::TimeDelta::FromMilliseconds(animation_time_ms));
- native_view->layer()->SetAnimator(animator);
- widget->Show();
-
- // We don't care about the show animation since it is off screen, so stop the
- // started animation and move the message into view.
- animator->StopAnimating();
- bounds.set_y((rs.height() - ps.height()) / 20);
- widget->SetBounds(bounds);
-
- // Allow to use the message for spoken feedback.
- view->NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_ALERT, true);
-}
-
-} // namespace
-
-// The class which implements the content view for the message.
-class IdleAppNameNotificationDelegateView
- : public views::WidgetDelegateView,
- public ui::ImplicitAnimationObserver {
- public:
- // An idle message which will get shown from the caller and hides itself after
- // a time, calling |owner->CloseMessage| to inform the owner that it got
- // destroyed. The |app_name| and the |app_author| are strings which get
- // used as message and |error| is true if something is not correct.
- // |message_visibility_time_in_ms| ms's after creation the message will start
- // to remove itself from the screen.
- IdleAppNameNotificationDelegateView(IdleAppNameNotificationView *owner,
- const base::string16& app_name,
- const base::string16& app_author,
- bool error,
- int message_visibility_time_in_ms)
- : owner_(owner),
- widget_closed_(false) {
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- // Add the application name label to the message.
- AddLabel(app_name,
- rb.GetFontList(ui::ResourceBundle::BoldFont),
- error && app_author.empty() ? kErrorTextColor : kTextColor);
- if (!app_author.empty()) {
- // Add the author label to the message.
- base::string16 app_by_author =
- l10n_util::GetStringFUTF16(IDS_IDLE_APP_NAME_NOTIFICATION,
- app_author);
- AddLabel(app_by_author,
- rb.GetFontList(ui::ResourceBundle::BaseFont),
- error ? kErrorTextColor : kTextColor);
- spoken_text_ =
- l10n_util::GetStringFUTF16(IDS_IDLE_APP_NAME_SPOKEN_NOTIFICATION,
- app_name,
- app_by_author);
- SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
- kHorizontalMarginAroundText,
- kVerticalMarginAroundText,
- kVerticalSpacingBetweenText));
- } else {
- spoken_text_ = app_name;
- SetLayoutManager(new views::FillLayout);
- }
-
- // Set a timer which will trigger to remove the message after the given
- // time.
- hide_timer_.Start(
- FROM_HERE,
- base::TimeDelta::FromMilliseconds(message_visibility_time_in_ms),
- this,
- &IdleAppNameNotificationDelegateView::RemoveMessage);
- }
-
- virtual ~IdleAppNameNotificationDelegateView() {
- // The widget is already closing, but the other cleanup items need to be
- // performed.
- widget_closed_ = true;
- Close();
- }
-
- // Close the widget immediately. This can be called from the owner or from
- // this class.
- void Close() {
- // Stop the timer (if it was running).
- hide_timer_.Stop();
- // Inform our owner that we are going away.
- if (owner_) {
- IdleAppNameNotificationView* owner = owner_;
- owner_ = NULL;
- owner->CloseMessage();
- }
- // Close the owning widget - if required.
- if (!widget_closed_) {
- widget_closed_ = true;
- GetWidget()->Close();
- }
- }
-
- // Animate the window away (and close once done).
- void RemoveMessage() {
- aura::Window* widget_view = GetWidget()->GetNativeView();
- ui::Layer* layer = widget_view->layer();
- ui::ScopedLayerAnimationSettings settings(layer->GetAnimator());
- settings.AddObserver(this);
- gfx::Rect rect = widget_view->bounds();
- rect.set_y(-GetPreferredSize().height());
- layer->SetBounds(rect);
- }
-
- virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
- SkPaint paint;
- paint.setStyle(SkPaint::kFill_Style);
- paint.setColor(kWindowBackgroundColor);
- canvas->DrawRoundRect(GetLocalBounds(), kWindowCornerRadius, paint);
- views::WidgetDelegateView::OnPaint(canvas);
- }
-
- virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE {
- state->name = spoken_text_;
- state->role = ui::AccessibilityTypes::ROLE_ALERT;
- }
-
- // ImplicitAnimationObserver overrides
- virtual void OnImplicitAnimationsCompleted() OVERRIDE {
- Close();
- }
-
- private:
- // Adds the label to the view, using |text| with a |font| and a |text_color|.
- void AddLabel(const base::string16& text,
- const gfx::FontList& font,
- SkColor text_color) {
- views::Label* label = new views::Label;
- label->SetText(text);
- label->SetHorizontalAlignment(gfx::ALIGN_CENTER);
- label->SetFontList(font);
- label->SetEnabledColor(text_color);
- label->SetDisabledColor(text_color);
- label->SetAutoColorReadabilityEnabled(false);
- AddChildView(label);
- }
-
- // A timer which calls us to remove the message from the screen.
- base::OneShotTimer<IdleAppNameNotificationDelegateView> hide_timer_;
-
- // The owner of this message which needs to get notified when the message
- // closes.
- IdleAppNameNotificationView* owner_;
-
- // The spoken text.
- base::string16 spoken_text_;
-
- // True if the widget got already closed.
- bool widget_closed_;
-
- DISALLOW_COPY_AND_ASSIGN(IdleAppNameNotificationDelegateView);
-};
-
-IdleAppNameNotificationView::IdleAppNameNotificationView(
- int message_visibility_time_in_ms,
- int animation_time_ms,
- const extensions::Extension* extension)
- : view_(NULL) {
- ShowMessage(message_visibility_time_in_ms, animation_time_ms, extension);
-}
-
-IdleAppNameNotificationView::~IdleAppNameNotificationView() {
- CloseMessage();
-}
-
-void IdleAppNameNotificationView::CloseMessage() {
- if (view_) {
- view_->Close();
- view_ = NULL;
- }
-}
-
-bool IdleAppNameNotificationView::IsVisible() {
- return view_ != NULL;
-}
-
-base::string16 IdleAppNameNotificationView::GetShownTextForTest() {
- ui::AccessibleViewState state;
- DCHECK(view_);
- view_->GetAccessibleState(&state);
- return state.name;
-}
-
-void IdleAppNameNotificationView::ShowMessage(
- int message_visibility_time_in_ms,
- int animation_time_ms,
- const extensions::Extension* extension) {
- DCHECK(!view_);
-
- base::string16 author;
- base::string16 app_name;
- bool error = false;
- if (extension && !ContainsOnlyWhitespaceASCII(extension->name())) {
- app_name = base::ASCIIToUTF16(extension->name());
- // TODO(skuhne): This might not be enough since the author flag is not
- // explicitly enforced by us, but for Kiosk mode we could maybe require it.
- extension->manifest()->GetString("author", &author);
- if (ContainsOnlyWhitespace(author)) {
- error = true;
- author = l10n_util::GetStringUTF16(
- IDS_IDLE_APP_NAME_INVALID_AUTHOR_NOTIFICATION);
- }
- } else {
- error = true;
- app_name = l10n_util::GetStringUTF16(
- IDS_IDLE_APP_NAME_UNKNOWN_APPLICATION_NOTIFICATION);
- }
-
- view_ = new IdleAppNameNotificationDelegateView(
- this,
- app_name,
- author,
- error,
- message_visibility_time_in_ms + animation_time_ms);
- CreateAndShowWidgetWithContent(view_, view_, animation_time_ms);
-}
-
-} // namespace chromeos
diff --git a/chrome/browser/chromeos/ui/idle_app_name_notification_view.h b/chrome/browser/chromeos/ui/idle_app_name_notification_view.h
deleted file mode 100644
index 7fd0cc9..0000000
--- a/chrome/browser/chromeos/ui/idle_app_name_notification_view.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2014 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_CHROMEOS_UI_IDLE_APP_NAME_NOTIFICATION_VIEW_H_
-#define CHROME_BROWSER_CHROMEOS_UI_IDLE_APP_NAME_NOTIFICATION_VIEW_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "base/strings/string16.h"
-
-namespace extensions {
-class Extension;
-} // namespace extensions
-
-namespace views {
-class Widget;
-} // namespace views
-
-namespace chromeos {
-
-class IdleAppNameNotificationDelegateView;
-
-// A class which creates a message which shows the currently running applicaion
-// name and its creator.
-class IdleAppNameNotificationView {
- public:
- // |message_visibility_time_in_ms| is the time the message is fully visible.
- // |animation_time_ms| is the transition time for the message to show or hide.
- // |extension| is the application which is started.
- IdleAppNameNotificationView(int message_visibility_time_in_ms,
- int animation_time_ms,
- const extensions::Extension* extension);
- virtual ~IdleAppNameNotificationView();
-
- // Close and destroy the message instantly.
- void CloseMessage();
-
- // Returns true when message is shown.
- bool IsVisible();
-
- // Returns the shown text for testing.
- base::string16 GetShownTextForTest();
-
- private:
- // Show the message. This will make the message visible.
- void ShowMessage(int message_visibility_time_in_ms,
- int animation_time_ms,
- const extensions::Extension* extension);
-
- // A reference to an existing message.
- IdleAppNameNotificationDelegateView* view_;
-
- DISALLOW_COPY_AND_ASSIGN(IdleAppNameNotificationView);
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_CHROMEOS_UI_IDLE_APP_NAME_NOTIFICATION_VIEW_H_
diff --git a/chrome/browser/chromeos/ui/idle_app_name_notification_view_unittest.cc b/chrome/browser/chromeos/ui/idle_app_name_notification_view_unittest.cc
deleted file mode 100644
index b2cb847..0000000
--- a/chrome/browser/chromeos/ui/idle_app_name_notification_view_unittest.cc
+++ /dev/null
@@ -1,142 +0,0 @@
-// Copyright 2014 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 "chrome/browser/chromeos/ui/idle_app_name_notification_view.h"
-
-#include "base/command_line.h"
-#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/test_extension_system.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/test/base/browser_with_test_window_test.h"
-#include "extensions/common/manifest_constants.h"
-#include "grit/generated_resources.h"
-#include "ui/base/l10n/l10n_util.h"
-
-namespace {
-const char kTestAppName[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
-} // namespace
-
-class IdleAppNameNotificationViewTest : public BrowserWithTestWindowTest {
- public:
- IdleAppNameNotificationViewTest()
- : BrowserWithTestWindowTest(
- Browser::TYPE_TABBED,
- chrome::HOST_DESKTOP_TYPE_ASH,
- false) {
- }
-
- virtual ~IdleAppNameNotificationViewTest() {
- }
-
- virtual void SetUp() OVERRIDE {
- // Add the application switch.
- CommandLine::ForCurrentProcess()->AppendSwitchASCII(::switches::kAppId,
- kTestAppName);
-
- BrowserWithTestWindowTest::SetUp();
-
- base::DictionaryValue manifest;
- manifest.SetString(extensions::manifest_keys::kName, "Test");
- manifest.SetString(extensions::manifest_keys::kVersion, "1");
- manifest.SetString(extensions::manifest_keys::kDescription, "Test app");
- manifest.SetString("author", "Someone");
-
- std::string error;
- correct_extension_ =
- extensions::Extension::Create(base::FilePath(),
- extensions::Manifest::UNPACKED,
- manifest,
- extensions::Extension::NO_FLAGS,
- kTestAppName,
- &error);
- base::DictionaryValue manifest2;
- manifest2.SetString(extensions::manifest_keys::kName, "Test");
- manifest2.SetString(extensions::manifest_keys::kVersion, "1");
- manifest2.SetString(extensions::manifest_keys::kDescription, "Test app");
-
- incorrect_extension_ =
- extensions::Extension::Create(base::FilePath(),
- extensions::Manifest::UNPACKED,
- manifest2,
- extensions::Extension::NO_FLAGS,
- kTestAppName,
- &error);
- }
-
- extensions::Extension* correct_extension() { return correct_extension_; }
- extensions::Extension* incorrect_extension() { return incorrect_extension_; }
-
- private:
- // Extensions to test with.
- scoped_refptr<extensions::Extension> correct_extension_;
- scoped_refptr<extensions::Extension> incorrect_extension_;
-
- DISALLOW_COPY_AND_ASSIGN(IdleAppNameNotificationViewTest);
-};
-
-// Check that creating and immediate destroying does not crash (and closes the
-// message).
-TEST_F(IdleAppNameNotificationViewTest, CheckTooEarlyDestruction) {
- // Create a message which is visible for 10ms and fades in/out for 5ms.
- scoped_ptr<chromeos::IdleAppNameNotificationView> message(
- new chromeos::IdleAppNameNotificationView(10, 5, correct_extension()));
-}
-
-// Check that the message gets created and it destroys itself after time.
-TEST_F(IdleAppNameNotificationViewTest, CheckSelfDestruction) {
- // Create a message which is visible for 10ms and fades in/out for 5ms.
- scoped_ptr<chromeos::IdleAppNameNotificationView> message(
- new chromeos::IdleAppNameNotificationView(10, 5, correct_extension()));
- EXPECT_TRUE(message->IsVisible());
-
- // Wait now for some time and see that it closes itself again.
- for (int i = 0; i < 50 && message->IsVisible(); i++) {
- sleep(1);
- base::MessageLoop::current()->RunUntilIdle();
- }
- EXPECT_FALSE(message->IsVisible());
-}
-
-// Check that the shown text for a correct application is correct.
-TEST_F(IdleAppNameNotificationViewTest, CheckCorrectApp) {
- // Create a message which is visible for 10ms and fades in/out for 5ms.
- scoped_ptr<chromeos::IdleAppNameNotificationView> message(
- new chromeos::IdleAppNameNotificationView(10, 5, correct_extension()));
- base::string16 text = message->GetShownTextForTest();
- // Check that the string starts with the application name followed by a space.
- base::string16 name = base::ASCIIToUTF16("Test ");
- EXPECT_EQ(name, text.substr(0, name.length()));
- // Check that the string ends with a space + author's name.
- base::string16 author = base::ASCIIToUTF16(" Someone");
- EXPECT_EQ(author,
- text.substr(text.length() - author.length(), author.length()));
-}
-
-// Check that an invalid author gets shown accordingly.
-TEST_F(IdleAppNameNotificationViewTest, CheckInvalidAuthor) {
- // Create a message which is visible for 10ms and fades in/out for 5ms.
- scoped_ptr<chromeos::IdleAppNameNotificationView> message(
- new chromeos::IdleAppNameNotificationView(10, 5, incorrect_extension()));
- base::string16 text = message->GetShownTextForTest();
- // Check that the string starts with the application name followed by a space.
- base::string16 name = base::ASCIIToUTF16("Test ");
- EXPECT_EQ(name, text.substr(0, name.length()));
- // Check that it ends in an invalid author notification.
- base::string16 author = l10n_util::GetStringUTF16(
- IDS_IDLE_APP_NAME_INVALID_AUTHOR_NOTIFICATION);
- EXPECT_EQ(author,
- text.substr(text.length() - author.length(), author.length()));
-}
-
-// Check that an invalid app gets shown accordingly.
-TEST_F(IdleAppNameNotificationViewTest, CheckInvalidApp) {
- // Create a message which is visible for 10ms and fades in/out for 5ms.
- scoped_ptr<chromeos::IdleAppNameNotificationView> message(
- new chromeos::IdleAppNameNotificationView(10, 5, NULL));
- base::string16 text = message->GetShownTextForTest();
- base::string16 error = l10n_util::GetStringUTF16(
- IDS_IDLE_APP_NAME_UNKNOWN_APPLICATION_NOTIFICATION);
- EXPECT_EQ(error, text);
-}
diff --git a/chrome/chrome_browser_chromeos.gypi b/chrome/chrome_browser_chromeos.gypi
index 7e3d8c92..f6629bd 100644
--- a/chrome/chrome_browser_chromeos.gypi
+++ b/chrome/chrome_browser_chromeos.gypi
@@ -141,8 +141,6 @@
'browser/chromeos/app_mode/kiosk_app_update_service.h',
'browser/chromeos/app_mode/kiosk_diagnosis_runner.cc',
'browser/chromeos/app_mode/kiosk_diagnosis_runner.h',
- 'browser/chromeos/app_mode/kiosk_mode_idle_app_name_notification.cc',
- 'browser/chromeos/app_mode/kiosk_mode_idle_app_name_notification.h',
'browser/chromeos/app_mode/kiosk_profile_loader.cc',
'browser/chromeos/app_mode/kiosk_profile_loader.h',
'browser/chromeos/app_mode/startup_app_launcher.cc',
@@ -856,8 +854,6 @@
'browser/chromeos/ui/focus_ring_controller.h',
'browser/chromeos/ui/focus_ring_layer.cc',
'browser/chromeos/ui/focus_ring_layer.h',
- 'browser/chromeos/ui/idle_app_name_notification_view.cc',
- 'browser/chromeos/ui/idle_app_name_notification_view.h',
'browser/chromeos/ui/idle_logout_dialog_view.cc',
'browser/chromeos/ui/idle_logout_dialog_view.h',
'browser/chromeos/ui/screen_capture_notification_ui_chromeos.cc',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 24289f6..9f4a5a9 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -765,7 +765,6 @@
'browser/chromeos/settings/session_manager_operation_unittest.cc',
'browser/chromeos/settings/stub_cros_settings_provider_unittest.cc',
'browser/chromeos/system/automatic_reboot_manager_unittest.cc',
- 'browser/chromeos/ui/idle_app_name_notification_view_unittest.cc',
'browser/chromeos/version_loader_unittest.cc',
'browser/command_updater_unittest.cc',
'browser/component_updater/test/component_installers_unittest.cc',