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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 explicit TabTitleObserver(content::WebContents* contents) | 315 explicit TabTitleObserver(content::WebContents* contents) |
316 : WebContentsObserver(contents) {} | 316 : WebContentsObserver(contents) {} |
317 | 317 |
318 base::string16 title_on_start() { return title_on_start_; } | 318 base::string16 title_on_start() { return title_on_start_; } |
319 base::string16 title_on_commit() { return title_on_commit_; } | 319 base::string16 title_on_commit() { return title_on_commit_; } |
320 | 320 |
321 private: | 321 private: |
322 void DidStartProvisionalLoadForFrame( | 322 void DidStartProvisionalLoadForFrame( |
323 content::RenderFrameHost* /* render_frame_host */, | 323 content::RenderFrameHost* /* render_frame_host */, |
324 const GURL& /* validated_url */, | 324 const GURL& /* validated_url */, |
325 bool /* is_error_page */, | 325 bool /* is_error_page */) override { |
326 bool /* is_iframe_srcdoc */) override { | |
327 title_on_start_ = web_contents()->GetTitle(); | 326 title_on_start_ = web_contents()->GetTitle(); |
328 } | 327 } |
329 | 328 |
330 void DidNavigateMainFrame( | 329 void DidNavigateMainFrame( |
331 const content::LoadCommittedDetails& /* details */, | 330 const content::LoadCommittedDetails& /* details */, |
332 const content::FrameNavigateParams& /* params */) override { | 331 const content::FrameNavigateParams& /* params */) override { |
333 title_on_commit_ = web_contents()->GetTitle(); | 332 title_on_commit_ = web_contents()->GetTitle(); |
334 } | 333 } |
335 | 334 |
336 base::string16 title_on_start_; | 335 base::string16 title_on_start_; |
337 base::string16 title_on_commit_; | 336 base::string16 title_on_commit_; |
338 }; | 337 }; |
339 | 338 |
340 TEST_F(SearchTabHelperTest, TitleIsSetForNTP) { | 339 TEST_F(SearchTabHelperTest, TitleIsSetForNTP) { |
341 TabTitleObserver title_observer(web_contents()); | 340 TabTitleObserver title_observer(web_contents()); |
342 NavigateAndCommit(GURL(chrome::kChromeUINewTabURL)); | 341 NavigateAndCommit(GURL(chrome::kChromeUINewTabURL)); |
343 const base::string16 title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); | 342 const base::string16 title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); |
344 EXPECT_EQ(title, title_observer.title_on_start()); | 343 EXPECT_EQ(title, title_observer.title_on_start()); |
345 EXPECT_EQ(title, title_observer.title_on_commit()); | 344 EXPECT_EQ(title, title_observer.title_on_commit()); |
346 EXPECT_EQ(title, web_contents()->GetTitle()); | 345 EXPECT_EQ(title, web_contents()->GetTitle()); |
347 } | 346 } |
OLD | NEW |