| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #include "chrome/browser/extensions/extension_tab_helper.h" | 57 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 58 #include "chrome/browser/extensions/extension_tabs_module.h" | 58 #include "chrome/browser/extensions/extension_tabs_module.h" |
| 59 #include "chrome/browser/favicon/favicon_tab_helper.h" | 59 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 60 #include "chrome/browser/file_select_helper.h" | 60 #include "chrome/browser/file_select_helper.h" |
| 61 #include "chrome/browser/first_run/first_run.h" | 61 #include "chrome/browser/first_run/first_run.h" |
| 62 #include "chrome/browser/google/google_url_tracker.h" | 62 #include "chrome/browser/google/google_url_tracker.h" |
| 63 #include "chrome/browser/infobars/infobar_tab_helper.h" | 63 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 64 #include "chrome/browser/instant/instant_controller.h" | 64 #include "chrome/browser/instant/instant_controller.h" |
| 65 #include "chrome/browser/instant/instant_unload_handler.h" | 65 #include "chrome/browser/instant/instant_unload_handler.h" |
| 66 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" | 66 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" |
| 67 #include "chrome/browser/intents/web_intents_registry_factory.h" | |
| 68 #include "chrome/browser/intents/web_intents_util.h" | 67 #include "chrome/browser/intents/web_intents_util.h" |
| 69 #include "chrome/browser/net/browser_url_util.h" | 68 #include "chrome/browser/net/browser_url_util.h" |
| 70 #include "chrome/browser/net/url_fixer_upper.h" | 69 #include "chrome/browser/net/url_fixer_upper.h" |
| 71 #include "chrome/browser/notifications/notification_ui_manager.h" | 70 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 72 #include "chrome/browser/platform_util.h" | 71 #include "chrome/browser/platform_util.h" |
| 73 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 72 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 74 #include "chrome/browser/prefs/pref_service.h" | 73 #include "chrome/browser/prefs/pref_service.h" |
| 75 #include "chrome/browser/prerender/prerender_manager.h" | 74 #include "chrome/browser/prerender/prerender_manager.h" |
| 76 #include "chrome/browser/prerender/prerender_manager_factory.h" | 75 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 77 #include "chrome/browser/prerender/prerender_tab_helper.h" | 76 #include "chrome/browser/prerender/prerender_tab_helper.h" |
| (...skipping 2768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2846 break; | 2845 break; |
| 2847 } | 2846 } |
| 2848 } | 2847 } |
| 2849 | 2848 |
| 2850 if (rph_delegate != NULL) | 2849 if (rph_delegate != NULL) |
| 2851 infobar_helper->AddInfoBar(rph_delegate); | 2850 infobar_helper->AddInfoBar(rph_delegate); |
| 2852 } | 2851 } |
| 2853 } | 2852 } |
| 2854 | 2853 |
| 2855 // static | 2854 // static |
| 2856 void Browser::RegisterIntentHandlerHelper(WebContents* tab, | |
| 2857 const string16& action, | |
| 2858 const string16& type, | |
| 2859 const string16& href, | |
| 2860 const string16& title, | |
| 2861 const string16& disposition) { | |
| 2862 if (!web_intents::IsWebIntentsEnabled()) | |
| 2863 return; | |
| 2864 | |
| 2865 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( | |
| 2866 tab); | |
| 2867 if (!tcw || tcw->profile()->IsOffTheRecord()) | |
| 2868 return; | |
| 2869 | |
| 2870 FaviconService* favicon_service = | |
| 2871 tcw->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS); | |
| 2872 | |
| 2873 // |href| can be relative to originating URL. Resolve if necessary. | |
| 2874 GURL service_url(href); | |
| 2875 if (!service_url.is_valid()) { | |
| 2876 const GURL& url = tab->GetURL(); | |
| 2877 service_url = url.Resolve(href); | |
| 2878 } | |
| 2879 | |
| 2880 webkit_glue::WebIntentServiceData service; | |
| 2881 service.service_url = service_url; | |
| 2882 service.action = action; | |
| 2883 service.type = type; | |
| 2884 service.title = title; | |
| 2885 service.setDisposition(disposition); | |
| 2886 | |
| 2887 RegisterIntentHandlerInfoBarDelegate::MaybeShowIntentInfoBar( | |
| 2888 tcw->infobar_tab_helper(), | |
| 2889 WebIntentsRegistryFactory::GetForProfile(tcw->profile()), | |
| 2890 service, | |
| 2891 favicon_service, | |
| 2892 tab->GetURL()); | |
| 2893 } | |
| 2894 | |
| 2895 // static | |
| 2896 void Browser::FindReplyHelper(WebContents* tab, | 2855 void Browser::FindReplyHelper(WebContents* tab, |
| 2897 int request_id, | 2856 int request_id, |
| 2898 int number_of_matches, | 2857 int number_of_matches, |
| 2899 const gfx::Rect& selection_rect, | 2858 const gfx::Rect& selection_rect, |
| 2900 int active_match_ordinal, | 2859 int active_match_ordinal, |
| 2901 bool final_update) { | 2860 bool final_update) { |
| 2902 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( | 2861 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( |
| 2903 tab); | 2862 tab); |
| 2904 if (!tcw || !tcw->find_tab_helper()) | 2863 if (!tcw || !tcw->find_tab_helper()) |
| 2905 return; | 2864 return; |
| (...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4202 const string16& action, | 4161 const string16& action, |
| 4203 const string16& type, | 4162 const string16& type, |
| 4204 const string16& href, | 4163 const string16& href, |
| 4205 const string16& title, | 4164 const string16& title, |
| 4206 const string16& disposition) { | 4165 const string16& disposition) { |
| 4207 RegisterIntentHandlerHelper(tab, action, type, href, title, disposition); | 4166 RegisterIntentHandlerHelper(tab, action, type, href, title, disposition); |
| 4208 } | 4167 } |
| 4209 | 4168 |
| 4210 void Browser::WebIntentDispatch( | 4169 void Browser::WebIntentDispatch( |
| 4211 WebContents* tab, content::WebIntentsDispatcher* intents_dispatcher) { | 4170 WebContents* tab, content::WebIntentsDispatcher* intents_dispatcher) { |
| 4171 #if defined(ENABLE_WEB_INTENTS) |
| 4212 if (!web_intents::IsWebIntentsEnabled()) | 4172 if (!web_intents::IsWebIntentsEnabled()) |
| 4213 return; | 4173 return; |
| 4214 | 4174 |
| 4215 TabContentsWrapper* tcw = | 4175 TabContentsWrapper* tcw = |
| 4216 TabContentsWrapper::GetCurrentWrapperForContents(tab); | 4176 TabContentsWrapper::GetCurrentWrapperForContents(tab); |
| 4217 tcw->web_intent_picker_controller()->SetIntentsDispatcher(intents_dispatcher); | 4177 tcw->web_intent_picker_controller()->SetIntentsDispatcher(intents_dispatcher); |
| 4218 tcw->web_intent_picker_controller()->ShowDialog( | 4178 tcw->web_intent_picker_controller()->ShowDialog( |
| 4219 this, | 4179 this, |
| 4220 intents_dispatcher->GetIntent().action, | 4180 intents_dispatcher->GetIntent().action, |
| 4221 intents_dispatcher->GetIntent().type); | 4181 intents_dispatcher->GetIntent().type); |
| 4182 #endif // defined(ENABLE_WEB_INTENTS) |
| 4222 } | 4183 } |
| 4223 | 4184 |
| 4224 void Browser::FindReply(WebContents* tab, | 4185 void Browser::FindReply(WebContents* tab, |
| 4225 int request_id, | 4186 int request_id, |
| 4226 int number_of_matches, | 4187 int number_of_matches, |
| 4227 const gfx::Rect& selection_rect, | 4188 const gfx::Rect& selection_rect, |
| 4228 int active_match_ordinal, | 4189 int active_match_ordinal, |
| 4229 bool final_update) { | 4190 bool final_update) { |
| 4230 FindReplyHelper(tab, request_id, number_of_matches, selection_rect, | 4191 FindReplyHelper(tab, request_id, number_of_matches, selection_rect, |
| 4231 active_match_ordinal, final_update); | 4192 active_match_ordinal, final_update); |
| (...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5650 } else { | 5611 } else { |
| 5651 LoginUIServiceFactory::GetForProfile( | 5612 LoginUIServiceFactory::GetForProfile( |
| 5652 profile()->GetOriginalProfile())->ShowLoginUI(); | 5613 profile()->GetOriginalProfile())->ShowLoginUI(); |
| 5653 } | 5614 } |
| 5654 #endif | 5615 #endif |
| 5655 } | 5616 } |
| 5656 | 5617 |
| 5657 void Browser::ToggleSpeechInput() { | 5618 void Browser::ToggleSpeechInput() { |
| 5658 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); | 5619 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); |
| 5659 } | 5620 } |
| OLD | NEW |