Chromium Code Reviews| 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/webstore_inline_installer.h" | 5 #include "chrome/browser/extensions/webstore_inline_installer.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
| 10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 const char kNotFromVerifiedSitesError[] = | 23 const char kNotFromVerifiedSitesError[] = |
| 24 "Installs can only be initiated by one of the Chrome Web Store item's " | 24 "Installs can only be initiated by one of the Chrome Web Store item's " |
| 25 "verified sites."; | 25 "verified sites."; |
| 26 const char kInlineInstallSupportedError[] = | 26 const char kInlineInstallSupportedError[] = |
| 27 "Inline installation is not supported for this item. The user will be " | 27 "Inline installation is not supported for this item. The user will be " |
| 28 "redirected to the Chrome Web Store."; | 28 "redirected to the Chrome Web Store."; |
| 29 const char kInitiatedFromPopupError[] = | 29 const char kInitiatedFromPopupError[] = |
| 30 "Inline installs can not be initiated from pop-up windows."; | 30 "Inline installs can not be initiated from pop-up windows."; |
| 31 const char kInitiatedFromFullscreenError[] = | 31 const char kInitiatedFromFullscreenError[] = |
| 32 "Inline installs can not be initiated from fullscreen."; | 32 "Inline installs can not be initiated from fullscreen."; |
| 33 const char kInternalError[] = "Unable to complete installation."; | |
| 33 | 34 |
| 34 WebstoreInlineInstaller::WebstoreInlineInstaller( | 35 WebstoreInlineInstaller::WebstoreInlineInstaller( |
| 35 content::WebContents* web_contents, | 36 content::WebContents* web_contents, |
| 36 content::RenderFrameHost* host, | 37 content::RenderFrameHost* host, |
| 37 const std::string& webstore_item_id, | 38 const std::string& webstore_item_id, |
| 38 const GURL& requestor_url, | 39 const GURL& requestor_url, |
| 39 const Callback& callback) | 40 const Callback& callback) |
| 40 : WebstoreStandaloneInstaller( | 41 : WebstoreStandaloneInstaller( |
| 41 webstore_item_id, | 42 webstore_item_id, |
| 42 Profile::FromBrowserContext(web_contents->GetBrowserContext()), | 43 Profile::FromBrowserContext(web_contents->GetBrowserContext()), |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 } | 130 } |
| 130 | 131 |
| 131 WebContents* WebstoreInlineInstaller::GetWebContents() const { | 132 WebContents* WebstoreInlineInstaller::GetWebContents() const { |
| 132 return web_contents(); | 133 return web_contents(); |
| 133 } | 134 } |
| 134 | 135 |
| 135 bool WebstoreInlineInstaller::CheckInlineInstallPermitted( | 136 bool WebstoreInlineInstaller::CheckInlineInstallPermitted( |
| 136 const base::DictionaryValue& webstore_data, | 137 const base::DictionaryValue& webstore_data, |
| 137 std::string* error) const { | 138 std::string* error) const { |
| 138 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); | 139 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); |
| 139 DCHECK(browser); | 140 if (!browser) { |
|
Devlin
2017/01/31 20:18:47
Hmm... interesting. Do you know when this might h
robertshield
2017/02/01 14:21:32
Yes, I believe in this case, web_contents() is not
Devlin
2017/02/06 16:28:41
Hmm, okay. What about merging this logic with Che
robertshield
2017/02/10 15:25:23
That does seem better. Made it so. Apologies for t
| |
| 141 *error = kInternalError; | |
| 142 return false; | |
| 143 } | |
| 140 if (browser->is_type_popup()) { | 144 if (browser->is_type_popup()) { |
| 141 *error = kInitiatedFromPopupError; | 145 *error = kInitiatedFromPopupError; |
| 142 return false; | 146 return false; |
| 143 } | 147 } |
| 144 FullscreenController* controller = | 148 FullscreenController* controller = |
| 145 browser->exclusive_access_manager()->fullscreen_controller(); | 149 browser->exclusive_access_manager()->fullscreen_controller(); |
| 146 if (controller->IsFullscreenForBrowser() || controller->IsTabFullscreen()) { | 150 if (controller->IsFullscreenForBrowser() || controller->IsTabFullscreen()) { |
| 147 *error = kInitiatedFromFullscreenError; | 151 *error = kInitiatedFromFullscreenError; |
| 148 return false; | 152 return false; |
| 149 } | 153 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 DLOG(WARNING) << "Could not parse " << verified_site_pattern_spec << | 249 DLOG(WARNING) << "Could not parse " << verified_site_pattern_spec << |
| 246 " as URL pattern " << parse_result; | 250 " as URL pattern " << parse_result; |
| 247 return false; | 251 return false; |
| 248 } | 252 } |
| 249 verified_site_pattern.SetScheme("*"); | 253 verified_site_pattern.SetScheme("*"); |
| 250 | 254 |
| 251 return verified_site_pattern.MatchesURL(requestor_url); | 255 return verified_site_pattern.MatchesURL(requestor_url); |
| 252 } | 256 } |
| 253 | 257 |
| 254 } // namespace extensions | 258 } // namespace extensions |
| OLD | NEW |