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

Side by Side Diff: chrome/browser/dom_ui/app_launcher_handler.cc

Issue 3903002: Uninstall default apps if user hides promo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add DCHECK Created 10 years, 2 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 | « chrome/app/generated_resources.grd ('k') | chrome/browser/extensions/default_apps.h » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/dom_ui/app_launcher_handler.h" 5 #include "chrome/browser/dom_ui/app_launcher_handler.h"
6 6
7 #include "app/animation.h" 7 #include "app/animation.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 return; 261 return;
262 262
263 if (!extension_id_prompting_.empty()) 263 if (!extension_id_prompting_.empty())
264 return; // Only one prompt at a time. 264 return; // Only one prompt at a time.
265 265
266 extension_id_prompting_ = extension_id; 266 extension_id_prompting_ = extension_id;
267 GetExtensionInstallUI()->ConfirmUninstall(this, extension); 267 GetExtensionInstallUI()->ConfirmUninstall(this, extension);
268 } 268 }
269 269
270 void AppLauncherHandler::HandleHideAppsPromo(const ListValue* args) { 270 void AppLauncherHandler::HandleHideAppsPromo(const ListValue* args) {
271 // If the user has intentionally hidden the promotion, we'll uninstall all the
272 // default apps (we know the user hasn't installed any apps on their own at
273 // this point, or the promotion wouldn't have been shown).
274 DefaultApps* default_apps = extensions_service_->default_apps();
275 const ExtensionIdSet* app_ids = default_apps->GetDefaultApps();
276 DCHECK(*app_ids == extensions_service_->GetAppIds());
277
278 for (ExtensionIdSet::const_iterator iter = app_ids->begin();
279 iter != app_ids->end(); ++iter) {
280 if (extensions_service_->GetExtensionById(*iter, true))
281 extensions_service_->UninstallExtension(*iter, false);
282 }
283
271 extensions_service_->default_apps()->SetPromoHidden(); 284 extensions_service_->default_apps()->SetPromoHidden();
272 } 285 }
273 286
274 ExtensionInstallUI* AppLauncherHandler::GetExtensionInstallUI() { 287 ExtensionInstallUI* AppLauncherHandler::GetExtensionInstallUI() {
275 if (!install_ui_.get()) 288 if (!install_ui_.get())
276 install_ui_.reset(new ExtensionInstallUI(dom_ui_->GetProfile())); 289 install_ui_.reset(new ExtensionInstallUI(dom_ui_->GetProfile()));
277 return install_ui_.get(); 290 return install_ui_.get();
278 } 291 }
279 292
280 void AppLauncherHandler::InstallUIProceed() { 293 void AppLauncherHandler::InstallUIProceed() {
281 DCHECK(!extension_id_prompting_.empty()); 294 DCHECK(!extension_id_prompting_.empty());
282 295
283 // The extension can be uninstalled in another window while the UI was 296 // The extension can be uninstalled in another window while the UI was
284 // showing. Do nothing in that case. 297 // showing. Do nothing in that case.
285 Extension* extension = 298 Extension* extension =
286 extensions_service_->GetExtensionById(extension_id_prompting_, true); 299 extensions_service_->GetExtensionById(extension_id_prompting_, true);
287 if (!extension) 300 if (!extension)
288 return; 301 return;
289 302
290 extensions_service_->UninstallExtension(extension_id_prompting_, 303 extensions_service_->UninstallExtension(extension_id_prompting_,
291 false /* external_uninstall */); 304 false /* external_uninstall */);
292 extension_id_prompting_ = ""; 305 extension_id_prompting_ = "";
293 } 306 }
294 307
295 void AppLauncherHandler::InstallUIAbort() { 308 void AppLauncherHandler::InstallUIAbort() {
296 extension_id_prompting_ = ""; 309 extension_id_prompting_ = "";
297 } 310 }
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/extensions/default_apps.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698