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_system.h" | 24 #include "chrome/browser/extensions/extension_system.h" |
| 25 #include "chrome/browser/extensions/launch_util.h" |
25 #include "chrome/browser/favicon/favicon_service_factory.h" | 26 #include "chrome/browser/favicon/favicon_service_factory.h" |
26 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/browser/ui/app_list/app_list_util.h" | 28 #include "chrome/browser/ui/app_list/app_list_util.h" |
28 #include "chrome/browser/ui/browser_dialogs.h" | 29 #include "chrome/browser/ui/browser_dialogs.h" |
29 #include "chrome/browser/ui/browser_finder.h" | 30 #include "chrome/browser/ui/browser_finder.h" |
30 #include "chrome/browser/ui/browser_tabstrip.h" | 31 #include "chrome/browser/ui/browser_tabstrip.h" |
31 #include "chrome/browser/ui/browser_window.h" | 32 #include "chrome/browser/ui/browser_window.h" |
32 #include "chrome/browser/ui/extensions/application_launch.h" | 33 #include "chrome/browser/ui/extensions/application_launch.h" |
33 #include "chrome/browser/ui/extensions/extension_enable_flow.h" | 34 #include "chrome/browser/ui/extensions/extension_enable_flow.h" |
34 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 35 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 extension, | 148 extension, |
148 extension_misc::EXTENSION_ICON_BITTY, | 149 extension_misc::EXTENSION_ICON_BITTY, |
149 ExtensionIconSet::MATCH_BIGGER, | 150 ExtensionIconSet::MATCH_BIGGER, |
150 false, | 151 false, |
151 &icon_small_exists); | 152 &icon_small_exists); |
152 value->SetString("icon_small", icon_small.spec()); | 153 value->SetString("icon_small", icon_small.spec()); |
153 value->SetBoolean("icon_small_exists", icon_small_exists); | 154 value->SetBoolean("icon_small_exists", icon_small_exists); |
154 value->SetInteger("launch_container", | 155 value->SetInteger("launch_container", |
155 extensions::AppLaunchInfo::GetLaunchContainer(extension)); | 156 extensions::AppLaunchInfo::GetLaunchContainer(extension)); |
156 ExtensionPrefs* prefs = service->extension_prefs(); | 157 ExtensionPrefs* prefs = service->extension_prefs(); |
157 value->SetInteger("launch_type", | 158 value->SetInteger("launch_type", extensions::GetLaunchType(prefs, extension)); |
158 prefs->GetLaunchType(extension)); | |
159 value->SetBoolean("is_component", | 159 value->SetBoolean("is_component", |
160 extension->location() == extensions::Manifest::COMPONENT); | 160 extension->location() == extensions::Manifest::COMPONENT); |
161 value->SetBoolean("is_webstore", | 161 value->SetBoolean("is_webstore", |
162 extension->id() == extension_misc::kWebStoreAppId); | 162 extension->id() == extension_misc::kWebStoreAppId); |
163 | 163 |
164 AppSorting* sorting = prefs->app_sorting(); | 164 AppSorting* sorting = prefs->app_sorting(); |
165 syncer::StringOrdinal page_ordinal = sorting->GetPageOrdinal(extension->id()); | 165 syncer::StringOrdinal page_ordinal = sorting->GetPageOrdinal(extension->id()); |
166 if (!page_ordinal.IsValid()) { | 166 if (!page_ordinal.IsValid()) { |
167 // Make sure every app has a page ordinal (some predate the page ordinal). | 167 // Make sure every app has a page ordinal (some predate the page ordinal). |
168 // The webstore app should be on the first page. | 168 // The webstore app should be on the first page. |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 CHECK(args->GetDouble(1, &launch_type)); | 552 CHECK(args->GetDouble(1, &launch_type)); |
553 | 553 |
554 const Extension* extension = | 554 const Extension* extension = |
555 extension_service_->GetExtensionById(extension_id, true); | 555 extension_service_->GetExtensionById(extension_id, true); |
556 if (!extension) | 556 if (!extension) |
557 return; | 557 return; |
558 | 558 |
559 // Don't update the page; it already knows about the launch type change. | 559 // Don't update the page; it already knows about the launch type change. |
560 base::AutoReset<bool> auto_reset(&ignore_changes_, true); | 560 base::AutoReset<bool> auto_reset(&ignore_changes_, true); |
561 | 561 |
562 extension_service_->extension_prefs()->SetLaunchType( | 562 extensions::SetLaunchType( |
| 563 extension_service_->extension_prefs(), |
563 extension_id, | 564 extension_id, |
564 static_cast<ExtensionPrefs::LaunchType>( | 565 static_cast<extensions::LaunchType>( |
565 static_cast<int>(launch_type))); | 566 static_cast<int>(launch_type))); |
566 } | 567 } |
567 | 568 |
568 void AppLauncherHandler::HandleUninstallApp(const ListValue* args) { | 569 void AppLauncherHandler::HandleUninstallApp(const ListValue* args) { |
569 std::string extension_id; | 570 std::string extension_id; |
570 CHECK(args->GetString(0, &extension_id)); | 571 CHECK(args->GetString(0, &extension_id)); |
571 | 572 |
572 const Extension* extension = extension_service_->GetInstalledExtension( | 573 const Extension* extension = extension_service_->GetInstalledExtension( |
573 extension_id); | 574 extension_id); |
574 if (!extension) | 575 if (!extension) |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() { | 839 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() { |
839 if (!extension_uninstall_dialog_.get()) { | 840 if (!extension_uninstall_dialog_.get()) { |
840 Browser* browser = chrome::FindBrowserWithWebContents( | 841 Browser* browser = chrome::FindBrowserWithWebContents( |
841 web_ui()->GetWebContents()); | 842 web_ui()->GetWebContents()); |
842 extension_uninstall_dialog_.reset( | 843 extension_uninstall_dialog_.reset( |
843 ExtensionUninstallDialog::Create(extension_service_->profile(), | 844 ExtensionUninstallDialog::Create(extension_service_->profile(), |
844 browser, this)); | 845 browser, this)); |
845 } | 846 } |
846 return extension_uninstall_dialog_.get(); | 847 return extension_uninstall_dialog_.get(); |
847 } | 848 } |
OLD | NEW |