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/apps/shortcut_manager.h" | 5 #include "chrome/browser/apps/shortcut_manager.h" |
6 | 6 |
7 #include "apps/pref_names.h" | 7 #include "apps/pref_names.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 extension->ShouldDisplayInAppLauncher(); | 54 extension->ShouldDisplayInAppLauncher(); |
55 } | 55 } |
56 | 56 |
57 } // namespace | 57 } // namespace |
58 | 58 |
59 AppShortcutManager::AppShortcutManager(Profile* profile) | 59 AppShortcutManager::AppShortcutManager(Profile* profile) |
60 : profile_(profile), | 60 : profile_(profile), |
61 is_profile_info_cache_observer_(false), | 61 is_profile_info_cache_observer_(false), |
62 prefs_(profile->GetPrefs()), | 62 prefs_(profile->GetPrefs()), |
63 weak_factory_(this) { | 63 weak_factory_(this) { |
| 64 // Use of g_browser_process requires that we are either on the UI thread, or |
| 65 // there are no threads initialized (such as in unit tests). |
| 66 DCHECK( |
| 67 !content::BrowserThread::IsWellKnownThread(content::BrowserThread::UI) || |
| 68 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 69 |
64 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, | 70 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, |
65 content::Source<Profile>(profile_)); | 71 content::Source<Profile>(profile_)); |
66 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 72 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
67 content::Source<Profile>(profile_)); | 73 content::Source<Profile>(profile_)); |
68 // Wait for extensions to be ready before running OnceOffCreateShortcuts. | 74 // Wait for extensions to be ready before running OnceOffCreateShortcuts. |
69 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, | 75 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, |
70 content::Source<Profile>(profile_)); | 76 content::Source<Profile>(profile_)); |
71 | 77 |
72 // TODO(mgiuca): This use of g_browser_process should be DCHECKed for | |
73 // content::BrowserThread::CurrentlyOn(content::BrowserThread::UI). This check | |
74 // currently fails browser_tests, due to http://crbug.com/251191. | |
75 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 78 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
76 // profile_manager might be NULL in testing environments. | 79 // profile_manager might be NULL in testing environments. |
77 if (profile_manager) { | 80 if (profile_manager) { |
78 profile_manager->GetProfileInfoCache().AddObserver(this); | 81 profile_manager->GetProfileInfoCache().AddObserver(this); |
79 is_profile_info_cache_observer_ = true; | 82 is_profile_info_cache_observer_ = true; |
80 } | 83 } |
81 } | 84 } |
82 | 85 |
83 AppShortcutManager::~AppShortcutManager() { | 86 AppShortcutManager::~AppShortcutManager() { |
84 if (g_browser_process && is_profile_info_cache_observer_) { | 87 if (g_browser_process && is_profile_info_cache_observer_) { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 *it->get(), profile_, base::Bind(&CreateShortcutsInApplicationsMenu)); | 185 *it->get(), profile_, base::Bind(&CreateShortcutsInApplicationsMenu)); |
183 } | 186 } |
184 } | 187 } |
185 | 188 |
186 void AppShortcutManager::DeleteApplicationShortcuts( | 189 void AppShortcutManager::DeleteApplicationShortcuts( |
187 const Extension* extension) { | 190 const Extension* extension) { |
188 ShellIntegration::ShortcutInfo delete_info = | 191 ShellIntegration::ShortcutInfo delete_info = |
189 web_app::ShortcutInfoForExtensionAndProfile(extension, profile_); | 192 web_app::ShortcutInfoForExtensionAndProfile(extension, profile_); |
190 web_app::DeleteAllShortcuts(delete_info); | 193 web_app::DeleteAllShortcuts(delete_info); |
191 } | 194 } |
OLD | NEW |