| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/login/ui/web_contents_forced_title.h" |
| 6 |
| 7 #include "content/public/browser/navigation_entry.h" |
| 8 #include "content/public/browser/web_contents.h" |
| 9 |
| 10 DEFINE_WEB_CONTENTS_USER_DATA_KEY(chromeos::WebContentsForcedTitle); |
| 11 |
| 12 namespace chromeos { |
| 13 |
| 14 // static |
| 15 void WebContentsForcedTitle::CreateForWebContentsWithTitle( |
| 16 content::WebContents* web_contents, |
| 17 const base::string16& title) { |
| 18 if (FromWebContents(web_contents)) |
| 19 return; |
| 20 |
| 21 web_contents->UpdateTitleForEntry(nullptr, title); |
| 22 web_contents->SetUserData(UserDataKey(), |
| 23 new WebContentsForcedTitle(web_contents, title)); |
| 24 } |
| 25 |
| 26 WebContentsForcedTitle::WebContentsForcedTitle( |
| 27 content::WebContents* web_contents, |
| 28 const base::string16& title) |
| 29 : content::WebContentsObserver(web_contents), title_(title) {} |
| 30 |
| 31 WebContentsForcedTitle::~WebContentsForcedTitle() {} |
| 32 |
| 33 void WebContentsForcedTitle::TitleWasSet(content::NavigationEntry* entry, |
| 34 bool explicit_set) { |
| 35 if (!entry || entry->GetTitle() != title_) |
| 36 web_contents()->UpdateTitleForEntry(entry, title_); |
| 37 } |
| 38 |
| 39 } // namespace chromeos |
| OLD | NEW |