Chromium Code Reviews| 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 2578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2613 render_manager_.dom_ui()->ProcessDOMUIMessage(params); | 2615 render_manager_.dom_ui()->ProcessDOMUIMessage(params); |
| 2614 } | 2616 } |
| 2615 | 2617 |
| 2616 void TabContents::ProcessExternalHostMessage(const std::string& message, | 2618 void TabContents::ProcessExternalHostMessage(const std::string& message, |
| 2617 const std::string& origin, | 2619 const std::string& origin, |
| 2618 const std::string& target) { | 2620 const std::string& target) { |
| 2619 if (delegate()) | 2621 if (delegate()) |
| 2620 delegate()->ForwardMessageToExternalHost(message, origin, target); | 2622 delegate()->ForwardMessageToExternalHost(message, origin, target); |
| 2621 } | 2623 } |
| 2622 | 2624 |
| 2625 void TabContents::RegisterProtocolHandler(const std::string& protocol, | |
| 2626 const GURL& url, | |
| 2627 const string16& title) { | |
| 2628 ProtocolHandler* handler = ProtocolHandler::CreateProtocolHandler(protocol, ur l, title); | |
| 2629 | |
| 2630 if (handler == NULL) { | |
| 2631 return; | |
| 2632 } | |
| 2633 | |
| 2634 if (profile()->GetProtocolHandlerRegistry()->IsAlreadyRegistered(handler)) { | |
| 2635 return; | |
|
tony
2011/02/14 23:40:07
Nit: 2 space indent. I would probably add a TODO(
koz (OOO until 15th September)
2011/02/15 03:37:27
Actually I've implemented the logic for showing a
| |
| 2636 } | |
| 2637 | |
| 2638 AddInfoBar(new RegisterProtocolHandlerInfoBarDelegate( | |
| 2639 this, profile()->GetProtocolHandlerRegistry(), handler)); | |
| 2640 } | |
| 2641 | |
| 2623 void TabContents::RunJavaScriptMessage( | 2642 void TabContents::RunJavaScriptMessage( |
| 2624 const std::wstring& message, | 2643 const std::wstring& message, |
| 2625 const std::wstring& default_prompt, | 2644 const std::wstring& default_prompt, |
| 2626 const GURL& frame_url, | 2645 const GURL& frame_url, |
| 2627 const int flags, | 2646 const int flags, |
| 2628 IPC::Message* reply_msg, | 2647 IPC::Message* reply_msg, |
| 2629 bool* did_suppress_message) { | 2648 bool* did_suppress_message) { |
| 2630 // Suppress javascript messages when requested and when inside a constrained | 2649 // Suppress javascript messages when requested and when inside a constrained |
| 2631 // popup window (because that activates them and breaks them out of the | 2650 // popup window (because that activates them and breaks them out of the |
| 2632 // constrained window jail). | 2651 // constrained window jail). |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3128 } | 3147 } |
| 3129 | 3148 |
| 3130 bool TabContents::MaybeUsePreloadedPage(const GURL& url) { | 3149 bool TabContents::MaybeUsePreloadedPage(const GURL& url) { |
| 3131 PrerenderManager* pm = profile()->GetPrerenderManager(); | 3150 PrerenderManager* pm = profile()->GetPrerenderManager(); |
| 3132 if (pm != NULL) { | 3151 if (pm != NULL) { |
| 3133 if (pm->MaybeUsePreloadedPage(this, url)) | 3152 if (pm->MaybeUsePreloadedPage(this, url)) |
| 3134 return true; | 3153 return true; |
| 3135 } | 3154 } |
| 3136 return false; | 3155 return false; |
| 3137 } | 3156 } |
| OLD | NEW |