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

Side by Side Diff: chrome/browser/extensions/api/declarative_content/content_rules_registry.cc

Issue 344433003: Prepare declarativeContent API for new script injection feature. Added Javascript types and functio… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add note about what it means to revert RequestContentScript Created 6 years, 6 months 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
OLDNEW
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,
28 const WatchedPagesRecipient
29 watched_pages_recipient,
27 RulesCacheDelegate* cache_delegate) 30 RulesCacheDelegate* cache_delegate)
28 : RulesRegistry(profile, 31 : RulesRegistry(profile,
29 declarative_content_constants::kOnPageChanged, 32 event_name,
30 content::BrowserThread::UI, 33 content::BrowserThread::UI,
31 cache_delegate, 34 cache_delegate,
32 WebViewKey(0, 0)) { 35 WebViewKey(0, 0)),
36 watched_pages_recipient_(watched_pages_recipient) {
33 extension_info_map_ = ExtensionSystem::Get(profile)->info_map(); 37 extension_info_map_ = ExtensionSystem::Get(profile)->info_map();
34 38
35 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, 39 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED,
36 content::NotificationService::AllBrowserContextsAndSources()); 40 content::NotificationService::AllBrowserContextsAndSources());
37 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 41 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
38 content::NotificationService::AllBrowserContextsAndSources()); 42 content::NotificationService::AllBrowserContextsAndSources());
39 } 43 }
40 44
41 void ContentRulesRegistry::Observe( 45 void ContentRulesRegistry::Observe(
42 int type, 46 int type,
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 !it.IsAtEnd(); it.Advance()) { 297 !it.IsAtEnd(); it.Advance()) {
294 content::RenderProcessHost* process = it.GetCurrentValue(); 298 content::RenderProcessHost* process = it.GetCurrentValue();
295 if (process->GetBrowserContext() == profile()) 299 if (process->GetBrowserContext() == profile())
296 InstructRenderProcess(process); 300 InstructRenderProcess(process);
297 } 301 }
298 } 302 }
299 } 303 }
300 304
301 void ContentRulesRegistry::InstructRenderProcess( 305 void ContentRulesRegistry::InstructRenderProcess(
302 content::RenderProcessHost* process) { 306 content::RenderProcessHost* process) {
303 process->Send(new ExtensionMsg_WatchPages(watched_css_selectors_)); 307 for (std::vector<std::string>::const_iterator it =
308 watched_css_selectors_.begin();
309 it != watched_css_selectors_.end(); ++it) {
Fady Samuel 2014/06/23 18:56:28 This is a do-nothing for loop? WhY?
Mark Dittmer 2014/06/24 14:14:19 I couldn't tell you. Probably left over from some
310 }
311 process->Send(
312 new ExtensionMsg_WatchPages(event_name(),
313 watched_pages_recipient_,
314 watched_css_selectors_));
304 } 315 }
305 316
306 bool ContentRulesRegistry::IsEmpty() const { 317 bool ContentRulesRegistry::IsEmpty() const {
307 return match_id_to_rule_.empty() && content_rules_.empty() && 318 return match_id_to_rule_.empty() && content_rules_.empty() &&
308 url_matcher_.IsEmpty(); 319 url_matcher_.IsEmpty();
309 } 320 }
310 321
311 ContentRulesRegistry::~ContentRulesRegistry() {} 322 ContentRulesRegistry::~ContentRulesRegistry() {}
312 323
313 base::Time ContentRulesRegistry::GetExtensionInstallationTime( 324 base::Time ContentRulesRegistry::GetExtensionInstallationTime(
314 const std::string& extension_id) const { 325 const std::string& extension_id) const {
315 if (!extension_info_map_.get()) // May be NULL during testing. 326 if (!extension_info_map_.get()) // May be NULL during testing.
316 return base::Time(); 327 return base::Time();
317 328
318 return extension_info_map_->GetInstallTime(extension_id); 329 return extension_info_map_->GetInstallTime(extension_id);
319 } 330 }
320 331
321 } // namespace extensions 332 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698