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 COMPONENTS_SECURITY_INTERSTITIALS_CORE_CONTROLLER_CLIENT_H_ | 5 #ifndef COMPONENTS_SECURITY_INTERSTITIALS_CORE_CONTROLLER_CLIENT_H_ |
6 #define COMPONENTS_SECURITY_INTERSTITIALS_CORE_CONTROLLER_CLIENT_H_ | 6 #define COMPONENTS_SECURITY_INTERSTITIALS_CORE_CONTROLLER_CLIENT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 | 12 |
13 class GURL; | 13 class GURL; |
14 class PrefService; | 14 class PrefService; |
15 | 15 |
16 namespace security_interstitials { | 16 namespace security_interstitials { |
17 | 17 |
18 class MetricsHelper; | 18 class MetricsHelper; |
19 | 19 |
| 20 // Constants used to communicate with the JavaScript. |
| 21 extern const char kBoxChecked[]; |
| 22 extern const char kDisplayCheckBox[]; |
| 23 extern const char kOptInLink[]; |
| 24 extern const char kPrivacyLinkHtml[]; |
| 25 |
| 26 // These represent the commands sent from the interstitial JavaScript. |
| 27 // DO NOT reorder or change these without also changing the JavaScript! |
| 28 // See components/security_interstitials/core/browser/resources/ |
| 29 enum SecurityInterstitialCommands { |
| 30 // Used by tests |
| 31 CMD_ERROR = -3, |
| 32 CMD_TEXT_FOUND = -2, |
| 33 CMD_TEXT_NOT_FOUND = -1, |
| 34 // Decisions |
| 35 CMD_DONT_PROCEED = 0, |
| 36 CMD_PROCEED = 1, |
| 37 // Ways for user to get more information |
| 38 CMD_SHOW_MORE_SECTION = 2, |
| 39 CMD_OPEN_HELP_CENTER = 3, |
| 40 CMD_OPEN_DIAGNOSTIC = 4, |
| 41 // Primary button actions |
| 42 CMD_RELOAD = 5, |
| 43 CMD_OPEN_DATE_SETTINGS = 6, |
| 44 CMD_OPEN_LOGIN = 7, |
| 45 // Safe Browsing Extended Reporting |
| 46 CMD_DO_REPORT = 8, |
| 47 CMD_DONT_REPORT = 9, |
| 48 CMD_OPEN_REPORTING_PRIVACY = 10, |
| 49 // Report a phishing error |
| 50 CMD_REPORT_PHISHING_ERROR = 11, |
| 51 }; |
| 52 |
20 // Provides methods for handling commands from the user, which requires some | 53 // Provides methods for handling commands from the user, which requires some |
21 // embedder-specific abstraction. | 54 // embedder-specific abstraction. |
22 class ControllerClient { | 55 class ControllerClient { |
23 public: | 56 public: |
24 // These represent the commands sent from the interstitial JavaScript. | |
25 // DO NOT reorder or change these without also changing the JavaScript! | |
26 // See components/security_interstitials/core/browser/resources/ | |
27 enum SecurityInterstitialCommands { | |
28 // Used by tests | |
29 CMD_ERROR = -3, | |
30 CMD_TEXT_FOUND = -2, | |
31 CMD_TEXT_NOT_FOUND = -1, | |
32 // Decisions | |
33 CMD_DONT_PROCEED = 0, | |
34 CMD_PROCEED = 1, | |
35 // Ways for user to get more information | |
36 CMD_SHOW_MORE_SECTION = 2, | |
37 CMD_OPEN_HELP_CENTER = 3, | |
38 CMD_OPEN_DIAGNOSTIC = 4, | |
39 // Primary button actions | |
40 CMD_RELOAD = 5, | |
41 CMD_OPEN_DATE_SETTINGS = 6, | |
42 CMD_OPEN_LOGIN = 7, | |
43 // Safe Browsing Extended Reporting | |
44 CMD_DO_REPORT = 8, | |
45 CMD_DONT_REPORT = 9, | |
46 CMD_OPEN_REPORTING_PRIVACY = 10, | |
47 // Report a phishing error | |
48 CMD_REPORT_PHISHING_ERROR = 11, | |
49 }; | |
50 | |
51 ControllerClient(); | 57 ControllerClient(); |
52 virtual ~ControllerClient(); | 58 virtual ~ControllerClient(); |
53 | 59 |
54 // Handle the user's reporting preferences. | 60 // Handle the user's reporting preferences. |
55 void SetReportingPreference(bool report); | 61 void SetReportingPreference(bool report); |
56 void OpenExtendedReportingPrivacyPolicy(); | 62 void OpenExtendedReportingPrivacyPolicy(); |
57 | 63 |
58 MetricsHelper* metrics_helper() const; | 64 MetricsHelper* metrics_helper() const; |
59 void set_metrics_helper(scoped_ptr<MetricsHelper> metrics_helper); | 65 void set_metrics_helper(scoped_ptr<MetricsHelper> metrics_helper); |
60 | 66 |
61 protected: | 67 protected: |
62 virtual void OpenUrlInCurrentTab(const GURL& url) = 0; | 68 virtual void OpenUrlInCurrentTab(const GURL& url) = 0; |
63 | 69 |
64 virtual const std::string& GetApplicationLocale() = 0; | 70 virtual const std::string& GetApplicationLocale() = 0; |
65 virtual PrefService* GetPrefService() = 0; | 71 virtual PrefService* GetPrefService() = 0; |
66 virtual const std::string GetExtendedReportingPrefName() = 0; | 72 virtual const std::string GetExtendedReportingPrefName() = 0; |
67 | 73 |
68 private: | 74 private: |
69 scoped_ptr<MetricsHelper> metrics_helper_; | 75 scoped_ptr<MetricsHelper> metrics_helper_; |
70 | 76 |
71 DISALLOW_COPY_AND_ASSIGN(ControllerClient); | 77 DISALLOW_COPY_AND_ASSIGN(ControllerClient); |
72 }; | 78 }; |
73 | 79 |
74 } // namespace security_interstitials | 80 } // namespace security_interstitials |
75 | 81 |
76 #endif // COMPONENTS_SECURITY_INTERSTITIALS_CORE_CONTROLLER_CLIENT_H_ | 82 #endif // COMPONENTS_SECURITY_INTERSTITIALS_CORE_CONTROLLER_CLIENT_H_ |
OLD | NEW |