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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // Use a mock if one is present. Otherwise, create a real extensions | 42 // Use a mock if one is present. Otherwise, create a real extensions |
43 // install UI. | 43 // install UI. |
44 if (mock_install_prompt_for_testing) { | 44 if (mock_install_prompt_for_testing) { |
45 ExtensionInstallPrompt* result = mock_install_prompt_for_testing; | 45 ExtensionInstallPrompt* result = mock_install_prompt_for_testing; |
46 mock_install_prompt_for_testing = NULL; | 46 mock_install_prompt_for_testing = NULL; |
47 return std::unique_ptr<ExtensionInstallPrompt>(result); | 47 return std::unique_ptr<ExtensionInstallPrompt>(result); |
48 } else { | 48 } else { |
49 content::WebContents* web_contents = download_item.GetWebContents(); | 49 content::WebContents* web_contents = download_item.GetWebContents(); |
50 if (!web_contents) { | 50 if (!web_contents) { |
51 Browser* browser = chrome::FindLastActiveWithProfile(profile); | 51 Browser* browser = chrome::FindLastActiveWithProfile(profile); |
52 if (!browser) | 52 if (!browser) { |
53 browser = | 53 browser = new Browser( |
54 new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile)); | 54 Browser::CreateParams(Browser::TYPE_TABBED, profile, true)); |
| 55 } |
55 web_contents = browser->tab_strip_model()->GetActiveWebContents(); | 56 web_contents = browser->tab_strip_model()->GetActiveWebContents(); |
56 } | 57 } |
57 return std::unique_ptr<ExtensionInstallPrompt>( | 58 return std::unique_ptr<ExtensionInstallPrompt>( |
58 new ExtensionInstallPrompt(web_contents)); | 59 new ExtensionInstallPrompt(web_contents)); |
59 } | 60 } |
60 } | 61 } |
61 | 62 |
62 } // namespace | 63 } // namespace |
63 | 64 |
64 // Tests can call this method to inject a mock ExtensionInstallPrompt | 65 // Tests can call this method to inject a mock ExtensionInstallPrompt |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 ->IsOffstoreInstallAllowed(item.GetURL(), item.GetReferrerUrl()); | 139 ->IsOffstoreInstallAllowed(item.GetURL(), item.GetReferrerUrl()); |
139 } | 140 } |
140 | 141 |
141 std::unique_ptr<base::AutoReset<bool>> OverrideOffstoreInstallAllowedForTesting( | 142 std::unique_ptr<base::AutoReset<bool>> OverrideOffstoreInstallAllowedForTesting( |
142 bool allowed) { | 143 bool allowed) { |
143 return base::MakeUnique<base::AutoReset<bool>>( | 144 return base::MakeUnique<base::AutoReset<bool>>( |
144 &g_allow_offstore_install_for_testing, allowed); | 145 &g_allow_offstore_install_for_testing, allowed); |
145 } | 146 } |
146 | 147 |
147 } // namespace download_crx_util | 148 } // namespace download_crx_util |
OLD | NEW |