Chromium Code Reviews| 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/metrics_names.h" | 9 #include "apps/metrics_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/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
| 14 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
| 17 #include "base/prefs/scoped_user_pref_update.h" | 17 #include "base/prefs/scoped_user_pref_update.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/chrome_notification_types.h" | 21 #include "chrome/browser/chrome_notification_types.h" |
| 22 #include "chrome/browser/extensions/crx_installer.h" | 22 #include "chrome/browser/extensions/crx_installer.h" |
| 23 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
| 24 #include "chrome/browser/extensions/extension_ui_util.h" | 24 #include "chrome/browser/extensions/extension_ui_util.h" |
| 25 #include "chrome/browser/extensions/launch_util.h" | 25 #include "chrome/browser/extensions/launch_util.h" |
| 26 #include "chrome/browser/favicon/favicon_service_factory.h" | 26 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 27 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 28 #include "chrome/browser/ui/app_list/app_list_util.h" | 28 #include "chrome/browser/ui/app_list/app_list_util.h" |
| 29 #include "chrome/browser/ui/apps/app_info_dialog.h" | |
| 29 #include "chrome/browser/ui/browser_dialogs.h" | 30 #include "chrome/browser/ui/browser_dialogs.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/app_launch_params.h" | 34 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 34 #include "chrome/browser/ui/extensions/application_launch.h" | 35 #include "chrome/browser/ui/extensions/application_launch.h" |
| 35 #include "chrome/browser/ui/extensions/extension_enable_flow.h" | 36 #include "chrome/browser/ui/extensions/extension_enable_flow.h" |
| 36 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 37 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 37 #include "chrome/browser/ui/webui/extensions/extension_basic_info.h" | 38 #include "chrome/browser/ui/webui/extensions/extension_basic_info.h" |
| 38 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 39 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 base::Unretained(this))); | 216 base::Unretained(this))); |
| 216 web_ui()->RegisterMessageCallback("setLaunchType", | 217 web_ui()->RegisterMessageCallback("setLaunchType", |
| 217 base::Bind(&AppLauncherHandler::HandleSetLaunchType, | 218 base::Bind(&AppLauncherHandler::HandleSetLaunchType, |
| 218 base::Unretained(this))); | 219 base::Unretained(this))); |
| 219 web_ui()->RegisterMessageCallback("uninstallApp", | 220 web_ui()->RegisterMessageCallback("uninstallApp", |
| 220 base::Bind(&AppLauncherHandler::HandleUninstallApp, | 221 base::Bind(&AppLauncherHandler::HandleUninstallApp, |
| 221 base::Unretained(this))); | 222 base::Unretained(this))); |
| 222 web_ui()->RegisterMessageCallback("createAppShortcut", | 223 web_ui()->RegisterMessageCallback("createAppShortcut", |
| 223 base::Bind(&AppLauncherHandler::HandleCreateAppShortcut, | 224 base::Bind(&AppLauncherHandler::HandleCreateAppShortcut, |
| 224 base::Unretained(this))); | 225 base::Unretained(this))); |
| 226 web_ui()->RegisterMessageCallback("showAppInfo", | |
| 227 base::Bind(&AppLauncherHandler::HandleShowAppInfo, | |
| 228 base::Unretained(this))); | |
| 225 web_ui()->RegisterMessageCallback("reorderApps", | 229 web_ui()->RegisterMessageCallback("reorderApps", |
| 226 base::Bind(&AppLauncherHandler::HandleReorderApps, | 230 base::Bind(&AppLauncherHandler::HandleReorderApps, |
| 227 base::Unretained(this))); | 231 base::Unretained(this))); |
| 228 web_ui()->RegisterMessageCallback("setPageIndex", | 232 web_ui()->RegisterMessageCallback("setPageIndex", |
| 229 base::Bind(&AppLauncherHandler::HandleSetPageIndex, | 233 base::Bind(&AppLauncherHandler::HandleSetPageIndex, |
| 230 base::Unretained(this))); | 234 base::Unretained(this))); |
| 231 web_ui()->RegisterMessageCallback("saveAppPageName", | 235 web_ui()->RegisterMessageCallback("saveAppPageName", |
| 232 base::Bind(&AppLauncherHandler::HandleSaveAppPageName, | 236 base::Bind(&AppLauncherHandler::HandleSaveAppPageName, |
| 233 base::Unretained(this))); | 237 base::Unretained(this))); |
| 234 web_ui()->RegisterMessageCallback("generateAppForLink", | 238 web_ui()->RegisterMessageCallback("generateAppForLink", |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 607 if (!extension) | 611 if (!extension) |
| 608 return; | 612 return; |
| 609 | 613 |
| 610 Browser* browser = chrome::FindBrowserWithWebContents( | 614 Browser* browser = chrome::FindBrowserWithWebContents( |
| 611 web_ui()->GetWebContents()); | 615 web_ui()->GetWebContents()); |
| 612 chrome::ShowCreateChromeAppShortcutsDialog( | 616 chrome::ShowCreateChromeAppShortcutsDialog( |
| 613 browser->window()->GetNativeWindow(), browser->profile(), extension, | 617 browser->window()->GetNativeWindow(), browser->profile(), extension, |
| 614 base::Callback<void(bool)>()); | 618 base::Callback<void(bool)>()); |
| 615 } | 619 } |
| 616 | 620 |
| 621 void AppLauncherHandler::HandleShowAppInfo(const base::ListValue* args) { | |
| 622 std::string extension_id; | |
| 623 CHECK(args->GetString(0, &extension_id)); | |
| 624 | |
| 625 const Extension* extension = | |
| 626 extension_service_->GetExtensionById(extension_id, true); | |
|
sashab
2015/02/06 16:23:00
DCHECK(extension) here
tsergeant
2015/02/09 03:10:49
Done.
| |
| 627 | |
| 628 // Display the dialog at a size similar to the app list. | |
|
sashab
2015/02/06 16:23:00
Don't need this comment - code explains it, and wi
tsergeant
2015/02/09 03:10:49
Done.
| |
| 629 ShowAppInfoInNativeDialog( | |
| 630 web_ui()->GetWebContents()->GetTopLevelNativeWindow(), | |
| 631 GetApproximateAppListSize(), | |
| 632 Profile::FromWebUI(web_ui()), extension, base::Bind(&base::DoNothing)); | |
| 633 } | |
| 634 | |
| 617 void AppLauncherHandler::HandleReorderApps(const base::ListValue* args) { | 635 void AppLauncherHandler::HandleReorderApps(const base::ListValue* args) { |
| 618 CHECK(args->GetSize() == 2); | 636 CHECK(args->GetSize() == 2); |
| 619 | 637 |
| 620 std::string dragged_app_id; | 638 std::string dragged_app_id; |
| 621 const base::ListValue* app_order; | 639 const base::ListValue* app_order; |
| 622 CHECK(args->GetString(0, &dragged_app_id)); | 640 CHECK(args->GetString(0, &dragged_app_id)); |
| 623 CHECK(args->GetList(1, &app_order)); | 641 CHECK(args->GetList(1, &app_order)); |
| 624 | 642 |
| 625 std::string predecessor_to_moved_ext; | 643 std::string predecessor_to_moved_ext; |
| 626 std::string successor_to_moved_ext; | 644 std::string successor_to_moved_ext; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 844 Browser* browser = chrome::FindBrowserWithWebContents( | 862 Browser* browser = chrome::FindBrowserWithWebContents( |
| 845 web_ui()->GetWebContents()); | 863 web_ui()->GetWebContents()); |
| 846 extension_uninstall_dialog_.reset( | 864 extension_uninstall_dialog_.reset( |
| 847 extensions::ExtensionUninstallDialog::Create( | 865 extensions::ExtensionUninstallDialog::Create( |
| 848 extension_service_->profile(), | 866 extension_service_->profile(), |
| 849 browser->window()->GetNativeWindow(), | 867 browser->window()->GetNativeWindow(), |
| 850 this)); | 868 this)); |
| 851 } | 869 } |
| 852 return extension_uninstall_dialog_.get(); | 870 return extension_uninstall_dialog_.get(); |
| 853 } | 871 } |
| OLD | NEW |