| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   182 #endif |   182 #endif | 
|   183  |   183  | 
|   184 ViewMsg_Navigate_Type::Value GetNavigationType( |   184 ViewMsg_Navigate_Type::Value GetNavigationType( | 
|   185     content::BrowserContext* browser_context, const NavigationEntryImpl& entry, |   185     content::BrowserContext* browser_context, const NavigationEntryImpl& entry, | 
|   186     NavigationController::ReloadType reload_type) { |   186     NavigationController::ReloadType reload_type) { | 
|   187   switch (reload_type) { |   187   switch (reload_type) { | 
|   188     case NavigationControllerImpl::RELOAD: |   188     case NavigationControllerImpl::RELOAD: | 
|   189       return ViewMsg_Navigate_Type::RELOAD; |   189       return ViewMsg_Navigate_Type::RELOAD; | 
|   190     case NavigationControllerImpl::RELOAD_IGNORING_CACHE: |   190     case NavigationControllerImpl::RELOAD_IGNORING_CACHE: | 
|   191       return ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; |   191       return ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; | 
 |   192     case NavigationControllerImpl::RELOAD_ORIGINAL_REQUEST_URL: | 
 |   193       return ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; | 
|   192     case NavigationControllerImpl::NO_RELOAD: |   194     case NavigationControllerImpl::NO_RELOAD: | 
|   193       break;  // Fall through to rest of function. |   195       break;  // Fall through to rest of function. | 
|   194   } |   196   } | 
|   195  |   197  | 
|   196   // |RenderViewImpl::PopulateStateFromPendingNavigationParams| differentiates |   198   // |RenderViewImpl::PopulateStateFromPendingNavigationParams| differentiates | 
|   197   // between |RESTORE_WITH_POST| and |RESTORE|. |   199   // between |RESTORE_WITH_POST| and |RESTORE|. | 
|   198   if (entry.restore_type() == NavigationEntryImpl::RESTORE_LAST_SESSION && |   200   if (entry.restore_type() == NavigationEntryImpl::RESTORE_LAST_SESSION && | 
|   199       browser_context->DidLastSessionExitCleanly()) { |   201       browser_context->DidLastSessionExitCleanly()) { | 
|   200     if (entry.GetHasPostData()) |   202     if (entry.GetHasPostData()) | 
|   201       return ViewMsg_Navigate_Type::RESTORE_WITH_POST; |   203       return ViewMsg_Navigate_Type::RESTORE_WITH_POST; | 
|   202     return ViewMsg_Navigate_Type::RESTORE; |   204     return ViewMsg_Navigate_Type::RESTORE; | 
|   203   } |   205   } | 
|   204  |   206  | 
|   205   return ViewMsg_Navigate_Type::NORMAL; |   207   return ViewMsg_Navigate_Type::NORMAL; | 
|   206 } |   208 } | 
|   207  |   209  | 
|   208 void MakeNavigateParams(const NavigationEntryImpl& entry, |   210 void MakeNavigateParams(const NavigationEntryImpl& entry, | 
|   209                         const NavigationControllerImpl& controller, |   211                         const NavigationControllerImpl& controller, | 
|   210                         content::WebContentsDelegate* delegate, |   212                         content::WebContentsDelegate* delegate, | 
|   211                         NavigationController::ReloadType reload_type, |   213                         NavigationController::ReloadType reload_type, | 
|   212                         const std::string& embedder_channel_name, |   214                         const std::string& embedder_channel_name, | 
|   213                         int embedder_container_id, |   215                         int embedder_container_id, | 
|   214                         ViewMsg_Navigate_Params* params) { |   216                         ViewMsg_Navigate_Params* params) { | 
|   215   params->page_id = entry.GetPageID(); |   217   params->page_id = entry.GetPageID(); | 
|   216   params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); |   218   params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); | 
|   217   params->current_history_list_offset = controller.GetLastCommittedEntryIndex(); |   219   params->current_history_list_offset = controller.GetLastCommittedEntryIndex(); | 
|   218   params->current_history_list_length = controller.GetEntryCount(); |   220   params->current_history_list_length = controller.GetEntryCount(); | 
|   219   params->url = entry.GetURL(); |  | 
|   220   if (!entry.GetBaseURLForDataURL().is_empty()) { |   221   if (!entry.GetBaseURLForDataURL().is_empty()) { | 
|   221     params->base_url_for_data_url = entry.GetBaseURLForDataURL(); |   222     params->base_url_for_data_url = entry.GetBaseURLForDataURL(); | 
|   222     params->history_url_for_data_url = entry.GetVirtualURL(); |   223     params->history_url_for_data_url = entry.GetVirtualURL(); | 
|   223   } |   224   } | 
|   224   params->referrer = entry.GetReferrer(); |   225   params->referrer = entry.GetReferrer(); | 
|   225   params->transition = entry.GetTransitionType(); |   226   params->transition = entry.GetTransitionType(); | 
|   226   params->state = entry.GetContentState(); |   227   params->state = entry.GetContentState(); | 
|   227   params->navigation_type = |   228   params->navigation_type = | 
|   228       GetNavigationType(controller.GetBrowserContext(), entry, reload_type); |   229       GetNavigationType(controller.GetBrowserContext(), entry, reload_type); | 
|   229   params->request_time = base::Time::Now(); |   230   params->request_time = base::Time::Now(); | 
|   230   params->extra_headers = entry.extra_headers(); |   231   params->extra_headers = entry.extra_headers(); | 
|   231   params->transferred_request_child_id = |   232   params->transferred_request_child_id = | 
|   232       entry.transferred_global_request_id().child_id; |   233       entry.transferred_global_request_id().child_id; | 
|   233   params->transferred_request_request_id = |   234   params->transferred_request_request_id = | 
|   234       entry.transferred_global_request_id().request_id; |   235       entry.transferred_global_request_id().request_id; | 
|   235   params->is_overriding_user_agent = entry.GetIsOverridingUserAgent(); |   236   params->is_overriding_user_agent = entry.GetIsOverridingUserAgent(); | 
|   236   // Avoid downloading when in view-source mode. |   237   // Avoid downloading when in view-source mode. | 
|   237   params->allow_download = !entry.IsViewSourceMode(); |   238   params->allow_download = !entry.IsViewSourceMode(); | 
|   238   params->embedder_channel_name = embedder_channel_name; |   239   params->embedder_channel_name = embedder_channel_name; | 
|   239   params->embedder_container_id = embedder_container_id; |   240   params->embedder_container_id = embedder_container_id; | 
|   240   params->is_post = entry.GetHasPostData(); |   241   params->is_post = entry.GetHasPostData(); | 
|   241   if(entry.GetBrowserInitiatedPostData()) { |   242   if(entry.GetBrowserInitiatedPostData()) { | 
|   242       params->browser_initiated_post_data.assign( |   243       params->browser_initiated_post_data.assign( | 
|   243           entry.GetBrowserInitiatedPostData()->front(), |   244           entry.GetBrowserInitiatedPostData()->front(), | 
|   244           entry.GetBrowserInitiatedPostData()->front() + |   245           entry.GetBrowserInitiatedPostData()->front() + | 
|   245               entry.GetBrowserInitiatedPostData()->size()); |   246               entry.GetBrowserInitiatedPostData()->size()); | 
|   246  |   247  | 
|   247   } |   248   } | 
|   248  |   249  | 
 |   250   if (reload_type == NavigationControllerImpl::RELOAD_ORIGINAL_REQUEST_URL && | 
 |   251       entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) { | 
 |   252     // We may have been redirected when navigating to the current URL. | 
 |   253     // Use the URL the user originally intended to visit, if it's valid and if a | 
 |   254     // POST wasn't involved; the latter case avoids issues with sending data to | 
 |   255     // the wrong page. | 
 |   256     params->url = entry.GetOriginalRequestURL(); | 
 |   257   } else { | 
 |   258     params->url = entry.GetURL(); | 
 |   259   } | 
 |   260  | 
|   249   if (delegate) |   261   if (delegate) | 
|   250     delegate->AddNavigationHeaders(params->url, ¶ms->extra_headers); |   262     delegate->AddNavigationHeaders(params->url, ¶ms->extra_headers); | 
|   251 } |   263 } | 
|   252  |   264  | 
|   253 int GetSwitchValueAsInt( |   265 int GetSwitchValueAsInt( | 
|   254     const CommandLine& command_line, |   266     const CommandLine& command_line, | 
|   255     const std::string& switch_string, |   267     const std::string& switch_string, | 
|   256     int min_value) { |   268     int min_value) { | 
|   257   std::string string_value = command_line.GetSwitchValueASCII(switch_string); |   269   std::string string_value = command_line.GetSwitchValueASCII(switch_string); | 
|   258   int int_value; |   270   int int_value; | 
| (...skipping 2883 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  3142       browser_plugin_host()->embedder_render_process_host(); |  3154       browser_plugin_host()->embedder_render_process_host(); | 
|  3143   *embedder_container_id = browser_plugin_host()->instance_id(); |  3155   *embedder_container_id = browser_plugin_host()->instance_id(); | 
|  3144   int embedder_process_id = |  3156   int embedder_process_id = | 
|  3145       embedder_render_process_host ? embedder_render_process_host->GetID() : -1; |  3157       embedder_render_process_host ? embedder_render_process_host->GetID() : -1; | 
|  3146   if (embedder_process_id != -1) { |  3158   if (embedder_process_id != -1) { | 
|  3147     *embedder_channel_name = |  3159     *embedder_channel_name = | 
|  3148         StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), |  3160         StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), | 
|  3149                      embedder_process_id); |  3161                      embedder_process_id); | 
|  3150   } |  3162   } | 
|  3151 } |  3163 } | 
| OLD | NEW |