OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/ash/launcher/settings_window_observer.h" | 5 #include "chrome/browser/ui/ash/launcher/settings_window_observer.h" |
6 | 6 |
7 #include "ash/common/shelf/shelf_item_types.h" | 7 #include "ash/common/shelf/shelf_item_types.h" |
8 #include "ash/resources/grit/ash_resources.h" | 8 #include "ash/resources/grit/ash_resources.h" |
9 #include "ash/wm/window_properties.h" | 9 #include "ash/wm/window_properties.h" |
10 #include "chrome/browser/ui/ash/ash_util.h" | 10 #include "chrome/browser/ui/ash/ash_util.h" |
11 #include "chrome/browser/ui/ash/property_util.h" | 11 #include "chrome/browser/ui/ash/property_util.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
14 #include "chrome/browser/ui/settings_window_manager.h" | 14 #include "chrome/browser/ui/settings_window_manager.h" |
15 #include "components/strings/grit/components_strings.h" | 15 #include "components/strings/grit/components_strings.h" |
16 #include "services/ui/public/cpp/property_type_converters.h" | 16 #include "services/ui/public/cpp/property_type_converters.h" |
17 #include "services/ui/public/cpp/window.h" | 17 #include "services/ui/public/cpp/window.h" |
18 #include "services/ui/public/cpp/window_property.h" | 18 #include "services/ui/public/cpp/window_property.h" |
19 #include "services/ui/public/interfaces/window_manager.mojom.h" | 19 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 20 #include "ui/aura/client/aura_constants.h" |
20 #include "ui/aura/mus/mus_util.h" | 21 #include "ui/aura/mus/mus_util.h" |
21 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
22 #include "ui/aura/window_property.h" | 23 #include "ui/aura/window_property.h" |
23 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "ui/base/resource/resource_bundle.h" |
| 26 #include "ui/gfx/image/image_skia.h" |
24 | 27 |
25 namespace { | 28 namespace { |
26 | 29 |
27 // This class is only used in classic ash to rename the Settings window. | 30 // This class is only used in classic ash to rename the Settings window. |
28 class AuraWindowSettingsTitleTracker : public aura::WindowTracker { | 31 class AuraWindowSettingsTitleTracker : public aura::WindowTracker { |
29 public: | 32 public: |
30 AuraWindowSettingsTitleTracker() {} | 33 AuraWindowSettingsTitleTracker() {} |
31 ~AuraWindowSettingsTitleTracker() override {} | 34 ~AuraWindowSettingsTitleTracker() override {} |
32 | 35 |
33 // aura::WindowTracker: | 36 // aura::WindowTracker: |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 SettingsWindowObserver::~SettingsWindowObserver() { | 80 SettingsWindowObserver::~SettingsWindowObserver() { |
78 chrome::SettingsWindowManager::GetInstance()->RemoveObserver(this); | 81 chrome::SettingsWindowManager::GetInstance()->RemoveObserver(this); |
79 } | 82 } |
80 | 83 |
81 void SettingsWindowObserver::OnNewSettingsWindow(Browser* settings_browser) { | 84 void SettingsWindowObserver::OnNewSettingsWindow(Browser* settings_browser) { |
82 aura::Window* window = settings_browser->window()->GetNativeWindow(); | 85 aura::Window* window = settings_browser->window()->GetNativeWindow(); |
83 property_util::SetTitle(window, | 86 property_util::SetTitle(window, |
84 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); | 87 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); |
85 property_util::SetIntProperty(window, ash::kShelfItemTypeKey, | 88 property_util::SetIntProperty(window, ash::kShelfItemTypeKey, |
86 ash::TYPE_DIALOG); | 89 ash::TYPE_DIALOG); |
87 property_util::SetIntProperty(window, ash::kShelfIconResourceIdKey, | 90 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
88 IDR_ASH_SHELF_ICON_SETTINGS); | 91 gfx::ImageSkia* icon = rb.GetImageSkiaNamed(IDR_ASH_SHELF_ICON_SETTINGS); |
| 92 // The new gfx::ImageSkia instance is owned by the window itself. |
| 93 window->SetProperty(aura::client::kWindowIconKey, new gfx::ImageSkia(*icon)); |
89 | 94 |
90 if (chrome::IsRunningInMash()) | 95 if (chrome::IsRunningInMash()) |
91 ui_window_tracker_->Add(aura::GetMusWindow(window)); | 96 ui_window_tracker_->Add(aura::GetMusWindow(window)); |
92 else | 97 else |
93 aura_window_tracker_->Add(window); | 98 aura_window_tracker_->Add(window); |
94 } | 99 } |
OLD | NEW |