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

Side by Side Diff: chrome/browser/instant/instant_loader.cc

Issue 11416187: Commit instant loader when the instant page navigates away from instant URL. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixing issue caused due to removal of TabContents. Created 8 years 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
« no previous file with comments | « chrome/browser/instant/instant_loader.h ('k') | chrome/browser/instant/instant_tab.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/instant/instant_loader.h" 5 #include "chrome/browser/instant/instant_loader.h"
6 6
7 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 7 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
8 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h"
8 #include "chrome/browser/history/history_tab_helper.h" 9 #include "chrome/browser/history/history_tab_helper.h"
9 #include "chrome/browser/instant/instant_controller.h" 10 #include "chrome/browser/instant/instant_controller.h"
10 #include "chrome/browser/safe_browsing/safe_browsing_tab_observer.h" 11 #include "chrome/browser/safe_browsing/safe_browsing_tab_observer.h"
11 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" 12 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
12 #include "chrome/browser/ui/constrained_window_tab_helper.h" 13 #include "chrome/browser/ui/constrained_window_tab_helper.h"
13 #include "chrome/browser/ui/constrained_window_tab_helper_delegate.h" 14 #include "chrome/browser/ui/constrained_window_tab_helper_delegate.h"
14 #include "chrome/browser/ui/search/search_tab_helper.h" 15 #include "chrome/browser/ui/search/search_tab_helper.h"
15 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 16 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
16 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" 17 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h"
17 #include "content/public/browser/notification_source.h" 18 #include "content/public/browser/notification_source.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE; 65 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE;
65 virtual bool CanDownload(content::RenderViewHost* render_view_host, 66 virtual bool CanDownload(content::RenderViewHost* render_view_host,
66 int request_id, 67 int request_id,
67 const std::string& request_method) OVERRIDE; 68 const std::string& request_method) OVERRIDE;
68 virtual void HandleMouseDown() OVERRIDE; 69 virtual void HandleMouseDown() OVERRIDE;
69 virtual void HandleMouseUp() OVERRIDE; 70 virtual void HandleMouseUp() OVERRIDE;
70 virtual void HandlePointerActivate() OVERRIDE; 71 virtual void HandlePointerActivate() OVERRIDE;
71 virtual void HandleGestureEnd() OVERRIDE; 72 virtual void HandleGestureEnd() OVERRIDE;
72 virtual void DragEnded() OVERRIDE; 73 virtual void DragEnded() OVERRIDE;
73 virtual bool OnGoToEntryOffset(int offset) OVERRIDE; 74 virtual bool OnGoToEntryOffset(int offset) OVERRIDE;
75 virtual content::WebContents* OpenURLFromTab(
76 content::WebContents* source,
77 const content::OpenURLParams& params) OVERRIDE;
74 78
75 void MaybeCommitFromPointerRelease(); 79 void MaybeCommitFromPointerRelease();
76 80
77 InstantLoader* const loader_; 81 InstantLoader* const loader_;
78 82
79 DISALLOW_COPY_AND_ASSIGN(WebContentsDelegateImpl); 83 DISALLOW_COPY_AND_ASSIGN(WebContentsDelegateImpl);
80 }; 84 };
81 85
82 InstantLoader::WebContentsDelegateImpl::WebContentsDelegateImpl( 86 InstantLoader::WebContentsDelegateImpl::WebContentsDelegateImpl(
83 InstantLoader* loader) 87 InstantLoader* loader)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // If the user drags, we won't get a mouse up (at least on Linux). Commit the 153 // If the user drags, we won't get a mouse up (at least on Linux). Commit the
150 // Instant result when the drag ends, so that during the drag the page won't 154 // Instant result when the drag ends, so that during the drag the page won't
151 // move around. 155 // move around.
152 MaybeCommitFromPointerRelease(); 156 MaybeCommitFromPointerRelease();
153 } 157 }
154 158
155 bool InstantLoader::WebContentsDelegateImpl::OnGoToEntryOffset(int offset) { 159 bool InstantLoader::WebContentsDelegateImpl::OnGoToEntryOffset(int offset) {
156 return false; 160 return false;
157 } 161 }
158 162
163 content::WebContents* InstantLoader::WebContentsDelegateImpl::OpenURLFromTab(
164 content::WebContents* source,
165 const content::OpenURLParams& params) {
166 content::WebContents* preview = loader_->contents_.get();
167 if (loader_->controller_->CommitIfPossible(INSTANT_COMMIT_NAVIGATED))
168 return preview->GetDelegate()->OpenURLFromTab(source, params);
169 return NULL;
170 }
171
159 void InstantLoader::WebContentsDelegateImpl::MaybeCommitFromPointerRelease() { 172 void InstantLoader::WebContentsDelegateImpl::MaybeCommitFromPointerRelease() {
160 if (loader_->is_pointer_down_from_activate_) { 173 if (loader_->is_pointer_down_from_activate_) {
161 loader_->is_pointer_down_from_activate_ = false; 174 loader_->is_pointer_down_from_activate_ = false;
162 loader_->controller_->CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST); 175 loader_->controller_->CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST);
163 } 176 }
164 } 177 }
165 178
166 // InstantLoader --------------------------------------------------------------- 179 // InstantLoader ---------------------------------------------------------------
167 180
168 // static 181 // static
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 void InstantLoader::StopCapturingKeyStrokes() { 303 void InstantLoader::StopCapturingKeyStrokes() {
291 InstantSupportDetermined(true); 304 InstantSupportDetermined(true);
292 // NOTE(samarth): the current implementation of the key capturing (invisible 305 // NOTE(samarth): the current implementation of the key capturing (invisible
293 // focus) doesn't require doing anything explicitly here. 306 // focus) doesn't require doing anything explicitly here.
294 } 307 }
295 308
296 void InstantLoader::RenderViewGone() { 309 void InstantLoader::RenderViewGone() {
297 controller_->InstantLoaderRenderViewGone(); 310 controller_->InstantLoaderRenderViewGone();
298 } 311 }
299 312
313 void InstantLoader::AboutToNavigateMainFrame(const GURL& url) {
314 controller_->InstantLoaderAboutToNavigateMainFrame(url);
315 }
316
300 void InstantLoader::Observe(int type, 317 void InstantLoader::Observe(int type,
301 const content::NotificationSource& source, 318 const content::NotificationSource& source,
302 const content::NotificationDetails& details) { 319 const content::NotificationDetails& details) {
303 #if defined(OS_MACOSX) 320 #if defined(OS_MACOSX)
304 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) { 321 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) {
305 if (content::RenderWidgetHostView* rwhv = 322 if (content::RenderWidgetHostView* rwhv =
306 contents_->GetRenderWidgetHostView()) 323 contents_->GetRenderWidgetHostView())
307 rwhv->SetTakesFocusOnlyOnMouseDown(true); 324 rwhv->SetTakesFocusOnlyOnMouseDown(true);
308 return; 325 return;
309 } 326 }
(...skipping 23 matching lines...) Expand all
333 set_delegate(delegate_.get()); 350 set_delegate(delegate_.get());
334 351
335 // A tab helper to catch prerender content swapping shenanigans. 352 // A tab helper to catch prerender content swapping shenanigans.
336 CoreTabHelper::CreateForWebContents(contents()); 353 CoreTabHelper::CreateForWebContents(contents());
337 CoreTabHelper::FromWebContents(contents())->set_delegate(delegate_.get()); 354 CoreTabHelper::FromWebContents(contents())->set_delegate(delegate_.get());
338 355
339 // Tab helpers used when committing a preview. 356 // Tab helpers used when committing a preview.
340 chrome::search::SearchTabHelper::CreateForWebContents(contents()); 357 chrome::search::SearchTabHelper::CreateForWebContents(contents());
341 HistoryTabHelper::CreateForWebContents(contents()); 358 HistoryTabHelper::CreateForWebContents(contents());
342 359
360 // Observers.
361 extensions::WebNavigationTabObserver::CreateForWebContents(contents());
362
343 // And some flat-out paranoia. 363 // And some flat-out paranoia.
344 safe_browsing::SafeBrowsingTabObserver::CreateForWebContents(contents()); 364 safe_browsing::SafeBrowsingTabObserver::CreateForWebContents(contents());
345 365
346 #if defined(OS_MACOSX) 366 #if defined(OS_MACOSX)
347 // If |contents_| doesn't yet have a RWHV, SetTakesFocusOnlyOnMouseDown() will 367 // If |contents_| doesn't yet have a RWHV, SetTakesFocusOnlyOnMouseDown() will
348 // be called later, when NOTIFICATION_RENDER_VIEW_HOST_CHANGED is received. 368 // be called later, when NOTIFICATION_RENDER_VIEW_HOST_CHANGED is received.
349 if (content::RenderWidgetHostView* rwhv = 369 if (content::RenderWidgetHostView* rwhv =
350 contents_->GetRenderWidgetHostView()) 370 contents_->GetRenderWidgetHostView())
351 rwhv->SetTakesFocusOnlyOnMouseDown(true); 371 rwhv->SetTakesFocusOnlyOnMouseDown(true);
352 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 372 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 content::WebContents* new_contents) { 406 content::WebContents* new_contents) {
387 DCHECK_EQ(old_contents, contents()); 407 DCHECK_EQ(old_contents, contents());
388 CleanupPreviewContents(); 408 CleanupPreviewContents();
389 // We release here without deleting so that the caller still has the 409 // We release here without deleting so that the caller still has the
390 // responsibility for deleting the WebContents. 410 // responsibility for deleting the WebContents.
391 ignore_result(contents_.release()); 411 ignore_result(contents_.release());
392 contents_.reset(new_contents); 412 contents_.reset(new_contents);
393 SetupPreviewContents(); 413 SetupPreviewContents();
394 controller_->SwappedWebContents(); 414 controller_->SwappedWebContents();
395 } 415 }
OLDNEW
« no previous file with comments | « chrome/browser/instant/instant_loader.h ('k') | chrome/browser/instant/instant_tab.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698