OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/views/frame/browser_window_property_manager_win.h" | 5 #include "chrome/browser/ui/views/frame/browser_window_property_manager_win.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
14 #include "chrome/browser/profiles/profile_shortcut_manager_win.h" | 14 #include "chrome/browser/profiles/profile_shortcut_manager_win.h" |
15 #include "chrome/browser/shell_integration.h" | 15 #include "chrome/browser/shell_integration.h" |
16 #include "chrome/browser/ui/host_desktop.h" | 16 #include "chrome/browser/ui/host_desktop.h" |
17 #include "chrome/browser/ui/views/frame/browser_view.h" | 17 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 18 #include "chrome/browser/web_applications/web_app.h" |
| 19 #include "chrome/browser/web_applications/web_app_win.h" |
18 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 21 #include "extensions/browser/extension_registry.h" |
19 #include "ui/base/win/shell.h" | 22 #include "ui/base/win/shell.h" |
20 #include "ui/views/win/hwnd_util.h" | 23 #include "ui/views/win/hwnd_util.h" |
21 | 24 |
| 25 using extensions::ExtensionRegistry; |
| 26 |
22 BrowserWindowPropertyManager::BrowserWindowPropertyManager(BrowserView* view) | 27 BrowserWindowPropertyManager::BrowserWindowPropertyManager(BrowserView* view) |
23 : view_(view) { | 28 : view_(view) { |
24 DCHECK(view_); | 29 DCHECK(view_); |
25 profile_pref_registrar_.Init(view_->browser()->profile()->GetPrefs()); | 30 profile_pref_registrar_.Init(view_->browser()->profile()->GetPrefs()); |
26 | 31 |
27 // Monitor the profile icon version on Windows so that we can set the browser | 32 // Monitor the profile icon version on Windows so that we can set the browser |
28 // relaunch icon when the version changes (e.g on initial icon creation). | 33 // relaunch icon when the version changes (e.g on initial icon creation). |
29 profile_pref_registrar_.Add( | 34 profile_pref_registrar_.Add( |
30 prefs::kProfileIconVersion, | 35 prefs::kProfileIconVersion, |
31 base::Bind(&BrowserWindowPropertyManager::OnProfileIconVersionChange, | 36 base::Bind(&BrowserWindowPropertyManager::OnProfileIconVersionChange, |
(...skipping 14 matching lines...) Expand all Loading... |
46 ShellIntegration::GetAppModelIdForProfile( | 51 ShellIntegration::GetAppModelIdForProfile( |
47 base::UTF8ToWide(browser->app_name()), | 52 base::UTF8ToWide(browser->app_name()), |
48 profile->GetPath()) : | 53 profile->GetPath()) : |
49 ShellIntegration::GetChromiumModelIdForProfile(profile->GetPath()); | 54 ShellIntegration::GetChromiumModelIdForProfile(profile->GetPath()); |
50 base::string16 icon_path_string; | 55 base::string16 icon_path_string; |
51 base::string16 command_line_string; | 56 base::string16 command_line_string; |
52 base::string16 pinned_name; | 57 base::string16 pinned_name; |
53 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 58 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
54 ProfileShortcutManager* shortcut_manager = NULL; | 59 ProfileShortcutManager* shortcut_manager = NULL; |
55 | 60 |
| 61 // Apps set their relaunch details based on app's details. |
| 62 if (browser->is_app()) { |
| 63 ExtensionRegistry* registry = ExtensionRegistry::Get(profile); |
| 64 const extensions::Extension* extension = registry->GetExtensionById( |
| 65 web_app::GetExtensionIdFromApplicationName(browser->app_name()), |
| 66 ExtensionRegistry::EVERYTHING); |
| 67 if (extension) { |
| 68 ui::win::SetAppIdForWindow(app_id, hwnd); |
| 69 web_app::UpdateRelaunchDetailsForApp(profile, extension, hwnd); |
| 70 return; |
| 71 } |
| 72 } |
| 73 |
56 // The profile manager may be NULL in testing. | 74 // The profile manager may be NULL in testing. |
57 if (profile_manager) | 75 if (profile_manager) |
58 shortcut_manager = profile_manager->profile_shortcut_manager(); | 76 shortcut_manager = profile_manager->profile_shortcut_manager(); |
59 | 77 |
60 if (!browser->is_app() && shortcut_manager && | 78 if (!browser->is_app() && shortcut_manager && |
61 profile->GetPrefs()->HasPrefPath(prefs::kProfileIconVersion)) { | 79 profile->GetPrefs()->HasPrefPath(prefs::kProfileIconVersion)) { |
62 const base::FilePath& profile_path = profile->GetPath(); | 80 const base::FilePath& profile_path = profile->GetPath(); |
63 | 81 |
64 // Set relaunch details to use profile. | 82 // Set relaunch details to use profile. |
65 CommandLine command_line(CommandLine::NO_PROGRAM); | 83 CommandLine command_line(CommandLine::NO_PROGRAM); |
(...skipping 20 matching lines...) Expand all Loading... |
86 return scoped_ptr<BrowserWindowPropertyManager>(); | 104 return scoped_ptr<BrowserWindowPropertyManager>(); |
87 } | 105 } |
88 | 106 |
89 return scoped_ptr<BrowserWindowPropertyManager>( | 107 return scoped_ptr<BrowserWindowPropertyManager>( |
90 new BrowserWindowPropertyManager(view)); | 108 new BrowserWindowPropertyManager(view)); |
91 } | 109 } |
92 | 110 |
93 void BrowserWindowPropertyManager::OnProfileIconVersionChange() { | 111 void BrowserWindowPropertyManager::OnProfileIconVersionChange() { |
94 UpdateWindowProperties(views::HWNDForNativeWindow(view_->GetNativeWindow())); | 112 UpdateWindowProperties(views::HWNDForNativeWindow(view_->GetNativeWindow())); |
95 } | 113 } |
OLD | NEW |