| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_BRIDGE_H_ |
| 6 #define CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_BRIDGE_H_ | 6 #define CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_BRIDGE_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 class ExternalDataUseObserver; | 32 class ExternalDataUseObserver; |
| 33 | 33 |
| 34 // ExternalDataUseObserverBridge creates and owns a Java listener object | 34 // ExternalDataUseObserverBridge creates and owns a Java listener object |
| 35 // that is notified of the data usage observations of Chromium. This class | 35 // that is notified of the data usage observations of Chromium. This class |
| 36 // receives regular expressions from the Java listener object. Objects of this | 36 // receives regular expressions from the Java listener object. Objects of this |
| 37 // class may may be constructed on any thread safe but are immediately moved to | 37 // class may may be constructed on any thread safe but are immediately moved to |
| 38 // the UI thread, and afterwards are accessible only on the UI thread. | 38 // the UI thread, and afterwards are accessible only on the UI thread. |
| 39 class ExternalDataUseObserverBridge { | 39 class ExternalDataUseObserverBridge { |
| 40 public: | 40 public: |
| 41 ExternalDataUseObserverBridge(); | 41 ExternalDataUseObserverBridge(); |
| 42 ~ExternalDataUseObserverBridge(); | 42 virtual ~ExternalDataUseObserverBridge(); |
| 43 | 43 |
| 44 // Initializes |this| on UI thread by constructing the | 44 // Initializes |this| on UI thread by constructing the |
| 45 // |j_external_data_use_observer_|, and fetches matching rules from | 45 // |j_external_data_use_observer_|, and fetches matching rules from |
| 46 // |j_external_data_use_observer_|. | 46 // |j_external_data_use_observer_|. |
| 47 void Init(scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 47 void Init(scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
| 48 base::WeakPtr<ExternalDataUseObserver> external_data_use_observer, | 48 base::WeakPtr<ExternalDataUseObserver> external_data_use_observer, |
| 49 DataUseTabModel* data_use_tab_model); | 49 DataUseTabModel* data_use_tab_model); |
| 50 | 50 |
| 51 // Fetches matching rules from Java. Returns result asynchronously via | 51 // Fetches matching rules from Java. Returns result asynchronously via |
| 52 // FetchMatchingRulesDone. FetchMatchingRules should not be called if a | 52 // FetchMatchingRulesDone. FetchMatchingRules should not be called if a |
| 53 // fetch to matching rules is already in progress. | 53 // fetch to matching rules is already in progress. |
| 54 void FetchMatchingRules() const; | 54 virtual void FetchMatchingRules() const; |
| 55 | 55 |
| 56 // Called by Java when new matching rules have been fetched. | 56 // Called by Java when new matching rules have been fetched. |
| 57 // |app_package_name| is the package name of the app that should be matched. | 57 // |app_package_name| is the package name of the app that should be matched. |
| 58 // |domain_path_regex| is the regex to be used for matching URLs. |label| is | 58 // |domain_path_regex| is the regex to be used for matching URLs. |label| is |
| 59 // the label that must be applied to data reports corresponding to the | 59 // the label that must be applied to data reports corresponding to the |
| 60 // matching rule, and must uniquely identify the matching rule. Each element | 60 // matching rule, and must uniquely identify the matching rule. Each element |
| 61 // in |label| must have non-zero length. The three vectors should have equal | 61 // in |label| must have non-zero length. The three vectors should have equal |
| 62 // length. The vectors may be empty which implies that no matching rules are | 62 // length. The vectors may be empty which implies that no matching rules are |
| 63 // active. | 63 // active. |
| 64 void FetchMatchingRulesDone( | 64 void FetchMatchingRulesDone( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 86 const base::android::JavaParamRef<jobject>& obj, | 86 const base::android::JavaParamRef<jobject>& obj, |
| 87 bool success); | 87 bool success); |
| 88 | 88 |
| 89 // Notifies the ExternalDataUseObserverBridge that the external control app is | 89 // Notifies the ExternalDataUseObserverBridge that the external control app is |
| 90 // installed or uninstalled. |is_control_app_installed| is true if app is | 90 // installed or uninstalled. |is_control_app_installed| is true if app is |
| 91 // installed. | 91 // installed. |
| 92 void OnControlAppInstallStateChange(JNIEnv* env, | 92 void OnControlAppInstallStateChange(JNIEnv* env, |
| 93 jobject obj, | 93 jobject obj, |
| 94 bool is_control_app_installed) const; | 94 bool is_control_app_installed) const; |
| 95 | 95 |
| 96 // Called by DataUseMatcher to notify |external_data_use_observer_| if it |
| 97 // should register as a data use observer. |
| 98 virtual void ShouldRegisterAsDataUseObserver(bool should_register) const; |
| 99 |
| 96 private: | 100 private: |
| 97 // Java listener that provides regular expressions to |this|. Data use | 101 // Java listener that provides regular expressions to |this|. Data use |
| 98 // reports are submitted to |j_external_data_use_observer_|. | 102 // reports are submitted to |j_external_data_use_observer_|. |
| 99 base::android::ScopedJavaGlobalRef<jobject> j_external_data_use_observer_; | 103 base::android::ScopedJavaGlobalRef<jobject> j_external_data_use_observer_; |
| 100 | 104 |
| 101 // |external_data_use_observer_| owns |this|. |external_data_use_observer_| is | 105 // |external_data_use_observer_| owns |this|. |external_data_use_observer_| is |
| 102 // notified of results from Java code by |this|. | 106 // notified of results from Java code by |this|. |
| 103 base::WeakPtr<ExternalDataUseObserver> external_data_use_observer_; | 107 base::WeakPtr<ExternalDataUseObserver> external_data_use_observer_; |
| 104 | 108 |
| 105 // |data_use_tab_model_| is notified of the matching rules on UI thread. | 109 // |data_use_tab_model_| is notified of the matching rules on UI thread. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 119 DISALLOW_COPY_AND_ASSIGN(ExternalDataUseObserverBridge); | 123 DISALLOW_COPY_AND_ASSIGN(ExternalDataUseObserverBridge); |
| 120 }; | 124 }; |
| 121 | 125 |
| 122 bool RegisterExternalDataUseObserver(JNIEnv* env); | 126 bool RegisterExternalDataUseObserver(JNIEnv* env); |
| 123 | 127 |
| 124 } // namespace android | 128 } // namespace android |
| 125 | 129 |
| 126 } // namespace chrome | 130 } // namespace chrome |
| 127 | 131 |
| 128 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_BRIDGE_H
_ | 132 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_BRIDGE_H
_ |
| OLD | NEW |