| 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 "chrome/browser/ui/sync/one_click_signin_helper.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 class CurrentHistoryCleaner : public content::WebContentsObserver { | 436 class CurrentHistoryCleaner : public content::WebContentsObserver { |
| 437 public: | 437 public: |
| 438 explicit CurrentHistoryCleaner(content::WebContents* contents); | 438 explicit CurrentHistoryCleaner(content::WebContents* contents); |
| 439 virtual ~CurrentHistoryCleaner(); | 439 virtual ~CurrentHistoryCleaner(); |
| 440 | 440 |
| 441 // content::WebContentsObserver: | 441 // content::WebContentsObserver: |
| 442 virtual void WebContentsDestroyed() OVERRIDE; | 442 virtual void WebContentsDestroyed() OVERRIDE; |
| 443 virtual void DidCommitProvisionalLoadForFrame( | 443 virtual void DidCommitProvisionalLoadForFrame( |
| 444 content::RenderFrameHost* render_frame_host, | 444 content::RenderFrameHost* render_frame_host, |
| 445 const GURL& url, | 445 const GURL& url, |
| 446 bool url_is_unreachable, |
| 446 ui::PageTransition transition_type) OVERRIDE; | 447 ui::PageTransition transition_type) OVERRIDE; |
| 447 | 448 |
| 448 private: | 449 private: |
| 449 scoped_ptr<content::WebContents> contents_; | 450 scoped_ptr<content::WebContents> contents_; |
| 450 int history_index_to_remove_; | 451 int history_index_to_remove_; |
| 451 | 452 |
| 452 DISALLOW_COPY_AND_ASSIGN(CurrentHistoryCleaner); | 453 DISALLOW_COPY_AND_ASSIGN(CurrentHistoryCleaner); |
| 453 }; | 454 }; |
| 454 | 455 |
| 455 CurrentHistoryCleaner::CurrentHistoryCleaner(content::WebContents* contents) | 456 CurrentHistoryCleaner::CurrentHistoryCleaner(content::WebContents* contents) |
| 456 : WebContentsObserver(contents) { | 457 : WebContentsObserver(contents) { |
| 457 history_index_to_remove_ = | 458 history_index_to_remove_ = |
| 458 web_contents()->GetController().GetLastCommittedEntryIndex(); | 459 web_contents()->GetController().GetLastCommittedEntryIndex(); |
| 459 } | 460 } |
| 460 | 461 |
| 461 CurrentHistoryCleaner::~CurrentHistoryCleaner() { | 462 CurrentHistoryCleaner::~CurrentHistoryCleaner() { |
| 462 } | 463 } |
| 463 | 464 |
| 464 void CurrentHistoryCleaner::DidCommitProvisionalLoadForFrame( | 465 void CurrentHistoryCleaner::DidCommitProvisionalLoadForFrame( |
| 465 content::RenderFrameHost* render_frame_host, | 466 content::RenderFrameHost* render_frame_host, |
| 466 const GURL& url, | 467 const GURL& url, |
| 468 bool url_is_unreachable, |
| 467 ui::PageTransition transition_type) { | 469 ui::PageTransition transition_type) { |
| 468 // Return early if this is not top-level navigation. | 470 // Return early if this is not top-level navigation. |
| 469 if (render_frame_host->GetParent()) | 471 if (render_frame_host->GetParent()) |
| 470 return; | 472 return; |
| 471 | 473 |
| 472 content::NavigationController* nc = &web_contents()->GetController(); | 474 content::NavigationController* nc = &web_contents()->GetController(); |
| 473 HistoryService* hs = HistoryServiceFactory::GetForProfile( | 475 HistoryService* hs = HistoryServiceFactory::GetForProfile( |
| 474 Profile::FromBrowserContext(web_contents()->GetBrowserContext()), | 476 Profile::FromBrowserContext(web_contents()->GetBrowserContext()), |
| 475 Profile::IMPLICIT_ACCESS); | 477 Profile::IMPLICIT_ACCESS); |
| 476 | 478 |
| (...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1597 // If the web contents is showing a blank page and not about to be closed, | 1599 // If the web contents is showing a blank page and not about to be closed, |
| 1598 // redirect to the NTP or apps page. | 1600 // redirect to the NTP or apps page. |
| 1599 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && | 1601 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && |
| 1600 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { | 1602 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { |
| 1601 RedirectToNtpOrAppsPage( | 1603 RedirectToNtpOrAppsPage( |
| 1602 web_contents(), | 1604 web_contents(), |
| 1603 signin::GetSourceForPromoURL(original_continue_url_)); | 1605 signin::GetSourceForPromoURL(original_continue_url_)); |
| 1604 } | 1606 } |
| 1605 } | 1607 } |
| 1606 } | 1608 } |
| OLD | NEW |