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

Side by Side Diff: chrome/browser/android/data_usage/external_data_use_observer.h

Issue 1447363006: ExternalDataUseObserver matches package names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed invalid DCHECK Created 5 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/android/data_usage/external_data_use_observer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_H_ 5 #ifndef CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_H_
6 #define CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_H_ 6 #define CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // called on a different thread. |success| is true if the request was 84 // called on a different thread. |success| is true if the request was
85 // successfully submitted to the external data use observer by Java. Must be 85 // successfully submitted to the external data use observer by Java. Must be
86 // called on UI thread. 86 // called on UI thread.
87 void OnReportDataUseDone(JNIEnv* env, jobject obj, bool success); 87 void OnReportDataUseDone(JNIEnv* env, jobject obj, bool success);
88 88
89 // Returns true if the |gurl| matches the registered regular expressions. 89 // Returns true if the |gurl| matches the registered regular expressions.
90 // |label| must not be null. If a match is found, the |label| is set to the 90 // |label| must not be null. If a match is found, the |label| is set to the
91 // matching rule's label. 91 // matching rule's label.
92 bool Matches(const GURL& gurl, std::string* label) const; 92 bool Matches(const GURL& gurl, std::string* label) const;
93 93
94 // Returns true if the |app_package_name| matches the registered package
95 // names. |label| must not be null. If a match is found, the |label| is set
96 // to the matching rule's label.
97 bool MatchesAppPackageName(const std::string& app_package_name,
98 std::string* label) const;
99
94 DataUseTabModel* data_use_tab_model() const { 100 DataUseTabModel* data_use_tab_model() const {
95 return data_use_tab_model_.get(); 101 return data_use_tab_model_.get();
96 } 102 }
97 103
98 private: 104 private:
99 friend class ExternalDataUseObserverTest; 105 friend class ExternalDataUseObserverTest;
100 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, SingleRegex); 106 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, SingleRegex);
101 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, TwoRegex); 107 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, TwoRegex);
102 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, MultipleRegex); 108 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, MultipleRegex);
103 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, ChangeRegex); 109 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, ChangeRegex);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 182
177 // Stores the matching rules. 183 // Stores the matching rules.
178 class MatchingRule { 184 class MatchingRule {
179 public: 185 public:
180 MatchingRule(const std::string& app_package_name, 186 MatchingRule(const std::string& app_package_name,
181 scoped_ptr<re2::RE2> pattern, 187 scoped_ptr<re2::RE2> pattern,
182 const std::string& label); 188 const std::string& label);
183 ~MatchingRule(); 189 ~MatchingRule();
184 190
185 const re2::RE2* pattern() const; 191 const re2::RE2* pattern() const;
192 const std::string& app_package_name() const;
186 const std::string& label() const; 193 const std::string& label() const;
187 194
188 private: 195 private:
189 // Package name of the app that should be matched. 196 // Package name of the app that should be matched.
190 const std::string app_package_name_; 197 const std::string app_package_name_;
191 198
192 // RE2 pattern to match against URLs. 199 // RE2 pattern to match against URLs.
193 scoped_ptr<re2::RE2> pattern_; 200 scoped_ptr<re2::RE2> pattern_;
194 201
195 // Opaque label that uniquely identifies this matching rule. 202 // Opaque label that uniquely identifies this matching rule.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 DISALLOW_COPY_AND_ASSIGN(ExternalDataUseObserver); 329 DISALLOW_COPY_AND_ASSIGN(ExternalDataUseObserver);
323 }; 330 };
324 331
325 bool RegisterExternalDataUseObserver(JNIEnv* env); 332 bool RegisterExternalDataUseObserver(JNIEnv* env);
326 333
327 } // namespace android 334 } // namespace android
328 335
329 } // namespace chrome 336 } // namespace chrome
330 337
331 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_H_ 338 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/data_usage/external_data_use_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698