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 29 matching lines...) Expand all Loading... |
40 const DownloadItem& download_item) { | 40 const DownloadItem& download_item) { |
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(); | |
51 Browser* browser = chrome::FindLastActiveWithProfile(profile); | 50 Browser* browser = chrome::FindLastActiveWithProfile(profile); |
52 if (!browser) | 51 if (!browser) |
53 browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, | 52 browser = |
54 profile, active_desktop)); | 53 new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile)); |
55 web_contents = browser->tab_strip_model()->GetActiveWebContents(); | 54 web_contents = browser->tab_strip_model()->GetActiveWebContents(); |
56 } | 55 } |
57 return scoped_ptr<ExtensionInstallPrompt>( | 56 return scoped_ptr<ExtensionInstallPrompt>( |
58 new ExtensionInstallPrompt(web_contents)); | 57 new ExtensionInstallPrompt(web_contents)); |
59 } | 58 } |
60 } | 59 } |
61 | 60 |
62 } // namespace | 61 } // namespace |
63 | 62 |
64 // Tests can call this method to inject a mock ExtensionInstallPrompt | 63 // Tests can call this method to inject a mock ExtensionInstallPrompt |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 130 |
132 bool OffStoreInstallAllowedByPrefs(Profile* profile, const DownloadItem& item) { | 131 bool OffStoreInstallAllowedByPrefs(Profile* profile, const DownloadItem& item) { |
133 // TODO(aa): RefererURL is cleared in some cases, for example when going | 132 // TODO(aa): RefererURL is cleared in some cases, for example when going |
134 // between secure and non-secure URLs. It would be better if DownloadItem | 133 // between secure and non-secure URLs. It would be better if DownloadItem |
135 // tracked the initiating page explicitly. | 134 // tracked the initiating page explicitly. |
136 return extensions::ExtensionManagementFactory::GetForBrowserContext(profile) | 135 return extensions::ExtensionManagementFactory::GetForBrowserContext(profile) |
137 ->IsOffstoreInstallAllowed(item.GetURL(), item.GetReferrerUrl()); | 136 ->IsOffstoreInstallAllowed(item.GetURL(), item.GetReferrerUrl()); |
138 } | 137 } |
139 | 138 |
140 } // namespace download_crx_util | 139 } // namespace download_crx_util |
OLD | NEW |