OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/webui/ntp/app_launcher_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "apps/pref_names.h" | 9 #include "apps/pref_names.h" |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/command_line.h" |
13 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
14 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
16 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
17 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
18 #include "base/values.h" | 19 #include "base/values.h" |
19 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/extensions/crx_installer.h" | 21 #include "chrome/browser/extensions/crx_installer.h" |
21 #include "chrome/browser/extensions/extension_prefs.h" | 22 #include "chrome/browser/extensions/extension_prefs.h" |
22 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
23 #include "chrome/browser/extensions/extension_sorting.h" | 24 #include "chrome/browser/extensions/extension_sorting.h" |
24 #include "chrome/browser/extensions/extension_system.h" | 25 #include "chrome/browser/extensions/extension_system.h" |
25 #include "chrome/browser/extensions/management_policy.h" | 26 #include "chrome/browser/extensions/management_policy.h" |
26 #include "chrome/browser/favicon/favicon_service_factory.h" | 27 #include "chrome/browser/favicon/favicon_service_factory.h" |
27 #include "chrome/browser/favicon/favicon_types.h" | 28 #include "chrome/browser/favicon/favicon_types.h" |
28 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 29 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
29 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
30 #include "chrome/browser/ui/browser_finder.h" | 31 #include "chrome/browser/ui/browser_finder.h" |
31 #include "chrome/browser/ui/browser_tabstrip.h" | 32 #include "chrome/browser/ui/browser_tabstrip.h" |
32 #include "chrome/browser/ui/browser_window.h" | 33 #include "chrome/browser/ui/browser_window.h" |
33 #include "chrome/browser/ui/extensions/application_launch.h" | 34 #include "chrome/browser/ui/extensions/application_launch.h" |
34 #include "chrome/browser/ui/extensions/extension_enable_flow.h" | 35 #include "chrome/browser/ui/extensions/extension_enable_flow.h" |
35 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 36 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
36 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 37 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
37 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 38 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
38 #include "chrome/common/chrome_notification_types.h" | 39 #include "chrome/common/chrome_notification_types.h" |
| 40 #include "chrome/common/chrome_switches.h" |
39 #include "chrome/common/extensions/extension.h" | 41 #include "chrome/common/extensions/extension.h" |
40 #include "chrome/common/extensions/extension_constants.h" | 42 #include "chrome/common/extensions/extension_constants.h" |
41 #include "chrome/common/extensions/extension_icon_set.h" | 43 #include "chrome/common/extensions/extension_icon_set.h" |
42 #include "chrome/common/pref_names.h" | 44 #include "chrome/common/pref_names.h" |
43 #include "chrome/common/url_constants.h" | 45 #include "chrome/common/url_constants.h" |
44 #include "chrome/common/web_application_info.h" | 46 #include "chrome/common/web_application_info.h" |
45 #include "components/user_prefs/pref_registry_syncable.h" | 47 #include "components/user_prefs/pref_registry_syncable.h" |
46 #include "content/public/browser/notification_service.h" | 48 #include "content/public/browser/notification_service.h" |
47 #include "content/public/browser/web_ui.h" | 49 #include "content/public/browser/web_ui.h" |
48 #include "content/public/common/favicon_url.h" | 50 #include "content/public/common/favicon_url.h" |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 it != visible_apps_.end(); ++it) { | 319 it != visible_apps_.end(); ++it) { |
318 const Extension* extension = extension_service_->GetInstalledExtension(*it); | 320 const Extension* extension = extension_service_->GetInstalledExtension(*it); |
319 if (extension && ShouldDisplayInNewTabPage(extension, prefs)) { | 321 if (extension && ShouldDisplayInNewTabPage(extension, prefs)) { |
320 DictionaryValue* app_info = GetAppInfo(extension); | 322 DictionaryValue* app_info = GetAppInfo(extension); |
321 list->Append(app_info); | 323 list->Append(app_info); |
322 } | 324 } |
323 } | 325 } |
324 | 326 |
325 dictionary->Set("apps", list); | 327 dictionary->Set("apps", list); |
326 | 328 |
327 // TODO(estade): remove these settings when the old NTP is removed. The new | |
328 // NTP does it in js. | |
329 #if defined(OS_MACOSX) | 329 #if defined(OS_MACOSX) |
330 // App windows are not yet implemented on mac. | 330 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
331 dictionary->SetBoolean("disableAppWindowLaunch", true); | 331 switches::kEnableAppShims)) |
332 dictionary->SetBoolean("disableCreateAppShortcut", true); | 332 dictionary->SetBoolean("disableCreateAppShortcut", true); |
333 #endif | 333 #endif |
334 | 334 |
335 #if defined(OS_CHROMEOS) | 335 #if defined(OS_CHROMEOS) |
336 // Making shortcut does not make sense on ChromeOS because it does not have | 336 // Making shortcut does not make sense on ChromeOS because it does not have |
337 // a desktop. | 337 // a desktop. |
338 dictionary->SetBoolean("disableCreateAppShortcut", true); | 338 dictionary->SetBoolean("disableCreateAppShortcut", true); |
339 #endif | 339 #endif |
340 | 340 |
341 const ListValue* app_page_names = prefs->GetList(prefs::kNtpAppPageNames); | 341 const ListValue* app_page_names = prefs->GetList(prefs::kNtpAppPageNames); |
342 if (!app_page_names || !app_page_names->GetSize()) { | 342 if (!app_page_names || !app_page_names->GetSize()) { |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() { | 861 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() { |
862 if (!extension_uninstall_dialog_.get()) { | 862 if (!extension_uninstall_dialog_.get()) { |
863 Browser* browser = chrome::FindBrowserWithWebContents( | 863 Browser* browser = chrome::FindBrowserWithWebContents( |
864 web_ui()->GetWebContents()); | 864 web_ui()->GetWebContents()); |
865 extension_uninstall_dialog_.reset( | 865 extension_uninstall_dialog_.reset( |
866 ExtensionUninstallDialog::Create(extension_service_->profile(), | 866 ExtensionUninstallDialog::Create(extension_service_->profile(), |
867 browser, this)); | 867 browser, this)); |
868 } | 868 } |
869 return extension_uninstall_dialog_.get(); | 869 return extension_uninstall_dialog_.get(); |
870 } | 870 } |
OLD | NEW |