OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <string> |
| 6 |
| 7 #include "chrome/browser/favicon/favicon_service.h" |
| 8 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" |
| 9 #include "chrome/browser/intents/web_intents_registry_factory.h" |
| 10 #include "chrome/browser/intents/web_intents_util.h" |
| 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 14 #include "content/public/browser/web_contents.h" |
| 15 #include "webkit/glue/web_intent_service_data.h" |
| 16 |
| 17 using content::WebContents; |
| 18 |
| 19 // static |
| 20 void Browser::RegisterIntentHandlerHelper(WebContents* tab, |
| 21 const string16& action, |
| 22 const string16& type, |
| 23 const string16& href, |
| 24 const string16& title, |
| 25 const string16& disposition) { |
| 26 if (!web_intents::IsWebIntentsEnabled()) |
| 27 return; |
| 28 |
| 29 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( |
| 30 tab); |
| 31 if (!tcw || tcw->profile()->IsOffTheRecord()) |
| 32 return; |
| 33 |
| 34 FaviconService* favicon_service = |
| 35 tcw->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS); |
| 36 |
| 37 // |href| can be relative to originating URL. Resolve if necessary. |
| 38 GURL service_url(href); |
| 39 if (!service_url.is_valid()) { |
| 40 const GURL& url = tab->GetURL(); |
| 41 service_url = url.Resolve(href); |
| 42 } |
| 43 |
| 44 webkit_glue::WebIntentServiceData service; |
| 45 service.service_url = service_url; |
| 46 service.action = action; |
| 47 service.type = type; |
| 48 service.title = title; |
| 49 service.setDisposition(disposition); |
| 50 |
| 51 RegisterIntentHandlerInfoBarDelegate::MaybeShowIntentInfoBar( |
| 52 tcw->infobar_tab_helper(), |
| 53 WebIntentsRegistryFactory::GetForProfile(tcw->profile()), |
| 54 service, |
| 55 favicon_service, |
| 56 tab->GetURL()); |
| 57 } |
OLD | NEW |