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

Side by Side Diff: chrome/browser/android/offline_pages/recent_tab_helper.cc

Issue 2100043004: [Offline pages] Filter out pages cached by different tabs on tab helper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updating comment to address CR Created 4 years, 5 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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/android/offline_pages/recent_tab_helper.h" 5 #include "chrome/browser/android/offline_pages/recent_tab_helper.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" 18 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h"
19 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 19 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
20 #include "chrome/browser/android/tab_android.h" 20 #include "chrome/browser/android/offline_pages/offline_page_utils.h"
21 #include "components/offline_pages/client_namespace_constants.h" 21 #include "components/offline_pages/client_namespace_constants.h"
22 #include "components/offline_pages/offline_page_item.h" 22 #include "components/offline_pages/offline_page_item.h"
23 #include "components/offline_pages/offline_page_model.h" 23 #include "components/offline_pages/offline_page_model.h"
24 #include "content/public/browser/browser_context.h" 24 #include "content/public/browser/browser_context.h"
25 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
26 #include "content/public/browser/navigation_entry.h" 26 #include "content/public/browser/navigation_entry.h"
27 #include "content/public/browser/navigation_handle.h" 27 #include "content/public/browser/navigation_handle.h"
28 28
29 DEFINE_WEB_CONTENTS_USER_DATA_KEY(offline_pages::RecentTabHelper); 29 DEFINE_WEB_CONTENTS_USER_DATA_KEY(offline_pages::RecentTabHelper);
30 30
31 namespace { 31 namespace {
32 class DefaultDelegate: public offline_pages::RecentTabHelper::Delegate { 32 class DefaultDelegate: public offline_pages::RecentTabHelper::Delegate {
33 public: 33 public:
34 DefaultDelegate() {} 34 DefaultDelegate() {}
35 35
36 // offline_pages::RecentTabHelper::Delegate 36 // offline_pages::RecentTabHelper::Delegate
37 std::unique_ptr<offline_pages::OfflinePageArchiver> CreatePageArchiver( 37 std::unique_ptr<offline_pages::OfflinePageArchiver> CreatePageArchiver(
38 content::WebContents* web_contents) override { 38 content::WebContents* web_contents) override {
39 return base::MakeUnique<offline_pages::OfflinePageMHTMLArchiver>( 39 return base::MakeUnique<offline_pages::OfflinePageMHTMLArchiver>(
40 web_contents); 40 web_contents);
41 } 41 }
42 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() override { 42 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() override {
43 return base::ThreadTaskRunnerHandle::Get(); 43 return base::ThreadTaskRunnerHandle::Get();
44 } 44 }
45 bool GetTabId(content::WebContents* web_contents, int* tab_id) override { 45 bool GetTabId(content::WebContents* web_contents, int* tab_id) override {
46 TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents); 46 return offline_pages::OfflinePageUtils::GetTabId(web_contents, tab_id);
47 if (!tab_android)
48 return false;
49 *tab_id = tab_android->GetAndroidId();
50 return true;
51 } 47 }
52 }; 48 };
53 } // namespace 49 } // namespace
54 50
55 namespace offline_pages { 51 namespace offline_pages {
56 52
57 RecentTabHelper::RecentTabHelper(content::WebContents* web_contents) 53 RecentTabHelper::RecentTabHelper(content::WebContents* web_contents)
58 : content::WebContentsObserver(web_contents), 54 : content::WebContentsObserver(web_contents),
59 page_model_(nullptr), 55 page_model_(nullptr),
60 delegate_(new DefaultDelegate()), 56 delegate_(new DefaultDelegate()),
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 bool RecentTabHelper::IsSamePage() const { 181 bool RecentTabHelper::IsSamePage() const {
186 return web_contents() && 182 return web_contents() &&
187 (web_contents()->GetLastCommittedURL() == snapshot_url_); 183 (web_contents()->GetLastCommittedURL() == snapshot_url_);
188 } 184 }
189 185
190 ClientId RecentTabHelper::client_id() const { 186 ClientId RecentTabHelper::client_id() const {
191 return ClientId(kLastNNamespace, tab_id_); 187 return ClientId(kLastNNamespace, tab_id_);
192 } 188 }
193 189
194 } // namespace offline_pages 190 } // namespace offline_pages
OLDNEW
« no previous file with comments | « chrome/browser/android/offline_pages/offline_page_utils.cc ('k') | components/offline_pages/client_policy_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698