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" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 extension, Profile::FromWebUI(web_ui()))) { | 263 extension, Profile::FromWebUI(web_ui()))) { |
264 return; | 264 return; |
265 } | 265 } |
266 | 266 |
267 scoped_ptr<base::DictionaryValue> app_info(GetAppInfo(extension)); | 267 scoped_ptr<base::DictionaryValue> app_info(GetAppInfo(extension)); |
268 if (app_info.get()) { | 268 if (app_info.get()) { |
269 visible_apps_.insert(extension->id()); | 269 visible_apps_.insert(extension->id()); |
270 | 270 |
271 ExtensionPrefs* prefs = | 271 ExtensionPrefs* prefs = |
272 ExtensionPrefs::Get(extension_service_->profile()); | 272 ExtensionPrefs::Get(extension_service_->profile()); |
273 scoped_ptr<base::FundamentalValue> highlight( | 273 base::FundamentalValue highlight( |
274 base::Value::CreateBooleanValue( | 274 prefs->IsFromBookmark(extension->id()) && |
275 prefs->IsFromBookmark(extension->id()) && | 275 attempted_bookmark_app_install_); |
276 attempted_bookmark_app_install_)); | |
277 attempted_bookmark_app_install_ = false; | 276 attempted_bookmark_app_install_ = false; |
278 web_ui()->CallJavascriptFunction( | 277 web_ui()->CallJavascriptFunction("ntp.appAdded", *app_info, highlight); |
279 "ntp.appAdded", *app_info, *highlight); | |
280 } | 278 } |
281 | 279 |
282 break; | 280 break; |
283 } | 281 } |
284 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: | 282 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: |
285 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED: { | 283 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED: { |
286 const Extension* extension = NULL; | 284 const Extension* extension = NULL; |
287 bool uninstalled = false; | 285 bool uninstalled = false; |
288 if (type == chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED) { | 286 if (type == chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED) { |
289 extension = content::Details<const Extension>(details).ptr(); | 287 extension = content::Details<const Extension>(details).ptr(); |
(...skipping 15 matching lines...) Expand all Loading... |
305 if (!extensions::ui_util::ShouldDisplayInNewTabPage( | 303 if (!extensions::ui_util::ShouldDisplayInNewTabPage( |
306 extension, Profile::FromWebUI(web_ui()))) { | 304 extension, Profile::FromWebUI(web_ui()))) { |
307 return; | 305 return; |
308 } | 306 } |
309 | 307 |
310 scoped_ptr<base::DictionaryValue> app_info(GetAppInfo(extension)); | 308 scoped_ptr<base::DictionaryValue> app_info(GetAppInfo(extension)); |
311 if (app_info.get()) { | 309 if (app_info.get()) { |
312 if (uninstalled) | 310 if (uninstalled) |
313 visible_apps_.erase(extension->id()); | 311 visible_apps_.erase(extension->id()); |
314 | 312 |
315 scoped_ptr<base::FundamentalValue> uninstall_value( | |
316 base::Value::CreateBooleanValue(uninstalled)); | |
317 scoped_ptr<base::FundamentalValue> from_page( | |
318 base::Value::CreateBooleanValue(!extension_id_prompting_.empty())); | |
319 web_ui()->CallJavascriptFunction( | 313 web_ui()->CallJavascriptFunction( |
320 "ntp.appRemoved", *app_info, *uninstall_value, *from_page); | 314 "ntp.appRemoved", |
| 315 *app_info, |
| 316 base::FundamentalValue(uninstalled), |
| 317 base::FundamentalValue(!extension_id_prompting_.empty())); |
321 } | 318 } |
322 break; | 319 break; |
323 } | 320 } |
324 case chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED: { | 321 case chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED: { |
325 const std::string* id = | 322 const std::string* id = |
326 content::Details<const std::string>(details).ptr(); | 323 content::Details<const std::string>(details).ptr(); |
327 if (id) { | 324 if (id) { |
328 const Extension* extension = | 325 const Extension* extension = |
329 extension_service_->GetInstalledExtension(*id); | 326 extension_service_->GetInstalledExtension(*id); |
330 if (!extension) { | 327 if (!extension) { |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 AppLauncherHandler::GetExtensionUninstallDialog() { | 835 AppLauncherHandler::GetExtensionUninstallDialog() { |
839 if (!extension_uninstall_dialog_.get()) { | 836 if (!extension_uninstall_dialog_.get()) { |
840 Browser* browser = chrome::FindBrowserWithWebContents( | 837 Browser* browser = chrome::FindBrowserWithWebContents( |
841 web_ui()->GetWebContents()); | 838 web_ui()->GetWebContents()); |
842 extension_uninstall_dialog_.reset( | 839 extension_uninstall_dialog_.reset( |
843 extensions::ExtensionUninstallDialog::Create( | 840 extensions::ExtensionUninstallDialog::Create( |
844 extension_service_->profile(), browser, this)); | 841 extension_service_->profile(), browser, this)); |
845 } | 842 } |
846 return extension_uninstall_dialog_.get(); | 843 return extension_uninstall_dialog_.get(); |
847 } | 844 } |
OLD | NEW |