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

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

Issue 8983012: Get rid of content::NavigationController in cc file and use "using" instead. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 11 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
« no previous file with comments | « content/browser/tab_contents/render_view_host_manager_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // In this case the old RVH has been swapped out but the new one has not 105 // In this case the old RVH has been swapped out but the new one has not
106 // replaced it, yet. Therefore, we cancel the pending RVH and skip the unloading 106 // replaced it, yet. Therefore, we cancel the pending RVH and skip the unloading
107 // of the old RVH. 107 // of the old RVH.
108 108
109 using content::DevToolsAgentHost; 109 using content::DevToolsAgentHost;
110 using content::DevToolsAgentHostRegistry; 110 using content::DevToolsAgentHostRegistry;
111 using content::DevToolsManagerImpl; 111 using content::DevToolsManagerImpl;
112 using content::DownloadItem; 112 using content::DownloadItem;
113 using content::DownloadManager; 113 using content::DownloadManager;
114 using content::GlobalRequestID; 114 using content::GlobalRequestID;
115 using content::NavigationController;
115 using content::NavigationEntry; 116 using content::NavigationEntry;
116 using content::NavigationEntryImpl; 117 using content::NavigationEntryImpl;
117 using content::OpenURLParams; 118 using content::OpenURLParams;
118 using content::SSLStatus; 119 using content::SSLStatus;
119 using content::UserMetricsAction; 120 using content::UserMetricsAction;
120 using content::WebContents; 121 using content::WebContents;
121 using content::WebContentsObserver; 122 using content::WebContentsObserver;
122 123
123 namespace { 124 namespace {
124 125
(...skipping 10 matching lines...) Expand all
135 BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { 136 BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) {
136 // Note: erase is required to properly paint some widgets borders. This can 137 // Note: erase is required to properly paint some widgets borders. This can
137 // be seen with textfields. 138 // be seen with textfields.
138 InvalidateRect(hwnd, NULL, TRUE); 139 InvalidateRect(hwnd, NULL, TRUE);
139 return TRUE; 140 return TRUE;
140 } 141 }
141 #endif 142 #endif
142 143
143 ViewMsg_Navigate_Type::Value GetNavigationType( 144 ViewMsg_Navigate_Type::Value GetNavigationType(
144 content::BrowserContext* browser_context, const NavigationEntryImpl& entry, 145 content::BrowserContext* browser_context, const NavigationEntryImpl& entry,
145 content::NavigationController::ReloadType reload_type) { 146 NavigationController::ReloadType reload_type) {
146 switch (reload_type) { 147 switch (reload_type) {
147 case NavigationControllerImpl::RELOAD: 148 case NavigationControllerImpl::RELOAD:
148 return ViewMsg_Navigate_Type::RELOAD; 149 return ViewMsg_Navigate_Type::RELOAD;
149 case NavigationControllerImpl::RELOAD_IGNORING_CACHE: 150 case NavigationControllerImpl::RELOAD_IGNORING_CACHE:
150 return ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; 151 return ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE;
151 case NavigationControllerImpl::NO_RELOAD: 152 case NavigationControllerImpl::NO_RELOAD:
152 break; // Fall through to rest of function. 153 break; // Fall through to rest of function.
153 } 154 }
154 155
155 if (entry.restore_type() == NavigationEntryImpl::RESTORE_LAST_SESSION && 156 if (entry.restore_type() == NavigationEntryImpl::RESTORE_LAST_SESSION &&
156 browser_context->DidLastSessionExitCleanly()) 157 browser_context->DidLastSessionExitCleanly())
157 return ViewMsg_Navigate_Type::RESTORE; 158 return ViewMsg_Navigate_Type::RESTORE;
158 159
159 return ViewMsg_Navigate_Type::NORMAL; 160 return ViewMsg_Navigate_Type::NORMAL;
160 } 161 }
161 162
162 void MakeNavigateParams(const NavigationEntryImpl& entry, 163 void MakeNavigateParams(const NavigationEntryImpl& entry,
163 const NavigationControllerImpl& controller, 164 const NavigationControllerImpl& controller,
164 content::WebContentsDelegate* delegate, 165 content::WebContentsDelegate* delegate,
165 content::NavigationController::ReloadType reload_type, 166 NavigationController::ReloadType reload_type,
166 ViewMsg_Navigate_Params* params) { 167 ViewMsg_Navigate_Params* params) {
167 params->page_id = entry.GetPageID(); 168 params->page_id = entry.GetPageID();
168 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); 169 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry);
169 params->current_history_list_offset = controller.GetLastCommittedEntryIndex(); 170 params->current_history_list_offset = controller.GetLastCommittedEntryIndex();
170 params->current_history_list_length = controller.GetEntryCount(); 171 params->current_history_list_length = controller.GetEntryCount();
171 params->url = entry.GetURL(); 172 params->url = entry.GetURL();
172 params->referrer = entry.GetReferrer(); 173 params->referrer = entry.GetReferrer();
173 params->transition = entry.GetTransitionType(); 174 params->transition = entry.GetTransitionType();
174 params->state = entry.GetContentState(); 175 params->state = entry.GetContentState();
175 params->navigation_type = 176 params->navigation_type =
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 350
350 return handled; 351 return handled;
351 } 352 }
352 353
353 void TabContents::RunFileChooser( 354 void TabContents::RunFileChooser(
354 RenderViewHost* render_view_host, 355 RenderViewHost* render_view_host,
355 const content::FileChooserParams& params) { 356 const content::FileChooserParams& params) {
356 delegate_->RunFileChooser(this, params); 357 delegate_->RunFileChooser(this, params);
357 } 358 }
358 359
359 content::NavigationController& TabContents::GetController() { 360 NavigationController& TabContents::GetController() {
360 return controller_; 361 return controller_;
361 } 362 }
362 363
363 const content::NavigationController& TabContents::GetController() const { 364 const NavigationController& TabContents::GetController() const {
364 return controller_; 365 return controller_;
365 } 366 }
366 367
367 content::BrowserContext* TabContents::GetBrowserContext() const { 368 content::BrowserContext* TabContents::GetBrowserContext() const {
368 return controller_.GetBrowserContext(); 369 return controller_.GetBrowserContext();
369 } 370 }
370 371
371 void TabContents::SetViewType(content::ViewType type) { 372 void TabContents::SetViewType(content::ViewType type) {
372 view_type_ = type; 373 view_type_ = type;
373 } 374 }
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 777
777 WebContents* new_contents = delegate_->OpenURLFromTab(this, params); 778 WebContents* new_contents = delegate_->OpenURLFromTab(this, params);
778 // Notify observers. 779 // Notify observers.
779 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 780 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
780 DidOpenURL(params.url, params.referrer, 781 DidOpenURL(params.url, params.referrer,
781 params.disposition, params.transition)); 782 params.disposition, params.transition));
782 return new_contents; 783 return new_contents;
783 } 784 }
784 785
785 bool TabContents::NavigateToPendingEntry( 786 bool TabContents::NavigateToPendingEntry(
786 content::NavigationController::ReloadType reload_type) { 787 NavigationController::ReloadType reload_type) {
787 return NavigateToEntry( 788 return NavigateToEntry(
788 *NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry()), 789 *NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry()),
789 reload_type); 790 reload_type);
790 } 791 }
791 792
792 bool TabContents::NavigateToEntry( 793 bool TabContents::NavigateToEntry(
793 const NavigationEntryImpl& entry, 794 const NavigationEntryImpl& entry,
794 content::NavigationController::ReloadType reload_type) { 795 NavigationController::ReloadType reload_type) {
795 // The renderer will reject IPC messages with URLs longer than 796 // The renderer will reject IPC messages with URLs longer than
796 // this limit, so don't attempt to navigate with a longer URL. 797 // this limit, so don't attempt to navigate with a longer URL.
797 if (entry.GetURL().spec().size() > content::kMaxURLChars) 798 if (entry.GetURL().spec().size() > content::kMaxURLChars)
798 return false; 799 return false;
799 800
800 RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry); 801 RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry);
801 if (!dest_render_view_host) 802 if (!dest_render_view_host)
802 return false; // Unable to create the desired render view host. 803 return false; // Unable to create the desired render view host.
803 804
804 // For security, we should never send non-Web-UI URLs to a Web UI renderer. 805 // For security, we should never send non-Web-UI URLs to a Web UI renderer.
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 params.is_main_frame, 1240 params.is_main_frame,
1240 controller_.IsURLInPageNavigation(validated_url), 1241 controller_.IsURLInPageNavigation(validated_url),
1241 validated_url, 1242 validated_url,
1242 std::string(), 1243 std::string(),
1243 false, 1244 false,
1244 params.frame_id); 1245 params.frame_id);
1245 details.set_error_code(params.error_code); 1246 details.set_error_code(params.error_code);
1246 1247
1247 content::NotificationService::current()->Notify( 1248 content::NotificationService::current()->Notify(
1248 content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR, 1249 content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR,
1249 content::Source<content::NavigationController>(&controller_), 1250 content::Source<NavigationController>(&controller_),
1250 content::Details<ProvisionalLoadDetails>(&details)); 1251 content::Details<ProvisionalLoadDetails>(&details));
1251 1252
1252 FOR_EACH_OBSERVER(WebContentsObserver, 1253 FOR_EACH_OBSERVER(WebContentsObserver,
1253 observers_, 1254 observers_,
1254 DidFailProvisionalLoad(params.frame_id, 1255 DidFailProvisionalLoad(params.frame_id,
1255 params.is_main_frame, 1256 params.is_main_frame,
1256 validated_url, 1257 validated_url,
1257 params.error_code, 1258 params.error_code,
1258 params.error_description)); 1259 params.error_description));
1259 } 1260 }
(...skipping 13 matching lines...) Expand all
1273 int connection_status = 0; 1274 int connection_status = 0;
1274 SSLManager::DeserializeSecurityInfo(security_info, 1275 SSLManager::DeserializeSecurityInfo(security_info,
1275 &cert_id, &cert_status, 1276 &cert_id, &cert_status,
1276 &security_bits, 1277 &security_bits,
1277 &connection_status); 1278 &connection_status);
1278 LoadFromMemoryCacheDetails details(url, GetRenderProcessHost()->GetID(), 1279 LoadFromMemoryCacheDetails details(url, GetRenderProcessHost()->GetID(),
1279 cert_id, cert_status); 1280 cert_id, cert_status);
1280 1281
1281 content::NotificationService::current()->Notify( 1282 content::NotificationService::current()->Notify(
1282 content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE, 1283 content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE,
1283 content::Source<content::NavigationController>(&controller_), 1284 content::Source<NavigationController>(&controller_),
1284 content::Details<LoadFromMemoryCacheDetails>(&details)); 1285 content::Details<LoadFromMemoryCacheDetails>(&details));
1285 } 1286 }
1286 1287
1287 void TabContents::OnDidDisplayInsecureContent() { 1288 void TabContents::OnDidDisplayInsecureContent() {
1288 content::RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent")); 1289 content::RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent"));
1289 displayed_insecure_content_ = true; 1290 displayed_insecure_content_ = true;
1290 SSLManager::NotifySSLInternalStateChanged(&GetControllerImpl()); 1291 SSLManager::NotifySSLInternalStateChanged(&GetControllerImpl());
1291 } 1292 }
1292 1293
1293 void TabContents::OnDidRunInsecureContent( 1294 void TabContents::OnDidRunInsecureContent(
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 if (delegate_) 1436 if (delegate_)
1436 delegate_->LoadingStateChanged(this); 1437 delegate_->LoadingStateChanged(this);
1437 NotifyNavigationStateChanged(INVALIDATE_LOAD); 1438 NotifyNavigationStateChanged(INVALIDATE_LOAD);
1438 1439
1439 int type = is_loading ? content::NOTIFICATION_LOAD_START : 1440 int type = is_loading ? content::NOTIFICATION_LOAD_START :
1440 content::NOTIFICATION_LOAD_STOP; 1441 content::NOTIFICATION_LOAD_STOP;
1441 content::NotificationDetails det = content::NotificationService::NoDetails(); 1442 content::NotificationDetails det = content::NotificationService::NoDetails();
1442 if (details) 1443 if (details)
1443 det = content::Details<LoadNotificationDetails>(details); 1444 det = content::Details<LoadNotificationDetails>(details);
1444 content::NotificationService::current()->Notify(type, 1445 content::NotificationService::current()->Notify(type,
1445 content::Source<content::NavigationController>(&controller_), 1446 content::Source<NavigationController>(&controller_),
1446 det); 1447 det);
1447 } 1448 }
1448 1449
1449 void TabContents::DidNavigateMainFramePostCommit( 1450 void TabContents::DidNavigateMainFramePostCommit(
1450 const content::LoadCommittedDetails& details, 1451 const content::LoadCommittedDetails& details,
1451 const ViewHostMsg_FrameNavigate_Params& params) { 1452 const ViewHostMsg_FrameNavigate_Params& params) {
1452 if (opener_web_ui_type_ != WebUI::kNoWebUI) { 1453 if (opener_web_ui_type_ != WebUI::kNoWebUI) {
1453 // If this is a window.open navigation, use the same WebUI as the renderer 1454 // If this is a window.open navigation, use the same WebUI as the renderer
1454 // that opened the window, as long as both renderers have the same 1455 // that opened the window, as long as both renderers have the same
1455 // privileges. 1456 // privileges.
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
2229 encoding_ = content::GetContentClient()->browser()-> 2230 encoding_ = content::GetContentClient()->browser()->
2230 GetCanonicalEncodingNameByAliasName(encoding); 2231 GetCanonicalEncodingNameByAliasName(encoding);
2231 } 2232 }
2232 2233
2233 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { 2234 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) {
2234 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); 2235 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh);
2235 // Can be NULL during tests. 2236 // Can be NULL during tests.
2236 if (rwh_view) 2237 if (rwh_view)
2237 rwh_view->SetSize(GetView()->GetContainerSize()); 2238 rwh_view->SetSize(GetView()->GetContainerSize());
2238 } 2239 }
OLDNEW
« no previous file with comments | « content/browser/tab_contents/render_view_host_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698