| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/api/declarative_content/content_rules_regist
ry.h" | 5 #include "chrome/browser/extensions/api/declarative_content/content_rules_regist
ry.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/extensions/api/declarative_content/content_action.h" | 8 #include "chrome/browser/extensions/api/declarative_content/content_action.h" |
| 9 #include "chrome/browser/extensions/api/declarative_content/content_condition.h" | 9 #include "chrome/browser/extensions/api/declarative_content/content_condition.h" |
| 10 #include "chrome/browser/extensions/api/declarative_content/content_constants.h" | 10 #include "chrome/browser/extensions/api/declarative_content/content_constants.h" |
| 11 #include "chrome/browser/extensions/extension_tab_util.h" | 11 #include "chrome/browser/extensions/extension_tab_util.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "content/public/browser/navigation_details.h" | 13 #include "content/public/browser/navigation_details.h" |
| 14 #include "content/public/browser/notification_service.h" | 14 #include "content/public/browser/notification_service.h" |
| 15 #include "content/public/browser/notification_source.h" | 15 #include "content/public/browser/notification_source.h" |
| 16 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
| 17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "extensions/browser/extension_registry.h" | 18 #include "extensions/browser/extension_registry.h" |
| 19 #include "extensions/browser/extension_system.h" | 19 #include "extensions/browser/extension_system.h" |
| 20 #include "extensions/common/extension_messages.h" | 20 #include "extensions/common/extension_messages.h" |
| 21 | 21 |
| 22 using url_matcher::URLMatcherConditionSet; | 22 using url_matcher::URLMatcherConditionSet; |
| 23 | 23 |
| 24 namespace extensions { | 24 namespace extensions { |
| 25 | 25 |
| 26 ContentRulesRegistry::ContentRulesRegistry(Profile* profile, | 26 ContentRulesRegistry::ContentRulesRegistry(Profile* profile, |
| 27 const std::string& event_name, |
| 27 RulesCacheDelegate* cache_delegate) | 28 RulesCacheDelegate* cache_delegate) |
| 28 : RulesRegistry(profile, | 29 : RulesRegistry(profile, |
| 29 declarative_content_constants::kOnPageChanged, | 30 event_name, |
| 30 content::BrowserThread::UI, | 31 content::BrowserThread::UI, |
| 31 cache_delegate, | 32 cache_delegate, |
| 32 WebViewKey(0, 0)) { | 33 WebViewKey(0, 0)) { |
| 33 extension_info_map_ = ExtensionSystem::Get(profile)->info_map(); | 34 extension_info_map_ = ExtensionSystem::Get(profile)->info_map(); |
| 34 | 35 |
| 35 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 36 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 36 content::NotificationService::AllBrowserContextsAndSources()); | 37 content::NotificationService::AllBrowserContextsAndSources()); |
| 37 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 38 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 38 content::NotificationService::AllBrowserContextsAndSources()); | 39 content::NotificationService::AllBrowserContextsAndSources()); |
| 39 } | 40 } |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 !it.IsAtEnd(); it.Advance()) { | 294 !it.IsAtEnd(); it.Advance()) { |
| 294 content::RenderProcessHost* process = it.GetCurrentValue(); | 295 content::RenderProcessHost* process = it.GetCurrentValue(); |
| 295 if (process->GetBrowserContext() == profile()) | 296 if (process->GetBrowserContext() == profile()) |
| 296 InstructRenderProcess(process); | 297 InstructRenderProcess(process); |
| 297 } | 298 } |
| 298 } | 299 } |
| 299 } | 300 } |
| 300 | 301 |
| 301 void ContentRulesRegistry::InstructRenderProcess( | 302 void ContentRulesRegistry::InstructRenderProcess( |
| 302 content::RenderProcessHost* process) { | 303 content::RenderProcessHost* process) { |
| 303 process->Send(new ExtensionMsg_WatchPages(watched_css_selectors_)); | 304 process->Send( |
| 305 new ExtensionMsg_WatchPages(event_name(), watched_css_selectors_)); |
| 304 } | 306 } |
| 305 | 307 |
| 306 bool ContentRulesRegistry::IsEmpty() const { | 308 bool ContentRulesRegistry::IsEmpty() const { |
| 307 return match_id_to_rule_.empty() && content_rules_.empty() && | 309 return match_id_to_rule_.empty() && content_rules_.empty() && |
| 308 url_matcher_.IsEmpty(); | 310 url_matcher_.IsEmpty(); |
| 309 } | 311 } |
| 310 | 312 |
| 311 ContentRulesRegistry::~ContentRulesRegistry() {} | 313 ContentRulesRegistry::~ContentRulesRegistry() {} |
| 312 | 314 |
| 313 base::Time ContentRulesRegistry::GetExtensionInstallationTime( | 315 base::Time ContentRulesRegistry::GetExtensionInstallationTime( |
| 314 const std::string& extension_id) const { | 316 const std::string& extension_id) const { |
| 315 if (!extension_info_map_.get()) // May be NULL during testing. | 317 if (!extension_info_map_.get()) // May be NULL during testing. |
| 316 return base::Time(); | 318 return base::Time(); |
| 317 | 319 |
| 318 return extension_info_map_->GetInstallTime(extension_id); | 320 return extension_info_map_->GetInstallTime(extension_id); |
| 319 } | 321 } |
| 320 | 322 |
| 321 } // namespace extensions | 323 } // namespace extensions |
| OLD | NEW |