| 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 |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 ShowPrompt(); | 254 ShowPrompt(); |
| 255 } | 255 } |
| 256 | 256 |
| 257 void BundleInstaller::ShowPrompt() { | 257 void BundleInstaller::ShowPrompt() { |
| 258 // Abort if we couldn't create any Extensions out of the manifests. | 258 // Abort if we couldn't create any Extensions out of the manifests. |
| 259 if (dummy_extensions_.empty()) { | 259 if (dummy_extensions_.empty()) { |
| 260 approval_callback_.Run(APPROVAL_ERROR); | 260 approval_callback_.Run(APPROVAL_ERROR); |
| 261 return; | 261 return; |
| 262 } | 262 } |
| 263 | 263 |
| 264 scoped_refptr<const PermissionSet> permissions = | 264 scoped_ptr<const PermissionSet> permissions; |
| 265 dummy_extensions_[0]->permissions_data()->active_permissions(); | 265 PermissionSet empty; |
| 266 for (size_t i = 1; i < dummy_extensions_.size(); ++i) { | 266 for (size_t i = 0; i < dummy_extensions_.size(); ++i) { |
| 267 // Using "permissions ? *permissions : PermissionSet()" tries to do a copy, |
| 268 // and doesn't compile. Use a more verbose, but compilable, workaround. |
| 267 permissions = PermissionSet::CreateUnion( | 269 permissions = PermissionSet::CreateUnion( |
| 268 *permissions, | 270 permissions ? *permissions : empty, |
| 269 *dummy_extensions_[i]->permissions_data()->active_permissions()); | 271 *dummy_extensions_[i]->permissions_data()->active_permissions()); |
| 270 } | 272 } |
| 271 | 273 |
| 272 if (g_auto_approve_for_test == PROCEED) { | 274 if (g_auto_approve_for_test == PROCEED) { |
| 273 InstallUIProceed(); | 275 InstallUIProceed(); |
| 274 } else if (g_auto_approve_for_test == ABORT) { | 276 } else if (g_auto_approve_for_test == ABORT) { |
| 275 InstallUIAbort(true); | 277 InstallUIAbort(true); |
| 276 } else { | 278 } else { |
| 277 Browser* browser = browser_; | 279 Browser* browser = browser_; |
| 278 if (!browser) { | 280 if (!browser) { |
| 279 // The browser that we got initially could have gone away during our | 281 // The browser that we got initially could have gone away during our |
| 280 // thread hopping. | 282 // thread hopping. |
| 281 browser = chrome::FindLastActiveWithProfile(profile_, host_desktop_type_); | 283 browser = chrome::FindLastActiveWithProfile(profile_, host_desktop_type_); |
| 282 } | 284 } |
| 283 content::WebContents* web_contents = NULL; | 285 content::WebContents* web_contents = NULL; |
| 284 if (browser) | 286 if (browser) |
| 285 web_contents = browser->tab_strip_model()->GetActiveWebContents(); | 287 web_contents = browser->tab_strip_model()->GetActiveWebContents(); |
| 286 install_ui_.reset(new ExtensionInstallPrompt(web_contents)); | 288 install_ui_.reset(new ExtensionInstallPrompt(web_contents)); |
| 287 if (delegated_username_.empty()) { | 289 if (delegated_username_.empty()) { |
| 288 install_ui_->ConfirmBundleInstall(this, &icon_, permissions.get()); | 290 install_ui_->ConfirmBundleInstall(this, &icon_, permissions.Pass()); |
| 289 } else { | 291 } else { |
| 290 install_ui_->ConfirmPermissionsForDelegatedBundleInstall( | 292 install_ui_->ConfirmPermissionsForDelegatedBundleInstall( |
| 291 this, delegated_username_, &icon_, permissions.get()); | 293 this, delegated_username_, &icon_, permissions.Pass()); |
| 292 } | 294 } |
| 293 } | 295 } |
| 294 } | 296 } |
| 295 | 297 |
| 296 void BundleInstaller::ShowInstalledBubbleIfDone() { | 298 void BundleInstaller::ShowInstalledBubbleIfDone() { |
| 297 // We're ready to show the installed bubble when no items are pending. | 299 // We're ready to show the installed bubble when no items are pending. |
| 298 if (HasItemWithState(Item::STATE_PENDING)) | 300 if (HasItemWithState(Item::STATE_PENDING)) |
| 299 return; | 301 return; |
| 300 | 302 |
| 301 if (browser_) | 303 if (browser_) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 | 361 |
| 360 ShowInstalledBubbleIfDone(); | 362 ShowInstalledBubbleIfDone(); |
| 361 } | 363 } |
| 362 | 364 |
| 363 void BundleInstaller::OnBrowserRemoved(Browser* browser) { | 365 void BundleInstaller::OnBrowserRemoved(Browser* browser) { |
| 364 if (browser_ == browser) | 366 if (browser_ == browser) |
| 365 browser_ = nullptr; | 367 browser_ = nullptr; |
| 366 } | 368 } |
| 367 | 369 |
| 368 } // namespace extensions | 370 } // namespace extensions |
| OLD | NEW |