OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/task_management/providers/web_contents/guest_task.h" | 5 #include "chrome/browser/task_management/providers/web_contents/guest_task.h" |
6 | 6 |
7 #include "components/guest_view/browser/guest_view_base.h" | 7 #include "components/guest_view/browser/guest_view_base.h" |
8 #include "content/public/browser/web_contents.h" | 8 #include "content/public/browser/web_contents.h" |
9 #include "ui/base/l10n/l10n_util.h" | 9 #include "ui/base/l10n/l10n_util.h" |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 return Task::GUEST; | 33 return Task::GUEST; |
34 } | 34 } |
35 | 35 |
36 base::string16 GuestTask::GetCurrentTitle( | 36 base::string16 GuestTask::GetCurrentTitle( |
37 content::WebContents* web_contents) const { | 37 content::WebContents* web_contents) const { |
38 DCHECK(web_contents); | 38 DCHECK(web_contents); |
39 | 39 |
40 guest_view::GuestViewBase* guest = | 40 guest_view::GuestViewBase* guest = |
41 guest_view::GuestViewBase::FromWebContents(web_contents); | 41 guest_view::GuestViewBase::FromWebContents(web_contents); |
42 | 42 |
43 DCHECK(guest); | 43 if (!guest) { |
| 44 // This can happen when an AppWindowContentsImpl is destroyed. It emits a |
| 45 // DidFinishNavigation() events to the WebContentsObservers which triggers a |
| 46 // title update in WebContentsTaskProvider. This happens before |
| 47 // WebContentsDestroyed() is emitted. |
| 48 return title(); |
| 49 } |
44 | 50 |
45 base::string16 title = | 51 base::string16 title = |
46 l10n_util::GetStringFUTF16(guest->GetTaskPrefix(), | 52 l10n_util::GetStringFUTF16(guest->GetTaskPrefix(), |
47 RendererTask::GetTitleFromWebContents( | 53 RendererTask::GetTitleFromWebContents( |
48 web_contents)); | 54 web_contents)); |
49 | 55 |
50 return title; | 56 return title; |
51 } | 57 } |
52 | 58 |
53 } // namespace task_management | 59 } // namespace task_management |
54 | 60 |
OLD | NEW |