Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(877)

Side by Side Diff: chrome/browser/ui/webui/ntp/app_launcher_handler.cc

Issue 22210003: Track extension uninstalls on the NTP to catch uninstalls of disabled apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/app_launcher.h" 9 #include "apps/app_launcher.h"
10 #include "apps/metrics_names.h" 10 #include "apps/metrics_names.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 scoped_ptr<base::FundamentalValue> highlight(Value::CreateBooleanValue( 263 scoped_ptr<base::FundamentalValue> highlight(Value::CreateBooleanValue(
264 prefs->IsFromBookmark(extension->id()) && 264 prefs->IsFromBookmark(extension->id()) &&
265 attempted_bookmark_app_install_)); 265 attempted_bookmark_app_install_));
266 attempted_bookmark_app_install_ = false; 266 attempted_bookmark_app_install_ = false;
267 web_ui()->CallJavascriptFunction( 267 web_ui()->CallJavascriptFunction(
268 "ntp.appAdded", *app_info, *highlight); 268 "ntp.appAdded", *app_info, *highlight);
269 } 269 }
270 270
271 break; 271 break;
272 } 272 }
273 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { 273 case chrome::NOTIFICATION_EXTENSION_UNLOADED:
274 const Extension* extension = 274 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: {
275 content::Details<extensions::UnloadedExtensionInfo>( 275 const Extension* extension = NULL;
276 details)->extension; 276 bool uninstalled = false;
277 if (type == chrome::NOTIFICATION_EXTENSION_UNINSTALLED) {
278 extension = content::Details<const Extension>(details).ptr();
279 uninstalled = true;
280 } else { // NOTIFICATION_EXTENSION_UNLOADED
281 if (content::Details<extensions::UnloadedExtensionInfo>(
282 details)->reason == extension_misc::UNLOAD_REASON_UNINSTALL) {
283 // Uninstalls are tracked by NOTIFICATION_EXTENSION_UNINSTALLED.
284 return;
285 }
286 extension = content::Details<extensions::UnloadedExtensionInfo>(
287 details)->extension;
288 uninstalled = false;
289 }
277 if (!extension->is_app()) 290 if (!extension->is_app())
278 return; 291 return;
279 292
280 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); 293 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
281 if (!ShouldDisplayInNewTabPage(extension, prefs)) 294 if (!ShouldDisplayInNewTabPage(extension, prefs))
282 return; 295 return;
283 296
284 scoped_ptr<DictionaryValue> app_info(GetAppInfo(extension)); 297 scoped_ptr<DictionaryValue> app_info(GetAppInfo(extension));
285 scoped_ptr<base::FundamentalValue> uninstall_value(
286 Value::CreateBooleanValue(
287 content::Details<extensions::UnloadedExtensionInfo>(
288 details)->reason == extension_misc::UNLOAD_REASON_UNINSTALL));
289 if (app_info.get()) { 298 if (app_info.get()) {
290 visible_apps_.erase(extension->id()); 299 visible_apps_.erase(extension->id());
291 300
301 scoped_ptr<base::FundamentalValue> uninstall_value(
302 Value::CreateBooleanValue(uninstalled));
292 scoped_ptr<base::FundamentalValue> from_page( 303 scoped_ptr<base::FundamentalValue> from_page(
293 Value::CreateBooleanValue(!extension_id_prompting_.empty())); 304 Value::CreateBooleanValue(!extension_id_prompting_.empty()));
294 web_ui()->CallJavascriptFunction( 305 web_ui()->CallJavascriptFunction(
295 "ntp.appRemoved", *app_info, *uninstall_value, *from_page); 306 "ntp.appRemoved", *app_info, *uninstall_value, *from_page);
296 } 307 }
297 break; 308 break;
298 } 309 }
299 case chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED: { 310 case chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED: {
300 const std::string* id = 311 const std::string* id =
301 content::Details<const std::string>(details).ptr(); 312 content::Details<const std::string>(details).ptr();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 extension_pref_change_registrar_.Init( 449 extension_pref_change_registrar_.Init(
439 extension_service_->extension_prefs()->pref_service()); 450 extension_service_->extension_prefs()->pref_service());
440 extension_pref_change_registrar_.Add(ExtensionPrefs::kExtensionsPref, 451 extension_pref_change_registrar_.Add(ExtensionPrefs::kExtensionsPref,
441 callback); 452 callback);
442 extension_pref_change_registrar_.Add(prefs::kNtpAppPageNames, callback); 453 extension_pref_change_registrar_.Add(prefs::kNtpAppPageNames, callback);
443 454
444 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 455 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
445 content::Source<Profile>(profile)); 456 content::Source<Profile>(profile));
446 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 457 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
447 content::Source<Profile>(profile)); 458 content::Source<Profile>(profile));
459 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
460 content::Source<Profile>(profile));
448 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, 461 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED,
449 content::Source<ExtensionSorting>( 462 content::Source<ExtensionSorting>(
450 extension_service_->extension_prefs()->extension_sorting())); 463 extension_service_->extension_prefs()->extension_sorting()));
451 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, 464 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR,
452 content::Source<CrxInstaller>(NULL)); 465 content::Source<CrxInstaller>(NULL));
453 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOAD_ERROR, 466 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOAD_ERROR,
454 content::Source<Profile>(profile)); 467 content::Source<Profile>(profile));
455 } 468 }
456 469
457 has_loaded_apps_ = true; 470 has_loaded_apps_ = true;
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() { 829 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() {
817 if (!extension_uninstall_dialog_.get()) { 830 if (!extension_uninstall_dialog_.get()) {
818 Browser* browser = chrome::FindBrowserWithWebContents( 831 Browser* browser = chrome::FindBrowserWithWebContents(
819 web_ui()->GetWebContents()); 832 web_ui()->GetWebContents());
820 extension_uninstall_dialog_.reset( 833 extension_uninstall_dialog_.reset(
821 ExtensionUninstallDialog::Create(extension_service_->profile(), 834 ExtensionUninstallDialog::Create(extension_service_->profile(),
822 browser, this)); 835 browser, this));
823 } 836 }
824 return extension_uninstall_dialog_.get(); 837 return extension_uninstall_dialog_.get();
825 } 838 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698