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 "content/browser/tab_contents/tab_contents.h" | 5 #include "content/browser/tab_contents/tab_contents.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.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/prefs/pref_service.h" |
| 17 #include "chrome/browser/profiles/profile.h" |
16 #include "content/browser/browser_context.h" | 18 #include "content/browser/browser_context.h" |
17 #include "content/browser/child_process_security_policy.h" | 19 #include "content/browser/child_process_security_policy.h" |
18 #include "content/browser/debugger/devtools_manager.h" | 20 #include "content/browser/debugger/devtools_manager.h" |
19 #include "content/browser/download/download_manager.h" | 21 #include "content/browser/download/download_manager.h" |
20 #include "content/browser/download/download_stats.h" | 22 #include "content/browser/download/download_stats.h" |
21 #include "content/browser/host_zoom_map.h" | 23 #include "content/browser/host_zoom_map.h" |
22 #include "content/browser/in_process_webkit/session_storage_namespace.h" | 24 #include "content/browser/in_process_webkit/session_storage_namespace.h" |
23 #include "content/browser/load_from_memory_cache_details.h" | 25 #include "content/browser/load_from_memory_cache_details.h" |
24 #include "content/browser/load_notification_details.h" | 26 #include "content/browser/load_notification_details.h" |
25 #include "content/browser/renderer_host/render_process_host.h" | 27 #include "content/browser/renderer_host/render_process_host.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 #endif | 197 #endif |
196 is_showing_before_unload_dialog_(false), | 198 is_showing_before_unload_dialog_(false), |
197 opener_web_ui_type_(WebUI::kNoWebUI), | 199 opener_web_ui_type_(WebUI::kNoWebUI), |
198 closed_by_user_gesture_(false), | 200 closed_by_user_gesture_(false), |
199 minimum_zoom_percent_( | 201 minimum_zoom_percent_( |
200 static_cast<int>(WebKit::WebView::minTextSizeMultiplier * 100)), | 202 static_cast<int>(WebKit::WebView::minTextSizeMultiplier * 100)), |
201 maximum_zoom_percent_( | 203 maximum_zoom_percent_( |
202 static_cast<int>(WebKit::WebView::maxTextSizeMultiplier * 100)), | 204 static_cast<int>(WebKit::WebView::maxTextSizeMultiplier * 100)), |
203 temporary_zoom_settings_(false), | 205 temporary_zoom_settings_(false), |
204 content_restrictions_(0), | 206 content_restrictions_(0), |
205 view_type_(content::VIEW_TYPE_TAB_CONTENTS) { | 207 view_type_(content::VIEW_TYPE_TAB_CONTENTS), |
| 208 per_tab_prefs_( |
| 209 Profile::FromBrowserContext(browser_context)-> |
| 210 GetPrefs()->CreatePrefServiceWithPerTabPrefStore()) { |
206 | 211 |
207 render_manager_.Init(browser_context, site_instance, routing_id); | 212 render_manager_.Init(browser_context, site_instance, routing_id); |
208 | 213 |
209 // We have the initial size of the view be based on the size of the passed in | 214 // We have the initial size of the view be based on the size of the passed in |
210 // tab contents (normally a tab from the same window). | 215 // tab contents (normally a tab from the same window). |
211 view_->CreateView(base_tab_contents ? | 216 view_->CreateView(base_tab_contents ? |
212 base_tab_contents->view()->GetContainerSize() : gfx::Size()); | 217 base_tab_contents->view()->GetContainerSize() : gfx::Size()); |
213 | 218 |
214 #if defined(ENABLE_JAVA_BRIDGE) | 219 #if defined(ENABLE_JAVA_BRIDGE) |
215 java_bridge_dispatcher_host_manager_.reset( | 220 java_bridge_dispatcher_host_manager_.reset( |
(...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 GetURL().spec() != chrome::kAboutBlankURL)) && | 1834 GetURL().spec() != chrome::kAboutBlankURL)) && |
1830 !web_prefs.allow_webui_compositing) { | 1835 !web_prefs.allow_webui_compositing) { |
1831 web_prefs.accelerated_compositing_enabled = false; | 1836 web_prefs.accelerated_compositing_enabled = false; |
1832 web_prefs.accelerated_2d_canvas_enabled = false; | 1837 web_prefs.accelerated_2d_canvas_enabled = false; |
1833 } | 1838 } |
1834 | 1839 |
1835 #if defined(TOUCH_UI) | 1840 #if defined(TOUCH_UI) |
1836 web_prefs.force_compositing_mode = true; | 1841 web_prefs.force_compositing_mode = true; |
1837 #endif | 1842 #endif |
1838 | 1843 |
| 1844 // TODO: Apply overrides from per_tab_prefs_ here. |
| 1845 |
1839 return web_prefs; | 1846 return web_prefs; |
1840 } | 1847 } |
1841 | 1848 |
1842 void TabContents::OnUserGesture() { | 1849 void TabContents::OnUserGesture() { |
1843 // Notify observers. | 1850 // Notify observers. |
1844 FOR_EACH_OBSERVER(TabContentsObserver, observers_, DidGetUserGesture()); | 1851 FOR_EACH_OBSERVER(TabContentsObserver, observers_, DidGetUserGesture()); |
1845 | 1852 |
1846 ResourceDispatcherHost* rdh = | 1853 ResourceDispatcherHost* rdh = |
1847 content::GetContentClient()->browser()->GetResourceDispatcherHost(); | 1854 content::GetContentClient()->browser()->GetResourceDispatcherHost(); |
1848 if (rdh) // NULL in unittests. | 1855 if (rdh) // NULL in unittests. |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2015 | 2022 |
2016 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2023 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2017 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 2024 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
2018 rwh_view->SetSize(view()->GetContainerSize()); | 2025 rwh_view->SetSize(view()->GetContainerSize()); |
2019 } | 2026 } |
2020 | 2027 |
2021 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { | 2028 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { |
2022 return render_view_host() ? | 2029 return render_view_host() ? |
2023 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; | 2030 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; |
2024 } | 2031 } |
OLD | NEW |