1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_
6 #define COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "components/dom_distiller/core/distiller_page.h"
13 #include "ios/web/public/web_state/web_state_observer.h"
17 class WebControllerProvider
;
25 namespace dom_distiller
{
27 class DistillerWebStateObserver
;
29 // Loads URLs and injects JavaScript into a page, extracting the distilled page
31 class DistillerPageIOS
: public DistillerPage
{
33 explicit DistillerPageIOS(web::BrowserState
* browser_state
);
34 ~DistillerPageIOS() override
;
37 bool StringifyOutput() override
;
38 bool CreateNewContext() override
;
39 void DistillPageImpl(const GURL
& url
, const std::string
& script
) override
;
42 friend class DistillerWebStateObserver
;
44 // Called by |web_state_observer_| once the page has finished loading.
45 void OnLoadURLDone(web::PageLoadCompletionStatus load_completion_status
);
47 // Called once the |script_| has been evaluated on the page.
48 void HandleJavaScriptResultString(NSString
* result
);
50 web::BrowserState
* browser_state_
;
53 scoped_ptr
<ios::WebControllerProvider
> provider_
;
54 scoped_ptr
<DistillerWebStateObserver
> web_state_observer_
;
55 base::WeakPtrFactory
<DistillerPageIOS
> weak_ptr_factory_
;
58 } // namespace dom_distiller
60 #endif // COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_