OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/gfx/text_elider.h" | 7 #include "app/gfx/text_elider.h" |
8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
10 #include "base/file_version_info.h" | 10 #include "base/file_version_info.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/dom_ui/dom_ui.h" | 24 #include "chrome/browser/dom_ui/dom_ui.h" |
25 #include "chrome/browser/dom_ui/dom_ui_factory.h" | 25 #include "chrome/browser/dom_ui/dom_ui_factory.h" |
26 #include "chrome/browser/download/download_item_model.h" | 26 #include "chrome/browser/download/download_item_model.h" |
27 #include "chrome/browser/download/download_manager.h" | 27 #include "chrome/browser/download/download_manager.h" |
28 #include "chrome/browser/download/download_request_manager.h" | 28 #include "chrome/browser/download/download_request_manager.h" |
29 #include "chrome/browser/external_protocol_handler.h" | 29 #include "chrome/browser/external_protocol_handler.h" |
30 #include "chrome/browser/extensions/extensions_service.h" | 30 #include "chrome/browser/extensions/extensions_service.h" |
31 #include "chrome/browser/favicon_service.h" | 31 #include "chrome/browser/favicon_service.h" |
32 #include "chrome/browser/form_field_history_manager.h" | 32 #include "chrome/browser/form_field_history_manager.h" |
33 #include "chrome/browser/google_util.h" | 33 #include "chrome/browser/google_util.h" |
| 34 #include "chrome/browser/host_content_settings_map.h" |
34 #include "chrome/browser/hung_renderer_dialog.h" | 35 #include "chrome/browser/hung_renderer_dialog.h" |
35 #include "chrome/browser/jsmessage_box_handler.h" | 36 #include "chrome/browser/jsmessage_box_handler.h" |
36 #include "chrome/browser/load_from_memory_cache_details.h" | 37 #include "chrome/browser/load_from_memory_cache_details.h" |
37 #include "chrome/browser/load_notification_details.h" | 38 #include "chrome/browser/load_notification_details.h" |
38 #include "chrome/browser/metrics/metric_event_duration_details.h" | 39 #include "chrome/browser/metrics/metric_event_duration_details.h" |
39 #include "chrome/browser/modal_html_dialog_delegate.h" | 40 #include "chrome/browser/modal_html_dialog_delegate.h" |
40 #include "chrome/browser/omnibox_search_hint.h" | 41 #include "chrome/browser/omnibox_search_hint.h" |
41 #include "chrome/browser/password_manager/password_manager.h" | 42 #include "chrome/browser/password_manager/password_manager.h" |
42 #include "chrome/browser/plugin_installer.h" | 43 #include "chrome/browser/plugin_installer.h" |
43 #include "chrome/browser/profile.h" | 44 #include "chrome/browser/profile.h" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 NotificationService::AllSources()); | 296 NotificationService::AllSources()); |
296 registrar_.Add(this, NotificationType::BOOKMARK_MODEL_LOADED, | 297 registrar_.Add(this, NotificationType::BOOKMARK_MODEL_LOADED, |
297 NotificationService::AllSources()); | 298 NotificationService::AllSources()); |
298 registrar_.Add(this, NotificationType::RENDER_WIDGET_HOST_DESTROYED, | 299 registrar_.Add(this, NotificationType::RENDER_WIDGET_HOST_DESTROYED, |
299 NotificationService::AllSources()); | 300 NotificationService::AllSources()); |
300 #if defined(OS_LINUX) | 301 #if defined(OS_LINUX) |
301 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, | 302 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, |
302 NotificationService::AllSources()); | 303 NotificationService::AllSources()); |
303 #endif | 304 #endif |
304 | 305 |
| 306 // Register for notifications about content setting changes. |
| 307 registrar_.Add(this, NotificationType::CONTENT_SETTINGS_CHANGED, |
| 308 NotificationService::AllSources()); |
| 309 |
305 // Keep a global copy of the previous search string (if any). | 310 // Keep a global copy of the previous search string (if any). |
306 static string16 global_last_search = string16(); | 311 static string16 global_last_search = string16(); |
307 last_search_prepopulate_text_ = &global_last_search; | 312 last_search_prepopulate_text_ = &global_last_search; |
308 | 313 |
309 // Set-up the showing of the omnibox search infobar if applicable. | 314 // Set-up the showing of the omnibox search infobar if applicable. |
310 if (OmniboxSearchHint::IsEnabled(profile)) | 315 if (OmniboxSearchHint::IsEnabled(profile)) |
311 omnibox_search_hint_.reset(new OmniboxSearchHint(this)); | 316 omnibox_search_hint_.reset(new OmniboxSearchHint(this)); |
312 } | 317 } |
313 | 318 |
314 TabContents::~TabContents() { | 319 TabContents::~TabContents() { |
(...skipping 2396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2711 | 2716 |
2712 #if defined(OS_LINUX) | 2717 #if defined(OS_LINUX) |
2713 case NotificationType::BROWSER_THEME_CHANGED: { | 2718 case NotificationType::BROWSER_THEME_CHANGED: { |
2714 renderer_preferences_util::UpdateFromSystemSettings( | 2719 renderer_preferences_util::UpdateFromSystemSettings( |
2715 &renderer_preferences_, profile()); | 2720 &renderer_preferences_, profile()); |
2716 render_view_host()->SyncRendererPrefs(); | 2721 render_view_host()->SyncRendererPrefs(); |
2717 break; | 2722 break; |
2718 } | 2723 } |
2719 #endif | 2724 #endif |
2720 | 2725 |
| 2726 case NotificationType::CONTENT_SETTINGS_CHANGED: { |
| 2727 Details<HostContentSettingsMap::ContentSettingsDetails> |
| 2728 settings_details(details); |
| 2729 std::string host; |
| 2730 NavigationEntry* entry = controller_.GetActiveEntry(); |
| 2731 if (entry) |
| 2732 host = entry->url().host(); |
| 2733 Source<HostContentSettingsMap> content_settings(source); |
| 2734 if (settings_details.ptr()->host().empty() || |
| 2735 settings_details.ptr()->host() == host) { |
| 2736 render_view_host()->SendContentSettings(host, |
| 2737 content_settings.ptr()->GetContentSettings(host)); |
| 2738 } |
| 2739 break; |
| 2740 } |
| 2741 |
2721 default: | 2742 default: |
2722 NOTREACHED(); | 2743 NOTREACHED(); |
2723 } | 2744 } |
2724 } | 2745 } |
2725 | 2746 |
2726 std::wstring TabContents::GetMessageBoxTitle(const GURL& frame_url, | 2747 std::wstring TabContents::GetMessageBoxTitle(const GURL& frame_url, |
2727 bool is_alert) { | 2748 bool is_alert) { |
2728 if (!frame_url.has_host()) | 2749 if (!frame_url.has_host()) |
2729 return l10n_util::GetString( | 2750 return l10n_util::GetString( |
2730 is_alert ? IDS_JAVASCRIPT_ALERT_DEFAULT_TITLE | 2751 is_alert ? IDS_JAVASCRIPT_ALERT_DEFAULT_TITLE |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2771 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, success, prompt); | 2792 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, success, prompt); |
2772 } | 2793 } |
2773 | 2794 |
2774 void TabContents::SetSuppressMessageBoxes(bool suppress_message_boxes) { | 2795 void TabContents::SetSuppressMessageBoxes(bool suppress_message_boxes) { |
2775 set_suppress_javascript_messages(suppress_message_boxes); | 2796 set_suppress_javascript_messages(suppress_message_boxes); |
2776 } | 2797 } |
2777 | 2798 |
2778 void TabContents::set_encoding(const std::string& encoding) { | 2799 void TabContents::set_encoding(const std::string& encoding) { |
2779 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); | 2800 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); |
2780 } | 2801 } |
OLD | NEW |