OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
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" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 params->transition = entry.GetTransitionType(); | 220 params->transition = entry.GetTransitionType(); |
221 params->state = entry.GetContentState(); | 221 params->state = entry.GetContentState(); |
222 params->navigation_type = | 222 params->navigation_type = |
223 GetNavigationType(controller.GetBrowserContext(), entry, reload_type); | 223 GetNavigationType(controller.GetBrowserContext(), entry, reload_type); |
224 params->request_time = base::Time::Now(); | 224 params->request_time = base::Time::Now(); |
225 params->extra_headers = entry.extra_headers(); | 225 params->extra_headers = entry.extra_headers(); |
226 params->transferred_request_child_id = | 226 params->transferred_request_child_id = |
227 entry.transferred_global_request_id().child_id; | 227 entry.transferred_global_request_id().child_id; |
228 params->transferred_request_request_id = | 228 params->transferred_request_request_id = |
229 entry.transferred_global_request_id().request_id; | 229 entry.transferred_global_request_id().request_id; |
| 230 params->is_overriding_user_agent = entry.GetIsOverridingUserAgent(); |
230 // Avoid downloading when in view-source mode. | 231 // Avoid downloading when in view-source mode. |
231 params->allow_download = !entry.IsViewSourceMode(); | 232 params->allow_download = !entry.IsViewSourceMode(); |
232 params->embedder_channel_name = embedder_channel_name; | 233 params->embedder_channel_name = embedder_channel_name; |
233 params->embedder_container_id = embedder_container_id; | 234 params->embedder_container_id = embedder_container_id; |
234 | 235 |
235 if (delegate) | 236 if (delegate) |
236 delegate->AddNavigationHeaders(params->url, ¶ms->extra_headers); | 237 delegate->AddNavigationHeaders(params->url, ¶ms->extra_headers); |
237 } | 238 } |
238 | 239 |
239 int GetSwitchValueAsInt( | 240 int GetSwitchValueAsInt( |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 content::WebUI* WebContentsImpl::GetWebUI() const { | 743 content::WebUI* WebContentsImpl::GetWebUI() const { |
743 return render_manager_.web_ui() ? render_manager_.web_ui() | 744 return render_manager_.web_ui() ? render_manager_.web_ui() |
744 : render_manager_.pending_web_ui(); | 745 : render_manager_.pending_web_ui(); |
745 } | 746 } |
746 | 747 |
747 content::WebUI* WebContentsImpl::GetCommittedWebUI() const { | 748 content::WebUI* WebContentsImpl::GetCommittedWebUI() const { |
748 return render_manager_.web_ui(); | 749 return render_manager_.web_ui(); |
749 } | 750 } |
750 | 751 |
751 void WebContentsImpl::SetUserAgentOverride(const std::string& override) { | 752 void WebContentsImpl::SetUserAgentOverride(const std::string& override) { |
752 user_agent_override_ = override; | 753 if (GetUserAgentOverride() == override) |
| 754 return; |
| 755 |
| 756 renderer_preferences_.user_agent_override = override; |
| 757 |
| 758 // Send the new override string to the renderer. |
| 759 RenderViewHost* host = GetRenderViewHost(); |
| 760 if (host) |
| 761 host->SyncRendererPrefs(); |
| 762 |
| 763 // Reload the page if a load is currently in progress to avoid having |
| 764 // different parts of the page loaded using different user agents. |
| 765 NavigationEntry* entry = controller_.GetActiveEntry(); |
| 766 if (is_loading_ && entry != NULL && entry->GetIsOverridingUserAgent()) |
| 767 controller_.ReloadIgnoringCache(true); |
753 } | 768 } |
754 | 769 |
755 const std::string& WebContentsImpl::GetUserAgentOverride() const { | 770 const std::string& WebContentsImpl::GetUserAgentOverride() const { |
756 return user_agent_override_; | 771 return renderer_preferences_.user_agent_override; |
757 } | 772 } |
758 | 773 |
759 const string16& WebContentsImpl::GetTitle() const { | 774 const string16& WebContentsImpl::GetTitle() const { |
760 // Transient entries take precedence. They are used for interstitial pages | 775 // Transient entries take precedence. They are used for interstitial pages |
761 // that are shown on top of existing pages. | 776 // that are shown on top of existing pages. |
762 NavigationEntry* entry = controller_.GetTransientEntry(); | 777 NavigationEntry* entry = controller_.GetTransientEntry(); |
763 std::string accept_languages = | 778 std::string accept_languages = |
764 content::GetContentClient()->browser()->GetAcceptLangs( | 779 content::GetContentClient()->browser()->GetAcceptLangs( |
765 GetBrowserContext()); | 780 GetBrowserContext()); |
766 if (entry) { | 781 if (entry) { |
(...skipping 2324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3091 browser_plugin_host()->embedder_render_process_host(); | 3106 browser_plugin_host()->embedder_render_process_host(); |
3092 *embedder_container_id = browser_plugin_host()->instance_id(); | 3107 *embedder_container_id = browser_plugin_host()->instance_id(); |
3093 int embedder_process_id = | 3108 int embedder_process_id = |
3094 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; | 3109 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; |
3095 if (embedder_process_id != -1) { | 3110 if (embedder_process_id != -1) { |
3096 *embedder_channel_name = | 3111 *embedder_channel_name = |
3097 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), | 3112 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), |
3098 embedder_process_id); | 3113 embedder_process_id); |
3099 } | 3114 } |
3100 } | 3115 } |
OLD | NEW |