OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tab_contents/tab_contents.h" | 5 #include "chrome/browser/tab_contents/tab_contents.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/metrics/stats_counters.h" | 11 #include "base/metrics/stats_counters.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "chrome/browser/autocomplete_history_manager.h" | 16 #include "chrome/browser/autocomplete_history_manager.h" |
17 #include "chrome/browser/autofill/autofill_manager.h" | 17 #include "chrome/browser/autofill/autofill_manager.h" |
18 #include "chrome/browser/blocked_content_container.h" | 18 #include "chrome/browser/blocked_content_container.h" |
19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/browser_shutdown.h" | 20 #include "chrome/browser/browser_shutdown.h" |
21 #include "chrome/browser/character_encoding.h" | 21 #include "chrome/browser/character_encoding.h" |
22 #include "chrome/browser/child_process_security_policy.h" | 22 #include "chrome/browser/child_process_security_policy.h" |
23 #include "chrome/browser/content_settings/content_settings_details.h" | 23 #include "chrome/browser/content_settings/content_settings_details.h" |
24 #include "chrome/browser/content_settings/host_content_settings_map.h" | 24 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 25 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 26 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg
ate.h" |
25 #include "chrome/browser/debugger/devtools_manager.h" | 27 #include "chrome/browser/debugger/devtools_manager.h" |
26 #include "chrome/browser/defaults.h" | 28 #include "chrome/browser/defaults.h" |
27 #include "chrome/browser/desktop_notification_handler.h" | 29 #include "chrome/browser/desktop_notification_handler.h" |
28 #include "chrome/browser/dom_operation_notification_details.h" | 30 #include "chrome/browser/dom_operation_notification_details.h" |
29 #include "chrome/browser/dom_ui/dom_ui.h" | 31 #include "chrome/browser/dom_ui/dom_ui.h" |
30 #include "chrome/browser/download/download_item_model.h" | 32 #include "chrome/browser/download/download_item_model.h" |
31 #include "chrome/browser/download/download_manager.h" | 33 #include "chrome/browser/download/download_manager.h" |
32 #include "chrome/browser/download/download_request_limiter.h" | 34 #include "chrome/browser/download/download_request_limiter.h" |
33 #include "chrome/browser/extensions/extension_service.h" | 35 #include "chrome/browser/extensions/extension_service.h" |
34 #include "chrome/browser/external_protocol_handler.h" | 36 #include "chrome/browser/external_protocol_handler.h" |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 OnUpdateContentRestrictions) | 527 OnUpdateContentRestrictions) |
526 IPC_MESSAGE_HANDLER(ViewHostMsg_PDFHasUnsupportedFeature, | 528 IPC_MESSAGE_HANDLER(ViewHostMsg_PDFHasUnsupportedFeature, |
527 OnPDFHasUnsupportedFeature) | 529 OnPDFHasUnsupportedFeature) |
528 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) | 530 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) |
529 IPC_MESSAGE_HANDLER(ViewHostMsg_DidGetApplicationInfo, | 531 IPC_MESSAGE_HANDLER(ViewHostMsg_DidGetApplicationInfo, |
530 OnDidGetApplicationInfo) | 532 OnDidGetApplicationInfo) |
531 IPC_MESSAGE_HANDLER(ViewHostMsg_InstallApplication, | 533 IPC_MESSAGE_HANDLER(ViewHostMsg_InstallApplication, |
532 OnInstallApplication) | 534 OnInstallApplication) |
533 IPC_MESSAGE_HANDLER(ViewHostMsg_PageContents, OnPageContents) | 535 IPC_MESSAGE_HANDLER(ViewHostMsg_PageContents, OnPageContents) |
534 IPC_MESSAGE_HANDLER(ViewHostMsg_PageTranslated, OnPageTranslated) | 536 IPC_MESSAGE_HANDLER(ViewHostMsg_PageTranslated, OnPageTranslated) |
| 537 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterProtocolHandler, |
| 538 OnRegisterProtocolHandler) |
535 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSuggestions, OnSetSuggestions) | 539 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSuggestions, OnSetSuggestions) |
536 IPC_MESSAGE_HANDLER(ViewHostMsg_InstantSupportDetermined, | 540 IPC_MESSAGE_HANDLER(ViewHostMsg_InstantSupportDetermined, |
537 OnInstantSupportDetermined) | 541 OnInstantSupportDetermined) |
538 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) | 542 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) |
539 IPC_MESSAGE_UNHANDLED(handled = false) | 543 IPC_MESSAGE_UNHANDLED(handled = false) |
540 IPC_END_MESSAGE_MAP_EX() | 544 IPC_END_MESSAGE_MAP_EX() |
541 | 545 |
542 if (!message_is_ok) { | 546 if (!message_is_ok) { |
543 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); | 547 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); |
544 GetRenderProcessHost()->ReceivedBadMessage(); | 548 GetRenderProcessHost()->ReceivedBadMessage(); |
(...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2163 TranslateErrors::Type error_type) { | 2167 TranslateErrors::Type error_type) { |
2164 language_state_.set_current_language(translated_lang); | 2168 language_state_.set_current_language(translated_lang); |
2165 language_state_.set_translation_pending(false); | 2169 language_state_.set_translation_pending(false); |
2166 PageTranslatedDetails details(original_lang, translated_lang, error_type); | 2170 PageTranslatedDetails details(original_lang, translated_lang, error_type); |
2167 NotificationService::current()->Notify( | 2171 NotificationService::current()->Notify( |
2168 NotificationType::PAGE_TRANSLATED, | 2172 NotificationType::PAGE_TRANSLATED, |
2169 Source<TabContents>(this), | 2173 Source<TabContents>(this), |
2170 Details<PageTranslatedDetails>(&details)); | 2174 Details<PageTranslatedDetails>(&details)); |
2171 } | 2175 } |
2172 | 2176 |
| 2177 void TabContents::OnRegisterProtocolHandler(const std::string& protocol, |
| 2178 const GURL& url, |
| 2179 const string16& title) { |
| 2180 ProtocolHandlerRegistry* registry = profile()->GetProtocolHandlerRegistry(); |
| 2181 if (!registry->CanSchemeBeOverridden(protocol)) { |
| 2182 return; |
| 2183 } |
| 2184 |
| 2185 ProtocolHandler* handler = ProtocolHandler::CreateProtocolHandler(protocol, |
| 2186 url, title); |
| 2187 if (handler == NULL) { |
| 2188 return; |
| 2189 } |
| 2190 |
| 2191 if (registry->IsAlreadyRegistered(handler)) { |
| 2192 AddInfoBar(new SimpleAlertInfoBarDelegate(this, NULL, |
| 2193 l10n_util::GetStringFUTF16( |
| 2194 IDS_REGISTER_PROTOCOL_HANDLER_ALREADY_REGISTERED, |
| 2195 handler->title(), UTF8ToUTF16(handler->protocol())), true)); |
| 2196 return; |
| 2197 } |
| 2198 |
| 2199 AddInfoBar(new RegisterProtocolHandlerInfoBarDelegate(this, registry, |
| 2200 handler)); |
| 2201 } |
| 2202 |
2173 void TabContents::OnSetSuggestions( | 2203 void TabContents::OnSetSuggestions( |
2174 int32 page_id, | 2204 int32 page_id, |
2175 const std::vector<std::string>& suggestions) { | 2205 const std::vector<std::string>& suggestions) { |
2176 if (delegate()) | 2206 if (delegate()) |
2177 delegate()->OnSetSuggestions(page_id, suggestions); | 2207 delegate()->OnSetSuggestions(page_id, suggestions); |
2178 } | 2208 } |
2179 | 2209 |
2180 void TabContents::OnInstantSupportDetermined(int32 page_id, bool result) { | 2210 void TabContents::OnInstantSupportDetermined(int32 page_id, bool result) { |
2181 if (delegate()) | 2211 if (delegate()) |
2182 delegate()->OnInstantSupportDetermined(page_id, result); | 2212 delegate()->OnInstantSupportDetermined(page_id, result); |
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3128 } | 3158 } |
3129 | 3159 |
3130 bool TabContents::MaybeUsePreloadedPage(const GURL& url) { | 3160 bool TabContents::MaybeUsePreloadedPage(const GURL& url) { |
3131 PrerenderManager* pm = profile()->GetPrerenderManager(); | 3161 PrerenderManager* pm = profile()->GetPrerenderManager(); |
3132 if (pm != NULL) { | 3162 if (pm != NULL) { |
3133 if (pm->MaybeUsePreloadedPage(this, url)) | 3163 if (pm->MaybeUsePreloadedPage(this, url)) |
3134 return true; | 3164 return true; |
3135 } | 3165 } |
3136 return false; | 3166 return false; |
3137 } | 3167 } |
OLD | NEW |