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/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #endif // OS_WIN | 10 #endif // OS_WIN |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 30 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 31 #include "chrome/browser/background/background_contents_service.h" | 31 #include "chrome/browser/background/background_contents_service.h" |
| 32 #include "chrome/browser/background/background_contents_service_factory.h" | 32 #include "chrome/browser/background/background_contents_service_factory.h" |
| 33 #include "chrome/browser/bookmarks/bookmark_model.h" | 33 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 34 #include "chrome/browser/bookmarks/bookmark_utils.h" | 34 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 35 #include "chrome/browser/browser_process.h" | 35 #include "chrome/browser/browser_process.h" |
| 36 #include "chrome/browser/browser_shutdown.h" | 36 #include "chrome/browser/browser_shutdown.h" |
| 37 #include "chrome/browser/character_encoding.h" | 37 #include "chrome/browser/character_encoding.h" |
| 38 #include "chrome/browser/chrome_page_zoom.h" | 38 #include "chrome/browser/chrome_page_zoom.h" |
| 39 #include "chrome/browser/content_settings/host_content_settings_map.h" | 39 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 40 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | |
| 40 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 41 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 41 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg ate.h" | 42 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg ate.h" |
| 42 #include "chrome/browser/debugger/devtools_toggle_action.h" | 43 #include "chrome/browser/debugger/devtools_toggle_action.h" |
| 43 #include "chrome/browser/debugger/devtools_window.h" | 44 #include "chrome/browser/debugger/devtools_window.h" |
| 44 #include "chrome/browser/download/download_crx_util.h" | 45 #include "chrome/browser/download/download_crx_util.h" |
| 45 #include "chrome/browser/download/download_item_model.h" | 46 #include "chrome/browser/download/download_item_model.h" |
| 46 #include "chrome/browser/download/download_service.h" | 47 #include "chrome/browser/download/download_service.h" |
| 47 #include "chrome/browser/download/download_service_factory.h" | 48 #include "chrome/browser/download/download_service_factory.h" |
| 48 #include "chrome/browser/download/download_shelf.h" | 49 #include "chrome/browser/download/download_shelf.h" |
| 49 #include "chrome/browser/download/download_started_animation.h" | 50 #include "chrome/browser/download/download_started_animation.h" |
| (...skipping 2211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2261 NULL, | 2262 NULL, |
| 2262 l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), | 2263 l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), |
| 2263 true)); | 2264 true)); |
| 2264 } | 2265 } |
| 2265 | 2266 |
| 2266 // static | 2267 // static |
| 2267 void Browser::RegisterProtocolHandlerHelper(WebContents* web_contents, | 2268 void Browser::RegisterProtocolHandlerHelper(WebContents* web_contents, |
| 2268 const std::string& protocol, | 2269 const std::string& protocol, |
| 2269 const GURL& url, | 2270 const GURL& url, |
| 2270 const string16& title, | 2271 const string16& title, |
| 2271 bool user_gesture) { | 2272 bool user_gesture, |
| 2273 BrowserWindow* window) { | |
| 2272 TabContents* tab_contents = TabContents::FromWebContents(web_contents); | 2274 TabContents* tab_contents = TabContents::FromWebContents(web_contents); |
| 2273 if (!tab_contents || tab_contents->profile()->IsOffTheRecord()) | 2275 if (!tab_contents || tab_contents->profile()->IsOffTheRecord()) |
| 2274 return; | 2276 return; |
| 2275 | 2277 |
| 2276 ProtocolHandler handler = | 2278 ProtocolHandler handler = |
| 2277 ProtocolHandler::CreateProtocolHandler(protocol, url, title); | 2279 ProtocolHandler::CreateProtocolHandler(protocol, url, title); |
| 2278 | 2280 |
| 2279 ProtocolHandlerRegistry* registry = | 2281 ProtocolHandlerRegistry* registry = |
| 2280 tab_contents->profile()->GetProtocolHandlerRegistry(); | 2282 tab_contents->profile()->GetProtocolHandlerRegistry(); |
| 2283 TabSpecificContentSettings* content_settings = | |
| 2284 tab_contents->content_settings(); | |
| 2285 | |
| 2286 if (!user_gesture && window) { | |
| 2287 content_settings->SetRegisterProtocolHandlerCalledUngestured(handler); | |
| 2288 ProtocolHandler old_handler = registry->GetHandlerFor(handler.protocol()); | |
| 2289 if (!old_handler.IsEmpty()) | |
| 2290 content_settings->SetOldRegisterProtocolHandlerTitle(old_handler.title()); | |
| 2291 window->GetLocationBar()->UpdateContentSettingsIcons(); | |
| 2292 return; | |
| 2293 } | |
| 2294 | |
| 2295 // Make sure content-settings are turned off in case the page does ungestured | |
| 2296 // and gestured RPH calls. | |
| 2297 content_settings->SetRegisterProtocolHandlerCalledUngestured( | |
|
koz (OOO until 15th September)
2012/06/21 01:50:53
Could change to
content_settings->ClearPendingReg
Greg Billock
2012/06/21 19:59:11
You think the extra method is worth it?
koz (OOO until 15th September)
2012/06/21 23:03:50
Yeah, I don't think it's a big cost, up to you tho
Greg Billock
2012/06/21 23:10:59
Ok. Adding.
On 2012/06/21 23:03:50, koz wrote:
| |
| 2298 ProtocolHandler::EmptyProtocolHandler()); | |
| 2299 window->GetLocationBar()->UpdateContentSettingsIcons(); | |
| 2281 | 2300 |
| 2282 if (!registry->SilentlyHandleRegisterHandlerRequest(handler)) { | 2301 if (!registry->SilentlyHandleRegisterHandlerRequest(handler)) { |
| 2283 content::RecordAction( | 2302 content::RecordAction( |
| 2284 UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown")); | 2303 UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown")); |
| 2285 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); | 2304 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); |
| 2286 | 2305 |
| 2287 RegisterProtocolHandlerInfoBarDelegate* rph_delegate = | 2306 RegisterProtocolHandlerInfoBarDelegate* rph_delegate = |
| 2288 new RegisterProtocolHandlerInfoBarDelegate(infobar_helper, | 2307 new RegisterProtocolHandlerInfoBarDelegate(infobar_helper, |
| 2289 registry, | 2308 registry, |
| 2290 handler); | 2309 handler); |
| (...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3631 void Browser::JSOutOfMemory(WebContents* web_contents) { | 3650 void Browser::JSOutOfMemory(WebContents* web_contents) { |
| 3632 JSOutOfMemoryHelper(web_contents); | 3651 JSOutOfMemoryHelper(web_contents); |
| 3633 } | 3652 } |
| 3634 | 3653 |
| 3635 void Browser::RegisterProtocolHandler(WebContents* web_contents, | 3654 void Browser::RegisterProtocolHandler(WebContents* web_contents, |
| 3636 const std::string& protocol, | 3655 const std::string& protocol, |
| 3637 const GURL& url, | 3656 const GURL& url, |
| 3638 const string16& title, | 3657 const string16& title, |
| 3639 bool user_gesture) { | 3658 bool user_gesture) { |
| 3640 RegisterProtocolHandlerHelper( | 3659 RegisterProtocolHandlerHelper( |
| 3641 web_contents, protocol, url, title, user_gesture); | 3660 web_contents, protocol, url, title, user_gesture, window()); |
| 3642 } | 3661 } |
| 3643 | 3662 |
| 3644 void Browser::RegisterIntentHandler( | 3663 void Browser::RegisterIntentHandler( |
| 3645 WebContents* web_contents, | 3664 WebContents* web_contents, |
| 3646 const webkit_glue::WebIntentServiceData& data, | 3665 const webkit_glue::WebIntentServiceData& data, |
| 3647 bool user_gesture) { | 3666 bool user_gesture) { |
| 3648 RegisterIntentHandlerHelper(web_contents, data, user_gesture); | 3667 RegisterIntentHandlerHelper(web_contents, data, user_gesture); |
| 3649 } | 3668 } |
| 3650 | 3669 |
| 3651 void Browser::WebIntentDispatch( | 3670 void Browser::WebIntentDispatch( |
| (...skipping 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5230 if (contents && !allow_js_access) { | 5249 if (contents && !allow_js_access) { |
| 5231 contents->web_contents()->GetController().LoadURL( | 5250 contents->web_contents()->GetController().LoadURL( |
| 5232 target_url, | 5251 target_url, |
| 5233 content::Referrer(), | 5252 content::Referrer(), |
| 5234 content::PAGE_TRANSITION_LINK, | 5253 content::PAGE_TRANSITION_LINK, |
| 5235 std::string()); // No extra headers. | 5254 std::string()); // No extra headers. |
| 5236 } | 5255 } |
| 5237 | 5256 |
| 5238 return contents != NULL; | 5257 return contents != NULL; |
| 5239 } | 5258 } |
| OLD | NEW |