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/extension_webnavigation_api.cc

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Implements the Chrome Extensions WebNavigation API. 5 // Implements the Chrome Extensions WebNavigation API.
6 6
7 #include "chrome/browser/extensions/extension_webnavigation_api.h" 7 #include "chrome/browser/extensions/extension_webnavigation_api.h"
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/extensions/extension_event_router.h" 14 #include "chrome/browser/extensions/extension_event_router.h"
15 #include "chrome/browser/extensions/extension_tab_util.h" 15 #include "chrome/browser/extensions/extension_tab_util.h"
16 #include "chrome/browser/extensions/extension_webnavigation_api_constants.h" 16 #include "chrome/browser/extensions/extension_webnavigation_api_constants.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
19 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
20 #include "content/browser/tab_contents/navigation_details.h" 20 #include "content/browser/tab_contents/navigation_details.h"
21 #include "content/browser/tab_contents/tab_contents.h" 21 #include "content/browser/tab_contents/tab_contents.h"
22 #include "content/common/notification_service.h" 22 #include "content/public/browser/notification_service.h"
23 #include "content/public/browser/notification_types.h" 23 #include "content/public/browser/notification_types.h"
24 #include "net/base/net_errors.h" 24 #include "net/base/net_errors.h"
25 25
26 namespace keys = extension_webnavigation_api_constants; 26 namespace keys = extension_webnavigation_api_constants;
27 27
28 namespace { 28 namespace {
29 29
30 typedef std::map<TabContents*, ExtensionWebNavigationTabObserver*> 30 typedef std::map<TabContents*, ExtensionWebNavigationTabObserver*>
31 TabObserverMap; 31 TabObserverMap;
32 static base::LazyInstance<TabObserverMap> g_tab_observer( 32 static base::LazyInstance<TabObserverMap> g_tab_observer(
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 360
361 ExtensionWebNavigationEventRouter::~ExtensionWebNavigationEventRouter() {} 361 ExtensionWebNavigationEventRouter::~ExtensionWebNavigationEventRouter() {}
362 362
363 void ExtensionWebNavigationEventRouter::Init() { 363 void ExtensionWebNavigationEventRouter::Init() {
364 if (registrar_.IsEmpty()) { 364 if (registrar_.IsEmpty()) {
365 registrar_.Add(this, 365 registrar_.Add(this,
366 content::NOTIFICATION_RETARGETING, 366 content::NOTIFICATION_RETARGETING,
367 content::Source<content::BrowserContext>(profile_)); 367 content::Source<content::BrowserContext>(profile_));
368 registrar_.Add(this, 368 registrar_.Add(this,
369 content::NOTIFICATION_TAB_ADDED, 369 content::NOTIFICATION_TAB_ADDED,
370 NotificationService::AllSources()); 370 content::NotificationService::AllSources());
371 registrar_.Add(this, 371 registrar_.Add(this,
372 content::NOTIFICATION_TAB_CONTENTS_DESTROYED, 372 content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
373 NotificationService::AllSources()); 373 content::NotificationService::AllSources());
374 } 374 }
375 } 375 }
376 376
377 void ExtensionWebNavigationEventRouter::Observe( 377 void ExtensionWebNavigationEventRouter::Observe(
378 int type, 378 int type,
379 const content::NotificationSource& source, 379 const content::NotificationSource& source,
380 const content::NotificationDetails& details) { 380 const content::NotificationDetails& details) {
381 switch (type) { 381 switch (type) {
382 case content::NOTIFICATION_RETARGETING: 382 case content::NOTIFICATION_RETARGETING:
383 Retargeting( 383 Retargeting(
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 keys::kFrameIdKey, 723 keys::kFrameIdKey,
724 GetFrameId(navigation_state.IsMainFrame(*frame), *frame)); 724 GetFrameId(navigation_state.IsMainFrame(*frame), *frame));
725 frameDict->SetBoolean( 725 frameDict->SetBoolean(
726 keys::kErrorOccurredKey, 726 keys::kErrorOccurredKey,
727 navigation_state.GetErrorOccurredInFrame(*frame)); 727 navigation_state.GetErrorOccurredInFrame(*frame));
728 resultList->Append(frameDict); 728 resultList->Append(frameDict);
729 } 729 }
730 result_.reset(resultList); 730 result_.reset(resultList);
731 return true; 731 return true;
732 } 732 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698