| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/search/search_tab_helper.h" | 5 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 | 276 |
| 277 class TabTitleObserver : public content::WebContentsObserver { | 277 class TabTitleObserver : public content::WebContentsObserver { |
| 278 public: | 278 public: |
| 279 explicit TabTitleObserver(content::WebContents* contents) | 279 explicit TabTitleObserver(content::WebContents* contents) |
| 280 : WebContentsObserver(contents) {} | 280 : WebContentsObserver(contents) {} |
| 281 | 281 |
| 282 base::string16 title_on_start() { return title_on_start_; } | 282 base::string16 title_on_start() { return title_on_start_; } |
| 283 base::string16 title_on_commit() { return title_on_commit_; } | 283 base::string16 title_on_commit() { return title_on_commit_; } |
| 284 | 284 |
| 285 private: | 285 private: |
| 286 void DidStartProvisionalLoadForFrame( | 286 void DidStartNavigation( |
| 287 content::RenderFrameHost* /* render_frame_host */, | 287 content::NavigationHandle* navigation_handle) override { |
| 288 const GURL& /* validated_url */, | |
| 289 bool /* is_error_page */) override { | |
| 290 title_on_start_ = web_contents()->GetTitle(); | 288 title_on_start_ = web_contents()->GetTitle(); |
| 291 } | 289 } |
| 292 | 290 |
| 293 void DidNavigateMainFrame( | 291 void DidFinishNavigation( |
| 294 const content::LoadCommittedDetails& /* details */, | 292 content::NavigationHandle* navigation_handle) override { |
| 295 const content::FrameNavigateParams& /* params */) override { | |
| 296 title_on_commit_ = web_contents()->GetTitle(); | 293 title_on_commit_ = web_contents()->GetTitle(); |
| 297 } | 294 } |
| 298 | 295 |
| 299 base::string16 title_on_start_; | 296 base::string16 title_on_start_; |
| 300 base::string16 title_on_commit_; | 297 base::string16 title_on_commit_; |
| 301 }; | 298 }; |
| 302 | 299 |
| 303 TEST_F(SearchTabHelperTest, TitleIsSetForNTP) { | 300 TEST_F(SearchTabHelperTest, TitleIsSetForNTP) { |
| 304 TabTitleObserver title_observer(web_contents()); | 301 TabTitleObserver title_observer(web_contents()); |
| 305 NavigateAndCommit(GURL(chrome::kChromeUINewTabURL)); | 302 NavigateAndCommit(GURL(chrome::kChromeUINewTabURL)); |
| 306 const base::string16 title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); | 303 const base::string16 title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); |
| 307 EXPECT_EQ(title, title_observer.title_on_start()); | 304 EXPECT_EQ(title, title_observer.title_on_start()); |
| 308 EXPECT_EQ(title, title_observer.title_on_commit()); | 305 EXPECT_EQ(title, title_observer.title_on_commit()); |
| 309 EXPECT_EQ(title, web_contents()->GetTitle()); | 306 EXPECT_EQ(title, web_contents()->GetTitle()); |
| 310 } | 307 } |
| OLD | NEW |