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

Unified Diff: chrome/browser/extensions/extension_install_dialog.cc

Issue 11087071: Making ShowExtensionInstallDialog a callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_install_dialog.cc
diff --git a/chrome/browser/extensions/extension_install_dialog.cc b/chrome/browser/extensions/extension_install_dialog.cc
deleted file mode 100644
index a3cd87bf911ec99916e8988d0b5bd51e1665fcee..0000000000000000000000000000000000000000
--- a/chrome/browser/extensions/extension_install_dialog.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/extensions/extension_install_dialog.h"
-
-#include "base/bind.h"
-#include "base/command_line.h"
-#include "base/file_path.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop.h"
-#include "base/values.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/extensions/extension.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "ui/gfx/image/image.h"
-
-namespace {
-
-// A flag used for SetExtensionInstallDialogAutoConfirmForTests
-enum AutoConfirmForTest {
- DO_NOT_SKIP = 0,
- PROCEED,
- ABORT
-};
-
-void AutoConfirmTask(ExtensionInstallPrompt::Delegate* delegate, bool proceed) {
- if (proceed)
- delegate->InstallUIProceed();
- else
- delegate->InstallUIAbort(true);
-}
-
-void DoAutoConfirm(AutoConfirmForTest setting,
- ExtensionInstallPrompt::Delegate* delegate) {
- bool proceed = (setting == PROCEED);
- // We use PostTask instead of calling the delegate directly here, because in
- // the real implementations it's highly likely the message loop will be
- // pumping a few times before the user clicks accept or cancel.
- MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&AutoConfirmTask, delegate, proceed));
-}
-
-AutoConfirmForTest CheckAutoConfirmCommandLineSwitch() {
- const CommandLine* cmdline = CommandLine::ForCurrentProcess();
- if (!cmdline->HasSwitch(switches::kAppsGalleryInstallAutoConfirmForTests))
- return DO_NOT_SKIP;
- std::string value = cmdline->GetSwitchValueASCII(
- switches::kAppsGalleryInstallAutoConfirmForTests);
- if (value == "accept")
- return PROCEED;
- else if (value == "cancel")
- return ABORT;
- else
- NOTREACHED();
- return DO_NOT_SKIP;
-}
-
-} // namespace
-
-void ShowExtensionInstallDialog(gfx::NativeWindow parent,
- content::PageNavigator* navigator,
- ExtensionInstallPrompt::Delegate* delegate,
- const ExtensionInstallPrompt::Prompt& prompt) {
- AutoConfirmForTest auto_confirm = CheckAutoConfirmCommandLineSwitch();
- if (auto_confirm != DO_NOT_SKIP) {
- DoAutoConfirm(auto_confirm, delegate);
- return;
- }
- ShowExtensionInstallDialogImpl(parent, navigator, delegate, prompt);
-}

Powered by Google App Engine
This is Rietveld 408576698