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

Side by Side Diff: ios/chrome/browser/reading_list/reading_list_distiller_page.mm

Issue 2604773002: Create distiller files for Reading List. (Closed)
Patch Set: Created 3 years, 11 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
gambard 2016/12/27 09:35:59 Update year?
Olivier 2016/12/27 10:08:37 Done.
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 "ios/chrome/browser/reading_list/reading_list_distiller_page.h"
6
7 #include "base/bind.h"
8 #include "base/threading/thread_task_runner_handle.h"
9 #import "ios/web/public/web_state/web_state.h"
10
11 namespace reading_list {
12
13 ReadingListDistillerPage::ReadingListDistillerPage(
14 FaviconWebStateDispatcher* web_state_dispatcher)
15 : dom_distiller::DistillerPageIOS(std::unique_ptr<web::WebState>()),
16 web_state_dispatcher_(web_state_dispatcher),
17 weak_ptr_factory_(this) {}
18
19 ReadingListDistillerPage::~ReadingListDistillerPage() {}
20
21 void ReadingListDistillerPage::DistillPageImpl(const GURL& url,
22 const std::string& script) {
23 std::unique_ptr<web::WebState> new_web_state =
24 web_state_dispatcher_->RequestWebState();
25 std::unique_ptr<web::WebState> old_web_state =
26 ReplaceWebState(std::move(new_web_state));
27 if (old_web_state) {
28 web_state_dispatcher_->ReturnWebState(std::move(old_web_state));
29 }
30 DistillerPageIOS::DistillPageImpl(url, script);
31 }
32
33 void ReadingListDistillerPage::OnDistillationDone(const GURL& page_url,
34 const base::Value* value) {
35 std::unique_ptr<web::WebState> old_web_state =
36 ReplaceWebState(std::unique_ptr<web::WebState>());
37 if (old_web_state) {
38 web_state_dispatcher_->ReturnWebState(std::move(old_web_state));
39 }
40 DistillerPageIOS::OnDistillationDone(page_url, value);
41 }
42
43 void ReadingListDistillerPage::OnLoadURLDone(
44 web::PageLoadCompletionStatus load_completion_status) {
45 if (load_completion_status == web::PageLoadCompletionStatus::FAILURE) {
46 DistillerPageIOS::OnLoadURLDone(load_completion_status);
47 return;
48 }
49 base::WeakPtr<ReadingListDistillerPage> weak_this =
50 weak_ptr_factory_.GetWeakPtr();
51 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
52 FROM_HERE, base::Bind(&ReadingListDistillerPage::DelayedOnLoadURLDone,
gambard 2016/12/27 09:35:59 Is this really necessary? ReadingListDistillerPage
Olivier 2016/12/27 10:08:37 You cannot bind directly DistillerPageIOS::OnLoadU
53 weak_this, load_completion_status),
54 base::TimeDelta::FromSeconds(2));
55 }
56
57 void ReadingListDistillerPage::DelayedOnLoadURLDone(
58 web::PageLoadCompletionStatus load_completion_status) {
59 DistillerPageIOS::OnLoadURLDone(load_completion_status);
60 }
61 }
gambard 2016/12/27 09:35:59 // namespace reading_list
Olivier 2016/12/27 10:08:37 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698