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" | |
20 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
21 #include "extensions/browser/extension_registry.h" | |
22 #include "ui/base/win/shell.h" | 19 #include "ui/base/win/shell.h" |
23 #include "ui/views/win/hwnd_util.h" | 20 #include "ui/views/win/hwnd_util.h" |
24 | 21 |
25 using extensions::ExtensionRegistry; | |
26 | |
27 BrowserWindowPropertyManager::BrowserWindowPropertyManager(BrowserView* view) | 22 BrowserWindowPropertyManager::BrowserWindowPropertyManager(BrowserView* view) |
28 : view_(view) { | 23 : view_(view) { |
29 DCHECK(view_); | 24 DCHECK(view_); |
30 profile_pref_registrar_.Init(view_->browser()->profile()->GetPrefs()); | 25 profile_pref_registrar_.Init(view_->browser()->profile()->GetPrefs()); |
31 | 26 |
32 // Monitor the profile icon version on Windows so that we can set the browser | 27 // Monitor the profile icon version on Windows so that we can set the browser |
33 // relaunch icon when the version changes (e.g on initial icon creation). | 28 // relaunch icon when the version changes (e.g on initial icon creation). |
34 profile_pref_registrar_.Add( | 29 profile_pref_registrar_.Add( |
35 prefs::kProfileIconVersion, | 30 prefs::kProfileIconVersion, |
36 base::Bind(&BrowserWindowPropertyManager::OnProfileIconVersionChange, | 31 base::Bind(&BrowserWindowPropertyManager::OnProfileIconVersionChange, |
(...skipping 14 matching lines...) Expand all Loading... |
51 ShellIntegration::GetAppModelIdForProfile( | 46 ShellIntegration::GetAppModelIdForProfile( |
52 base::UTF8ToWide(browser->app_name()), | 47 base::UTF8ToWide(browser->app_name()), |
53 profile->GetPath()) : | 48 profile->GetPath()) : |
54 ShellIntegration::GetChromiumModelIdForProfile(profile->GetPath()); | 49 ShellIntegration::GetChromiumModelIdForProfile(profile->GetPath()); |
55 base::string16 icon_path_string; | 50 base::string16 icon_path_string; |
56 base::string16 command_line_string; | 51 base::string16 command_line_string; |
57 base::string16 pinned_name; | 52 base::string16 pinned_name; |
58 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 53 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
59 ProfileShortcutManager* shortcut_manager = NULL; | 54 ProfileShortcutManager* shortcut_manager = NULL; |
60 | 55 |
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 | |
74 // The profile manager may be NULL in testing. | 56 // The profile manager may be NULL in testing. |
75 if (profile_manager) | 57 if (profile_manager) |
76 shortcut_manager = profile_manager->profile_shortcut_manager(); | 58 shortcut_manager = profile_manager->profile_shortcut_manager(); |
77 | 59 |
78 if (!browser->is_app() && shortcut_manager && | 60 if (!browser->is_app() && shortcut_manager && |
79 profile->GetPrefs()->HasPrefPath(prefs::kProfileIconVersion)) { | 61 profile->GetPrefs()->HasPrefPath(prefs::kProfileIconVersion)) { |
80 const base::FilePath& profile_path = profile->GetPath(); | 62 const base::FilePath& profile_path = profile->GetPath(); |
81 | 63 |
82 // Set relaunch details to use profile. | 64 // Set relaunch details to use profile. |
83 CommandLine command_line(CommandLine::NO_PROGRAM); | 65 CommandLine command_line(CommandLine::NO_PROGRAM); |
(...skipping 20 matching lines...) Expand all Loading... |
104 return scoped_ptr<BrowserWindowPropertyManager>(); | 86 return scoped_ptr<BrowserWindowPropertyManager>(); |
105 } | 87 } |
106 | 88 |
107 return scoped_ptr<BrowserWindowPropertyManager>( | 89 return scoped_ptr<BrowserWindowPropertyManager>( |
108 new BrowserWindowPropertyManager(view)); | 90 new BrowserWindowPropertyManager(view)); |
109 } | 91 } |
110 | 92 |
111 void BrowserWindowPropertyManager::OnProfileIconVersionChange() { | 93 void BrowserWindowPropertyManager::OnProfileIconVersionChange() { |
112 UpdateWindowProperties(views::HWNDForNativeWindow(view_->GetNativeWindow())); | 94 UpdateWindowProperties(views::HWNDForNativeWindow(view_->GetNativeWindow())); |
113 } | 95 } |
OLD | NEW |