OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/sync/sessions/sync_sessions_router_tab_helper.h" | 5 #include "chrome/browser/sync/sessions/sync_sessions_router_tab_helper.h" |
6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
7 #include "chrome/browser/sessions/session_tab_helper.h" | 8 #include "chrome/browser/sessions/session_tab_helper.h" |
8 #include "chrome/browser/sync/sessions/sync_sessions_web_contents_router.h" | 9 #include "chrome/browser/sync/sessions/sync_sessions_web_contents_router.h" |
9 #include "components/sync_sessions/synced_tab_delegate.h" | 10 #include "components/sync_sessions/synced_tab_delegate.h" |
10 #include "content/public/browser/navigation_entry.h" | 11 #include "content/public/browser/navigation_entry.h" |
11 #include "content/public/browser/navigation_handle.h" | 12 #include "content/public/browser/navigation_handle.h" |
12 #include "content/public/browser/render_frame_host.h" | 13 #include "content/public/browser/render_frame_host.h" |
13 | 14 |
14 DEFINE_WEB_CONTENTS_USER_DATA_KEY(sync_sessions::SyncSessionsRouterTabHelper); | 15 DEFINE_WEB_CONTENTS_USER_DATA_KEY(sync_sessions::SyncSessionsRouterTabHelper); |
15 | 16 |
16 namespace sync_sessions { | 17 namespace sync_sessions { |
17 | 18 |
18 // static | 19 // static |
19 void SyncSessionsRouterTabHelper::CreateForWebContents( | 20 void SyncSessionsRouterTabHelper::CreateForWebContents( |
20 content::WebContents* web_contents, | 21 content::WebContents* web_contents, |
21 SyncSessionsWebContentsRouter* router) { | 22 SyncSessionsWebContentsRouter* router) { |
22 DCHECK(web_contents); | 23 DCHECK(web_contents); |
23 if (!FromWebContents(web_contents)) { | 24 if (!FromWebContents(web_contents)) { |
24 web_contents->SetUserData( | 25 web_contents->SetUserData(UserDataKey(), |
25 UserDataKey(), new SyncSessionsRouterTabHelper(web_contents, router)); | 26 base::WrapUnique(new SyncSessionsRouterTabHelper( |
| 27 web_contents, router))); |
26 } | 28 } |
27 } | 29 } |
28 | 30 |
29 SyncSessionsRouterTabHelper::SyncSessionsRouterTabHelper( | 31 SyncSessionsRouterTabHelper::SyncSessionsRouterTabHelper( |
30 content::WebContents* web_contents, | 32 content::WebContents* web_contents, |
31 SyncSessionsWebContentsRouter* router) | 33 SyncSessionsWebContentsRouter* router) |
32 : content::WebContentsObserver(web_contents), | 34 : content::WebContentsObserver(web_contents), |
33 router_(router), | 35 router_(router), |
34 source_tab_id_(kInvalidTabID) {} | 36 source_tab_id_(kInvalidTabID) {} |
35 | 37 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 75 } |
74 NotifyRouter(); | 76 NotifyRouter(); |
75 } | 77 } |
76 | 78 |
77 void SyncSessionsRouterTabHelper::NotifyRouter(bool page_load_completed) { | 79 void SyncSessionsRouterTabHelper::NotifyRouter(bool page_load_completed) { |
78 if (router_) | 80 if (router_) |
79 router_->NotifyTabModified(web_contents(), page_load_completed); | 81 router_->NotifyTabModified(web_contents(), page_load_completed); |
80 } | 82 } |
81 | 83 |
82 } // namespace sync_sessions | 84 } // namespace sync_sessions |
OLD | NEW |