OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/browser/extensions/activity_log/uma_policy.h" | 5 #include "chrome/browser/extensions/activity_log/uma_policy.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/extensions/active_script_controller.h" | 10 #include "chrome/browser/extensions/active_script_controller.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 96 } |
97 if (url.empty()) | 97 if (url.empty()) |
98 return; | 98 return; |
99 | 99 |
100 SiteMap::iterator site_lookup = url_status_.find(url); | 100 SiteMap::iterator site_lookup = url_status_.find(url); |
101 if (site_lookup != url_status_.end()) | 101 if (site_lookup != url_status_.end()) |
102 site_lookup->second[action->extension_id()] |= status; | 102 site_lookup->second[action->extension_id()] |= status; |
103 } | 103 } |
104 | 104 |
105 int UmaPolicy::MatchActionToStatus(scoped_refptr<Action> action) { | 105 int UmaPolicy::MatchActionToStatus(scoped_refptr<Action> action) { |
106 if (action->action_type() == Action::ACTION_CONTENT_SCRIPT) { | 106 if (action->action_type() == Action::ACTION_CONTENT_SCRIPT) |
107 return kContentScript; | 107 return kContentScript; |
108 } else if (action->action_type() == Action::ACTION_API_CALL && | 108 if (action->action_type() == Action::ACTION_API_CALL && |
109 action->api_name() == "tabs.executeScript") { | 109 action->api_name() == "tabs.executeScript") |
110 return kContentScript; | 110 return kContentScript; |
111 } else if (action->action_type() != Action::ACTION_DOM_ACCESS) { | 111 if (action->action_type() != Action::ACTION_DOM_ACCESS) |
112 return kNoStatus; | 112 return kNoStatus; |
113 } | |
114 | 113 |
115 int dom_verb; | 114 int dom_verb = DomActionType::MODIFIED; |
116 if (!action->other() || | 115 if (!action->other() || |
117 !action->other()->GetIntegerWithoutPathExpansion( | 116 !action->other()->GetIntegerWithoutPathExpansion( |
118 activity_log_constants::kActionDomVerb, &dom_verb)) { | 117 activity_log_constants::kActionDomVerb, &dom_verb)) |
119 return kNoStatus; | 118 return kNoStatus; |
120 } | |
121 | 119 |
122 int ret_bit = kNoStatus; | 120 int ret_bit = kNoStatus; |
123 DomActionType::Type dom_type = static_cast<DomActionType::Type>(dom_verb); | 121 DomActionType::Type dom_type = static_cast<DomActionType::Type>(dom_verb); |
124 if (dom_type == DomActionType::GETTER) | 122 if (dom_type == DomActionType::GETTER) |
125 return kReadDom; | 123 return kReadDom; |
126 if (dom_type == DomActionType::SETTER) { | 124 if (dom_type == DomActionType::SETTER) |
127 ret_bit |= kModifiedDom; | 125 ret_bit |= kModifiedDom; |
128 } else if (dom_type == DomActionType::METHOD) { | 126 else if (dom_type == DomActionType::METHOD) |
129 ret_bit |= kDomMethod; | 127 ret_bit |= kDomMethod; |
130 } else { | 128 else |
131 return kNoStatus; | 129 return kNoStatus; |
132 } | |
133 | 130 |
134 if (action->api_name() == "HTMLDocument.write" || | 131 if (action->api_name() == "HTMLDocument.write" || |
135 action->api_name() == "HTMLDocument.writeln") { | 132 action->api_name() == "HTMLDocument.writeln") { |
136 ret_bit |= kDocumentWrite; | 133 ret_bit |= kDocumentWrite; |
137 } else if (action->api_name() == "Element.innerHTML") { | 134 } else if (action->api_name() == "Element.innerHTML") { |
138 ret_bit |= kInnerHtml; | 135 ret_bit |= kInnerHtml; |
139 } else if (action->api_name() == "Document.createElement") { | 136 } else if (action->api_name() == "Document.createElement") { |
140 std::string arg; | 137 std::string arg; |
141 action->args()->GetString(0, &arg); | 138 action->args()->GetString(0, &arg); |
142 if (arg == "script") { | 139 if (arg == "script") |
143 ret_bit |= kCreatedScript; | 140 ret_bit |= kCreatedScript; |
144 } else if (arg == "iframe") { | 141 else if (arg == "iframe") |
145 ret_bit |= kCreatedIframe; | 142 ret_bit |= kCreatedIframe; |
146 } else if (arg == "div") { | 143 else if (arg == "div") |
147 ret_bit |= kCreatedDiv; | 144 ret_bit |= kCreatedDiv; |
148 } else if (arg == "a") { | 145 else if (arg == "a") |
149 ret_bit |= kCreatedLink; | 146 ret_bit |= kCreatedLink; |
150 } else if (arg == "input") { | 147 else if (arg == "input") |
151 ret_bit |= kCreatedInput; | 148 ret_bit |= kCreatedInput; |
152 } else if (arg == "embed") { | 149 else if (arg == "embed") |
153 ret_bit |= kCreatedEmbed; | 150 ret_bit |= kCreatedEmbed; |
154 } else if (arg == "object") { | 151 else if (arg == "object") |
155 ret_bit |= kCreatedObject; | 152 ret_bit |= kCreatedObject; |
156 } | |
157 } | 153 } |
158 | 154 |
159 const Action::InjectionType ad_injection = | 155 const Action::InjectionType ad_injection = |
160 action->DidInjectAd(g_browser_process->rappor_service()); | 156 action->DidInjectAd(g_browser_process->rappor_service()); |
161 switch (ad_injection) { | 157 switch (ad_injection) { |
162 case Action::INJECTION_NEW_AD: | 158 case Action::INJECTION_NEW_AD: |
163 ret_bit |= kAdInjected; | 159 ret_bit |= kAdInjected; |
164 break; | 160 break; |
165 case Action::INJECTION_REMOVED_AD: | 161 case Action::INJECTION_REMOVED_AD: |
166 ret_bit |= kAdRemoved; | 162 ret_bit |= kAdRemoved; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 return "AdLikelyReplaced"; | 450 return "AdLikelyReplaced"; |
455 case NONE: | 451 case NONE: |
456 case MAX_STATUS: | 452 case MAX_STATUS: |
457 default: | 453 default: |
458 NOTREACHED(); | 454 NOTREACHED(); |
459 return ""; | 455 return ""; |
460 } | 456 } |
461 } | 457 } |
462 | 458 |
463 } // namespace extensions | 459 } // namespace extensions |
OLD | NEW |