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 */) override { | 325 bool /* is_error_page */, |
| 326 bool /* is_iframe_srcdoc */) override { |
326 title_on_start_ = web_contents()->GetTitle(); | 327 title_on_start_ = web_contents()->GetTitle(); |
327 } | 328 } |
328 | 329 |
329 void DidNavigateMainFrame( | 330 void DidNavigateMainFrame( |
330 const content::LoadCommittedDetails& /* details */, | 331 const content::LoadCommittedDetails& /* details */, |
331 const content::FrameNavigateParams& /* params */) override { | 332 const content::FrameNavigateParams& /* params */) override { |
332 title_on_commit_ = web_contents()->GetTitle(); | 333 title_on_commit_ = web_contents()->GetTitle(); |
333 } | 334 } |
334 | 335 |
335 base::string16 title_on_start_; | 336 base::string16 title_on_start_; |
336 base::string16 title_on_commit_; | 337 base::string16 title_on_commit_; |
337 }; | 338 }; |
338 | 339 |
339 TEST_F(SearchTabHelperTest, TitleIsSetForNTP) { | 340 TEST_F(SearchTabHelperTest, TitleIsSetForNTP) { |
340 TabTitleObserver title_observer(web_contents()); | 341 TabTitleObserver title_observer(web_contents()); |
341 NavigateAndCommit(GURL(chrome::kChromeUINewTabURL)); | 342 NavigateAndCommit(GURL(chrome::kChromeUINewTabURL)); |
342 const base::string16 title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); | 343 const base::string16 title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); |
343 EXPECT_EQ(title, title_observer.title_on_start()); | 344 EXPECT_EQ(title, title_observer.title_on_start()); |
344 EXPECT_EQ(title, title_observer.title_on_commit()); | 345 EXPECT_EQ(title, title_observer.title_on_commit()); |
345 EXPECT_EQ(title, web_contents()->GetTitle()); | 346 EXPECT_EQ(title, web_contents()->GetTitle()); |
346 } | 347 } |
OLD | NEW |