Commit 3be29607 authored by Philip Hanson's avatar Philip Hanson Committed by Commit Bot

Make secondary app shelf icon tooltips match document.title.

Exclusively for extension app windows spawned using showInShelf = true,
make the tooltip text for the shelf item (icon) match the current value
of document.title from the corresponding window.

BUG=chromium:687359
TEST=Verify that the shelf item tooltip for extension app windows
     matches the document.title once the content is loaded.
TEST=From an extension app window with showInShelf=true, change the
     document.title dynamically and confirm that the shelf item tooltip
     changes to match.

Change-Id: I4620052821c19d91ea803151dc2cd4e538be121d
Reviewed-on: https://chromium-review.googlesource.com/526276
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#478681}
parent 8fc1bb61
......@@ -573,6 +573,7 @@ Peter Brophy <pbrophy@adobe.com>
Peter Collingbourne <peter@pcc.me.uk>
Peter Gal <pgal.u-szeged@partner.samsung.com>
Peter Molnar <pmolnar.u-szeged@partner.samsung.com>
Philip Hanson <philip.hanson@intel.com>
Philipp Hancke <fippo@andyet.net>
Philipp Hancke <philipp.hancke@googlemail.com>
Philippe Beauchamp <philippe.beauchamp@gmail.com>
......
......@@ -331,6 +331,16 @@ void ChromeLauncherController::SetItemStatus(const ash::ShelfID& id,
}
}
void ChromeLauncherController::SetItemTitle(const ash::ShelfID& id,
const base::string16& title) {
const ash::ShelfItem* item = GetItem(id);
if (item && item->title != title) {
ash::ShelfItem new_item = *item;
new_item.title = title;
model_->Set(model_->ItemIndexByID(id), new_item);
}
}
void ChromeLauncherController::CloseLauncherItem(const ash::ShelfID& id) {
CHECK(!id.IsNull());
if (IsPinned(id)) {
......
......@@ -111,6 +111,9 @@ class ChromeLauncherController
// browsers shelf item if needed.
void SetItemStatus(const ash::ShelfID& id, ash::ShelfItemStatus status);
// Updates the shelf item title (displayed in the tooltip).
void SetItemTitle(const ash::ShelfID& id, const base::string16& title);
// Closes or unpins the shelf item.
void CloseLauncherItem(const ash::ShelfID& id);
......
......@@ -80,3 +80,22 @@ void ExtensionAppWindowLauncherItemController::ExecuteCommand(
int32_t event_flags) {
ChromeLauncherController::instance()->ActivateShellApp(app_id(), command_id);
}
void ExtensionAppWindowLauncherItemController::OnWindowTitleChanged(
aura::Window* window) {
ui::BaseWindow* base_window = GetAppWindow(window);
extensions::AppWindowRegistry* app_window_registry =
extensions::AppWindowRegistry::Get(
ChromeLauncherController::instance()->profile());
extensions::AppWindow* app_window =
app_window_registry->GetAppWindowForNativeWindow(
base_window->GetNativeWindow());
// Use the window title (if set) to differentiate show_in_shelf window shelf
// items instead of the default behavior of using the app name.
if (app_window->show_in_shelf()) {
base::string16 title = window->GetTitle();
if (!title.empty())
ChromeLauncherController::instance()->SetItemTitle(shelf_id(), title);
}
}
......@@ -25,6 +25,9 @@ class ExtensionAppWindowLauncherItemController
void AddAppWindow(extensions::AppWindow* app_window);
// aura::WindowObserver overrides:
void OnWindowTitleChanged(aura::Window* window) override;
// AppWindowLauncherItemController:
ash::MenuItemList GetAppMenuItems(int event_flags) override;
void ExecuteCommand(uint32_t command_id, int32_t event_flags) 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