Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/ash/launcher/settings_window_observer.h" | |
| 6 | |
| 7 #include "ash/common/shelf/shelf_item_types.h" | |
| 8 #include "ash/common/wm_lookup.h" | |
|
James Cook
2016/10/01 00:16:21
I think you have a few unnecessary headers here.
msw
2016/10/03 19:14:23
Done; let me know if I missed any.
| |
| 9 #include "ash/common/wm_window.h" | |
| 10 #include "ash/common/wm_window_property.h" | |
| 11 #include "ash/resources/grit/ash_resources.h" | |
| 12 #include "ash/wm/window_properties.h" | |
| 13 #include "chrome/browser/ui/ash/ash_util.h" | |
| 14 #include "chrome/browser/ui/ash/property_util.h" | |
| 15 #include "chrome/browser/ui/browser.h" | |
| 16 #include "chrome/browser/ui/settings_window_manager.h" | |
| 17 #include "chrome/browser/ui/views/frame/browser_view.h" | |
| 18 #include "components/strings/grit/components_strings.h" | |
| 19 #include "services/ui/public/cpp/property_type_converters.h" | |
| 20 #include "services/ui/public/cpp/window.h" | |
| 21 #include "services/ui/public/interfaces/window_manager.mojom.h" | |
| 22 #include "ui/aura/mus/mus_util.h" | |
| 23 #include "ui/aura/window.h" | |
| 24 #include "ui/aura/window_property.h" | |
| 25 #include "ui/base/l10n/l10n_util.h" | |
| 26 | |
| 27 namespace { | |
| 28 | |
| 29 class AuraWindowSettingsTitleTracker : public aura::WindowTracker { | |
|
James Cook
2016/10/01 00:16:21
This and the class below could use a comment about
msw
2016/10/03 19:14:23
Done.
| |
| 30 public: | |
| 31 AuraWindowSettingsTitleTracker() {} | |
| 32 ~AuraWindowSettingsTitleTracker() override {} | |
| 33 | |
| 34 // aura::WindowTracker: | |
| 35 void OnWindowTitleChanged(aura::Window* window) override { | |
| 36 // Name the window "Settings" instead of "Google Chrome - Settings". | |
| 37 window->SetTitle(l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); | |
| 38 } | |
| 39 | |
| 40 private: | |
| 41 DISALLOW_COPY_AND_ASSIGN(AuraWindowSettingsTitleTracker); | |
| 42 }; | |
| 43 | |
| 44 class UiWindowSettingsTitleTracker : public ui::WindowTracker { | |
| 45 public: | |
| 46 UiWindowSettingsTitleTracker() {} | |
| 47 ~UiWindowSettingsTitleTracker() override {} | |
| 48 | |
| 49 // ui::WindowTracker: | |
| 50 void OnWindowSharedPropertyChanged( | |
| 51 ui::Window* window, | |
| 52 const std::string& name, | |
| 53 const std::vector<uint8_t>* old_data, | |
| 54 const std::vector<uint8_t>* new_data) override { | |
| 55 if (name == ui::mojom::WindowManager::kWindowTitle_Property) { | |
| 56 // Name the window "Settings" instead of "Google Chrome - Settings". | |
| 57 window->SetSharedProperty<base::string16>( | |
| 58 ui::mojom::WindowManager::kWindowTitle_Property, | |
| 59 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); | |
| 60 } | |
| 61 } | |
| 62 | |
| 63 private: | |
| 64 DISALLOW_COPY_AND_ASSIGN(UiWindowSettingsTitleTracker); | |
| 65 }; | |
| 66 | |
| 67 } // namespace | |
| 68 | |
| 69 SettingsWindowObserver::SettingsWindowObserver() | |
| 70 : aura_window_tracker_(new AuraWindowSettingsTitleTracker), | |
|
James Cook
2016/10/01 00:16:21
Only create the one you need based on IsRunningInM
msw
2016/10/03 19:14:23
Done.
| |
| 71 ui_window_tracker_(new UiWindowSettingsTitleTracker) { | |
| 72 chrome::SettingsWindowManager::GetInstance()->AddObserver(this); | |
| 73 } | |
| 74 | |
| 75 SettingsWindowObserver::~SettingsWindowObserver() { | |
| 76 chrome::SettingsWindowManager::GetInstance()->RemoveObserver(this); | |
| 77 } | |
| 78 | |
| 79 void SettingsWindowObserver::OnNewSettingsWindow(Browser* settings_browser) { | |
| 80 BrowserView* view = BrowserView::GetBrowserViewForBrowser(settings_browser); | |
| 81 aura::Window* window = view->GetWidget()->GetNativeView(); | |
| 82 SetTitle(window, l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); | |
|
James Cook
2016/10/01 00:16:21
This function, and the ones below, need to be in a
msw
2016/10/03 19:14:23
Done.
| |
| 83 SetIntProperty(window, ash::kShelfItemTypeKey, ash::TYPE_DIALOG); | |
| 84 SetIntProperty(window, ash::kShelfIconResourceIdKey, | |
| 85 IDR_ASH_SHELF_ICON_SETTINGS); | |
| 86 | |
| 87 ui::Window* ui_window = aura::GetMusWindow(window); | |
| 88 DCHECK_EQ(chrome::IsRunningInMash(), !!ui_window); | |
| 89 if (ui_window) | |
| 90 ui_window_tracker_->Add(ui_window); | |
| 91 else | |
| 92 aura_window_tracker_->Add(window); | |
| 93 } | |
| OLD | NEW |