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

Side by Side Diff: chrome/browser/extensions/extension_install_dialog.cc

Issue 7741037: Add WebstoreInlineInstaller (downloads store data, shows the install UI, and starts the install). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Put webstore response in the right directory. Created 9 years, 3 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/extension_install_dialog.h"
6
7 #include "base/file_path.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/values.h"
10 #include "chrome/common/extensions/extension.h"
11
12 // A flag used for SetExtensionInstallDialogForManifestAutoConfirmForTests
13 enum AutoConfirmForTest {
14 DO_NOT_SKIP = 0,
15 PROCEED,
16 ABORT
17 };
18 AutoConfirmForTest auto_confirm_for_tests = DO_NOT_SKIP;
19
20 void ShowExtensionInstallDialogForManifest(
21 Profile *profile,
22 ExtensionInstallUI::Delegate* delegate,
23 const DictionaryValue* manifest,
24 const std::string& id,
25 const std::string& localized_name,
26 SkBitmap* icon,
27 ExtensionInstallUI::PromptType type,
28 scoped_refptr<Extension>* dummy_extension) {
29 scoped_ptr<DictionaryValue> localized_manifest;
30 if (!localized_name.empty()) {
31 localized_manifest.reset(manifest->DeepCopy());
32 localized_manifest->SetString(extension_manifest_keys::kName,
33 localized_name);
34 }
35
36 std::string init_errors;
37 *dummy_extension = Extension::CreateWithId(
38 FilePath(),
39 Extension::INTERNAL,
40 localized_manifest.get() ? *localized_manifest.get() : *manifest,
41 Extension::NO_FLAGS,
42 id,
43 &init_errors);
44 if (!dummy_extension->get()) {
45 return;
46 }
47
48 if (icon->empty())
49 icon = const_cast<SkBitmap*>(&Extension::GetDefaultIcon(
50 (*dummy_extension)->is_app()));
51
52 // In tests, we may have setup to proceed or abort without putting up the real
53 // confirmation dialog.
54 if (auto_confirm_for_tests != DO_NOT_SKIP) {
55 if (auto_confirm_for_tests == PROCEED)
56 delegate->InstallUIProceed();
57 else
58 delegate->InstallUIAbort(true);
59 return;
60 }
61
62 ShowExtensionInstallDialog(profile,
63 delegate,
64 dummy_extension->get(),
65 icon,
66 (*dummy_extension)->GetPermissionMessageStrings(),
67 ExtensionInstallUI::INSTALL_PROMPT);
68 return;
69 }
70
71 void SetExtensionInstallDialogForManifestAutoConfirmForTests(
72 bool should_proceed) {
73 auto_confirm_for_tests = should_proceed ? PROCEED : ABORT;
74 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_dialog.h ('k') | chrome/browser/extensions/extension_tab_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698