Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2839)

Unified Diff: chrome/browser/ui/ash/launcher/browser_status_monitor.cc

Issue 2357143004: mash: Support ShelfWindowWatcher via ShelfItem properties. (Closed)
Patch Set: Set Settings WmWindow title with a WmWindowObserver. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/launcher/browser_status_monitor.cc
diff --git a/chrome/browser/ui/ash/launcher/browser_status_monitor.cc b/chrome/browser/ui/ash/launcher/browser_status_monitor.cc
index 119bad52220375722e530bc12056e194fb54cd93..8431602cd542bd0a0eb9e511dc88c653bbce89af 100644
--- a/chrome/browser/ui/ash/launcher/browser_status_monitor.cc
+++ b/chrome/browser/ui/ash/launcher/browser_status_monitor.cc
@@ -6,6 +6,7 @@
#include "ash/aura/wm_window_aura.h"
#include "ash/common/shelf/shelf_item_types.h"
+#include "ash/common/wm_window_observer.h"
#include "ash/common/wm_window_property.h"
#include "ash/resources/grit/ash_resources.h"
#include "ash/shell.h"
@@ -23,7 +24,6 @@
#include "chrome/browser/ui/settings_window_manager_observer.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/web_applications/web_app.h"
-#include "chrome/grit/generated_resources.h"
James Cook 2016/09/28 20:41:03 Nice catch.
msw 2016/09/28 23:27:46 Acknowledged.
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
@@ -85,19 +85,29 @@ class BrowserStatusMonitor::LocalWebContentsObserver
// Observes any new settings windows and sets their shelf icon (since they
// are excluded from BrowserShortcutLauncherItem).
class BrowserStatusMonitor::SettingsWindowObserver
- : public chrome::SettingsWindowManagerObserver {
+ : public chrome::SettingsWindowManagerObserver,
+ public ash::WmWindowObserver {
public:
SettingsWindowObserver() {}
~SettingsWindowObserver() override {}
- // SettingsWindowManagerObserver
+ // SettingsWindowManagerObserver:
void OnNewSettingsWindow(Browser* settings_browser) override {
- ash::ShelfItemDetails item_details;
- item_details.type = ash::TYPE_DIALOG;
- item_details.image_resource_id = IDR_ASH_SHELF_ICON_SETTINGS;
- item_details.title = l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE);
aura::Window* aura_window = settings_browser->window()->GetNativeWindow();
- ash::WmWindowAura::Get(aura_window)->SetShelfItemDetails(item_details);
+ ash::WmWindow* window = ash::WmWindowAura::Get(aura_window);
+ window->SetTitle(l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE));
+ window->SetIntProperty(ash::WmWindowProperty::SHELF_ITEM_TYPE,
+ ash::TYPE_DIALOG);
+ window->SetIntProperty(ash::WmWindowProperty::SHELF_ICON_ID,
+ IDR_ASH_SHELF_ICON_SETTINGS);
+ window->AddObserver(this);
James Cook 2016/09/28 20:41:03 Does this observer need to be cleaned up?
msw 2016/09/28 23:27:46 Done. (used WmWindowTracker instead)
+ }
+
+ // ash::WmWindowObserver:
+ void OnWindowTitleChanged(ash::WmWindow* window) override {
+ // Override Chrome's product name prepending for Settings windows.
James Cook 2016/09/28 20:41:03 super nit: Maybe just say "Name the window "Settin
msw 2016/09/28 23:27:46 Done.
+ if (window->GetTitle() != l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE))
James Cook 2016/09/28 20:41:03 Aside: Ugh, aura::Window::SetTitle calls observers
msw 2016/09/28 23:27:46 Acknowledged. Worth following up?
James Cook 2016/09/29 02:49:46 Yeah, I think it's worth fixing. There are only a
+ window->SetTitle(l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE));
}
private:

Powered by Google App Engine
This is Rietveld 408576698