Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1926)

Unified Diff: chrome/browser/chromeos/login/ui/web_contents_forced_title.cc

Issue 2550263002: cros: Ensure task manager shows correct title for lock screen webview (Closed)
Patch Set: Rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/ui/web_contents_forced_title.cc
diff --git a/chrome/browser/chromeos/login/ui/web_contents_forced_title.cc b/chrome/browser/chromeos/login/ui/web_contents_forced_title.cc
new file mode 100644
index 0000000000000000000000000000000000000000..51dbef23ced0f28d1a4bcf1fb3b137c56eacc433
--- /dev/null
+++ b/chrome/browser/chromeos/login/ui/web_contents_forced_title.cc
@@ -0,0 +1,39 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/login/ui/web_contents_forced_title.h"
+
+#include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/web_contents.h"
+
+DEFINE_WEB_CONTENTS_USER_DATA_KEY(chromeos::WebContentsForcedTitle);
+
+namespace chromeos {
+
+// static
+void WebContentsForcedTitle::CreateForWebContentsWithTitle(
+ content::WebContents* web_contents,
+ const base::string16& title) {
+ if (FromWebContents(web_contents))
+ return;
+
+ web_contents->UpdateTitleForEntry(nullptr, title);
+ web_contents->SetUserData(UserDataKey(),
+ new WebContentsForcedTitle(web_contents, title));
+}
+
+WebContentsForcedTitle::WebContentsForcedTitle(
+ content::WebContents* web_contents,
+ const base::string16& title)
+ : content::WebContentsObserver(web_contents), title_(title) {}
+
+WebContentsForcedTitle::~WebContentsForcedTitle() {}
+
+void WebContentsForcedTitle::TitleWasSet(content::NavigationEntry* entry,
+ bool explicit_set) {
+ if (!entry || entry->GetTitle() != title_)
+ web_contents()->UpdateTitleForEntry(entry, title_);
+}
+
+} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/login/ui/web_contents_forced_title.h ('k') | chrome/browser/chromeos/login/ui/webui_login_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698