1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_AUTOFILL_IOS_BROWSER_AUTOFILL_DRIVER_IOS_WEBFRAME_H_
#define COMPONENTS_AUTOFILL_IOS_BROWSER_AUTOFILL_DRIVER_IOS_WEBFRAME_H_
#include "components/autofill/ios/browser/autofill_driver_ios.h"
#include "ios/web/public/web_state/web_frame_user_data.h"
#include "ios/web/public/web_state/web_state_user_data.h"
namespace web {
class WebFrame;
class WebState;
} // namespace web
namespace autofill {
class AutofillDriverIOSWebFrame;
// This factory will keep the parameters needed to create an
// AutofillDriverIOSWebFrame. These parameters only depend on the web_state, so
// there is one AutofillDriverIOSWebFrameFactory per WebState.
class AutofillDriverIOSWebFrameFactory
: public web::WebStateUserData<AutofillDriverIOSWebFrameFactory> {
public:
// Creates a AutofillDriverIOSWebFrameFactory that will store all the
// needed to create a AutofillDriverIOS.
static void CreateForWebStateAndDelegate(
web::WebState* web_state,
AutofillClient* client,
id<AutofillDriverIOSBridge> bridge,
const std::string& app_locale,
AutofillManager::AutofillDownloadManagerState enable_download_manager);
~AutofillDriverIOSWebFrameFactory() override;
AutofillDriverIOSWebFrameFactory(
web::WebState* web_state,
AutofillClient* client,
id<AutofillDriverIOSBridge> bridge,
const std::string& app_locale,
AutofillManager::AutofillDownloadManagerState enable_download_manager);
// Returns a AutofillDriverIOSFromWebFrame for |web_frame|, creating it if
// needed.
AutofillDriverIOSWebFrame* AutofillDriverIOSFromWebFrame(
web::WebFrame* web_frame);
private:
web::WebState* web_state_ = nullptr;
AutofillClient* client_ = nullptr;
id<AutofillDriverIOSBridge> bridge_ = nil;
std::string app_locale_;
AutofillManager::AutofillDownloadManagerState enable_download_manager_;
};
// AutofillDriverIOSWebFrame will keep a refcountable AutofillDriverIOS. This is
// a workaround crbug.com/892612. On submission, AutofillDownloadManager and
// CreditCardSaveManager expect autofillManager and autofillDriver to live after
// web frame deletion so AutofillAgent will keep the latest submitted
// AutofillDriver alive.
// TODO(crbug.com/892612): remove this workaround once life cycle of autofill
// manager is fixed.
class AutofillDriverIOSRefCountable
: public AutofillDriverIOS,
public base::RefCountedThreadSafe<AutofillDriverIOSRefCountable> {
public:
AutofillDriverIOSRefCountable(
web::WebState* web_state,
web::WebFrame* web_frame,
AutofillClient* client,
id<AutofillDriverIOSBridge> bridge,
const std::string& app_locale,
AutofillManager::AutofillDownloadManagerState enable_download_manager);
private:
friend class base::RefCountedThreadSafe<AutofillDriverIOSRefCountable>;
~AutofillDriverIOSRefCountable() override = default;
};
// TODO(crbug.com/883203): Merge with AutofillDriverIOS class once WebFrame is
// released.
class AutofillDriverIOSWebFrame
: public web::WebFrameUserData<AutofillDriverIOSWebFrame> {
public:
// Creates a AutofillDriverIOSWebFrame for |web_frame|.
static void CreateForWebFrameAndDelegate(
web::WebState* web_state,
web::WebFrame* web_frame,
AutofillClient* client,
id<AutofillDriverIOSBridge> bridge,
const std::string& app_locale,
AutofillManager::AutofillDownloadManagerState enable_download_manager);
~AutofillDriverIOSWebFrame() override;
AutofillDriverIOS* driver() { return driver_.get(); }
scoped_refptr<AutofillDriverIOSRefCountable> GetRetainableDriver();
AutofillDriverIOSWebFrame(
web::WebState* web_state,
web::WebFrame* web_frame,
AutofillClient* client,
id<AutofillDriverIOSBridge> bridge,
const std::string& app_locale,
AutofillManager::AutofillDownloadManagerState enable_download_manager);
scoped_refptr<AutofillDriverIOSRefCountable> driver_;
};
} // namespace autofill
#endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOFILL_DRIVER_IOS_WEBSTATE_H_
|