Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: chrome/browser/tab_contents/tab_contents.cc

Issue 6410115: Adds navigator.registerProtocolHandler. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 std::string& url,
2627 const std::string& title) {
2628 ProtocolHandler* handler = ProtocolHandler::CreateProtocolHandler(protocol, ur l, title);
2629
2630 if (handler == NULL) {
2631 return;
2632 }
2633
2634 AddInfoBar(new RegisterProtocolHandlerInfoBarDelegate(
2635 this, profile()->GetProtocolHandlerRegistry(), handler));
tony 2011/02/07 20:51:45 Have you thought about what happens if an extensio
koz (OOO until 15th September) 2011/02/13 22:33:48 Hm, I hadn't thought of that. I guess if the exten
2636 }
2637
2623 void TabContents::RunJavaScriptMessage( 2638 void TabContents::RunJavaScriptMessage(
2624 const std::wstring& message, 2639 const std::wstring& message,
2625 const std::wstring& default_prompt, 2640 const std::wstring& default_prompt,
2626 const GURL& frame_url, 2641 const GURL& frame_url,
2627 const int flags, 2642 const int flags,
2628 IPC::Message* reply_msg, 2643 IPC::Message* reply_msg,
2629 bool* did_suppress_message) { 2644 bool* did_suppress_message) {
2630 // Suppress javascript messages when requested and when inside a constrained 2645 // Suppress javascript messages when requested and when inside a constrained
2631 // popup window (because that activates them and breaks them out of the 2646 // popup window (because that activates them and breaks them out of the
2632 // constrained window jail). 2647 // constrained window jail).
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
3128 } 3143 }
3129 3144
3130 bool TabContents::MaybeUsePreloadedPage(const GURL& url) { 3145 bool TabContents::MaybeUsePreloadedPage(const GURL& url) {
3131 PrerenderManager* pm = profile()->GetPrerenderManager(); 3146 PrerenderManager* pm = profile()->GetPrerenderManager();
3132 if (pm != NULL) { 3147 if (pm != NULL) {
3133 if (pm->MaybeUsePreloadedPage(this, url)) 3148 if (pm->MaybeUsePreloadedPage(this, url))
3134 return true; 3149 return true;
3135 } 3150 }
3136 return false; 3151 return false;
3137 } 3152 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698