| 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 // Download code which handles CRX files (extensions, themes, apps, ...). | 5 // Download code which handles CRX files (extensions, themes, apps, ...). |
| 6 | 6 |
| 7 #include "chrome/browser/download/download_crx_util.h" | 7 #include "chrome/browser/download/download_crx_util.h" |
| 8 | 8 |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/extensions/crx_installer.h" | 10 #include "chrome/browser/extensions/crx_installer.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // Use a mock if one is present. Otherwise, create a real extensions | 41 // Use a mock if one is present. Otherwise, create a real extensions |
| 42 // install UI. | 42 // install UI. |
| 43 if (mock_install_prompt_for_testing) { | 43 if (mock_install_prompt_for_testing) { |
| 44 ExtensionInstallPrompt* result = mock_install_prompt_for_testing; | 44 ExtensionInstallPrompt* result = mock_install_prompt_for_testing; |
| 45 mock_install_prompt_for_testing = NULL; | 45 mock_install_prompt_for_testing = NULL; |
| 46 return scoped_ptr<ExtensionInstallPrompt>(result); | 46 return scoped_ptr<ExtensionInstallPrompt>(result); |
| 47 } else { | 47 } else { |
| 48 content::WebContents* web_contents = download_item.GetWebContents(); | 48 content::WebContents* web_contents = download_item.GetWebContents(); |
| 49 if (!web_contents) { | 49 if (!web_contents) { |
| 50 chrome::HostDesktopType active_desktop = chrome::GetActiveDesktop(); | 50 chrome::HostDesktopType active_desktop = chrome::GetActiveDesktop(); |
| 51 Browser* browser = chrome::FindLastActiveWithProfile(profile, | 51 Browser* browser = chrome::FindLastActiveWithProfile(profile); |
| 52 active_desktop); | |
| 53 if (!browser) | 52 if (!browser) |
| 54 browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, | 53 browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, |
| 55 profile, active_desktop)); | 54 profile, active_desktop)); |
| 56 web_contents = browser->tab_strip_model()->GetActiveWebContents(); | 55 web_contents = browser->tab_strip_model()->GetActiveWebContents(); |
| 57 } | 56 } |
| 58 return scoped_ptr<ExtensionInstallPrompt>( | 57 return scoped_ptr<ExtensionInstallPrompt>( |
| 59 new ExtensionInstallPrompt(web_contents)); | 58 new ExtensionInstallPrompt(web_contents)); |
| 60 } | 59 } |
| 61 } | 60 } |
| 62 | 61 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 131 |
| 133 bool OffStoreInstallAllowedByPrefs(Profile* profile, const DownloadItem& item) { | 132 bool OffStoreInstallAllowedByPrefs(Profile* profile, const DownloadItem& item) { |
| 134 // TODO(aa): RefererURL is cleared in some cases, for example when going | 133 // TODO(aa): RefererURL is cleared in some cases, for example when going |
| 135 // between secure and non-secure URLs. It would be better if DownloadItem | 134 // between secure and non-secure URLs. It would be better if DownloadItem |
| 136 // tracked the initiating page explicitly. | 135 // tracked the initiating page explicitly. |
| 137 return extensions::ExtensionManagementFactory::GetForBrowserContext(profile) | 136 return extensions::ExtensionManagementFactory::GetForBrowserContext(profile) |
| 138 ->IsOffstoreInstallAllowed(item.GetURL(), item.GetReferrerUrl()); | 137 ->IsOffstoreInstallAllowed(item.GetURL(), item.GetReferrerUrl()); |
| 139 } | 138 } |
| 140 | 139 |
| 141 } // namespace download_crx_util | 140 } // namespace download_crx_util |
| OLD | NEW |