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/extensions/bundle_installer.h" | 5 #include "chrome/browser/extensions/bundle_installer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/extensions/crx_installer.h" | 15 #include "chrome/browser/extensions/crx_installer.h" |
16 #include "chrome/browser/extensions/permissions_updater.h" | |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/browser/ui/browser_finder.h" | 19 #include "chrome/browser/ui/browser_finder.h" |
19 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_list.h" |
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
21 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
23 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
24 #include "extensions/common/extension.h" | 25 #include "extensions/common/extension.h" |
25 #include "extensions/common/permissions/permission_set.h" | 26 #include "extensions/common/permissions/permission_set.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
45 // We require localized names so we can have nice error messages when we can't | 46 // We require localized names so we can have nice error messages when we can't |
46 // parse an extension manifest. | 47 // parse an extension manifest. |
47 CHECK(!item.localized_name.empty()); | 48 CHECK(!item.localized_name.empty()); |
48 | 49 |
49 std::string error; | 50 std::string error; |
50 return Extension::Create(base::FilePath(), | 51 return Extension::Create(base::FilePath(), |
51 Manifest::INTERNAL, | 52 Manifest::INTERNAL, |
52 *manifest, | 53 *manifest, |
53 Extension::NO_FLAGS, | 54 Extension::NO_FLAGS, |
54 item.id, | 55 item.id, |
55 &error); | 56 &error); |
not at google - send to devlin
2014/08/28 03:17:32
Would this be a better place to manipulate permiss
gpdavis
2014/08/28 17:41:48
I put it below so that we did it just before creat
| |
56 } | 57 } |
57 | 58 |
58 bool IsAppPredicate(scoped_refptr<const Extension> extension) { | 59 bool IsAppPredicate(scoped_refptr<const Extension> extension) { |
59 return extension->is_app(); | 60 return extension->is_app(); |
60 } | 61 } |
61 | 62 |
62 struct MatchIdFunctor { | 63 struct MatchIdFunctor { |
63 explicit MatchIdFunctor(const std::string& id) : id(id) {} | 64 explicit MatchIdFunctor(const std::string& id) : id(id) {} |
64 bool operator()(scoped_refptr<const Extension> extension) { | 65 bool operator()(scoped_refptr<const Extension> extension) { |
65 return extension->id() == id; | 66 return extension->id() == id; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 } | 249 } |
249 | 250 |
250 void BundleInstaller::ShowPrompt() { | 251 void BundleInstaller::ShowPrompt() { |
251 // Abort if we couldn't create any Extensions out of the manifests. | 252 // Abort if we couldn't create any Extensions out of the manifests. |
252 if (dummy_extensions_.empty()) { | 253 if (dummy_extensions_.empty()) { |
253 ReportCanceled(false); | 254 ReportCanceled(false); |
254 return; | 255 return; |
255 } | 256 } |
256 | 257 |
257 scoped_refptr<PermissionSet> permissions; | 258 scoped_refptr<PermissionSet> permissions; |
259 PermissionsUpdater updater(profile_); | |
258 for (size_t i = 0; i < dummy_extensions_.size(); ++i) { | 260 for (size_t i = 0; i < dummy_extensions_.size(); ++i) { |
261 // Initialize permissions so that withheld permissions don't end up in the | |
262 // install prompt. | |
263 updater.InitializePermissions(dummy_extensions_[i]); | |
259 permissions = PermissionSet::CreateUnion( | 264 permissions = PermissionSet::CreateUnion( |
260 permissions.get(), | 265 permissions.get(), |
261 dummy_extensions_[i]->permissions_data()->active_permissions()); | 266 dummy_extensions_[i]->permissions_data()->active_permissions()); |
262 } | 267 } |
263 | 268 |
264 if (g_auto_approve_for_test == PROCEED) { | 269 if (g_auto_approve_for_test == PROCEED) { |
265 InstallUIProceed(); | 270 InstallUIProceed(); |
266 } else if (g_auto_approve_for_test == ABORT) { | 271 } else if (g_auto_approve_for_test == ABORT) { |
267 InstallUIAbort(true); | 272 InstallUIAbort(true); |
268 } else { | 273 } else { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 void BundleInstaller::OnBrowserAdded(Browser* browser) {} | 350 void BundleInstaller::OnBrowserAdded(Browser* browser) {} |
346 | 351 |
347 void BundleInstaller::OnBrowserRemoved(Browser* browser) { | 352 void BundleInstaller::OnBrowserRemoved(Browser* browser) { |
348 if (browser_ == browser) | 353 if (browser_ == browser) |
349 browser_ = NULL; | 354 browser_ = NULL; |
350 } | 355 } |
351 | 356 |
352 void BundleInstaller::OnBrowserSetLastActive(Browser* browser) {} | 357 void BundleInstaller::OnBrowserSetLastActive(Browser* browser) {} |
353 | 358 |
354 } // namespace extensions | 359 } // namespace extensions |
OLD | NEW |