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

Side by Side Diff: chrome/browser/automation/automation_tab_tracker.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 #include "chrome/browser/automation/automation_tab_tracker.h" 5 #include "chrome/browser/automation/automation_tab_tracker.h"
6 6
7 #include "content/browser/tab_contents/navigation_controller.h" 7 #include "content/browser/tab_contents/navigation_controller.h"
8 #include "chrome/common/chrome_notification_types.h"
8 #include "content/common/notification_source.h" 9 #include "content/common/notification_source.h"
9 #include "content/common/notification_type.h"
10 10
11 AutomationTabTracker::AutomationTabTracker(IPC::Message::Sender* automation) 11 AutomationTabTracker::AutomationTabTracker(IPC::Message::Sender* automation)
12 : AutomationResourceTracker<NavigationController*>(automation) { 12 : AutomationResourceTracker<NavigationController*>(automation) {
13 } 13 }
14 14
15 AutomationTabTracker::~AutomationTabTracker() { 15 AutomationTabTracker::~AutomationTabTracker() {
16 } 16 }
17 17
18 void AutomationTabTracker::AddObserver(NavigationController* resource) { 18 void AutomationTabTracker::AddObserver(NavigationController* resource) {
19 // This tab could either be a regular tab or an external tab 19 // This tab could either be a regular tab or an external tab
20 // Register for both notifications. 20 // Register for both notifications.
21 registrar_.Add(this, NotificationType::TAB_CLOSING, 21 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSING,
22 Source<NavigationController>(resource)); 22 Source<NavigationController>(resource));
23 registrar_.Add(this, NotificationType::EXTERNAL_TAB_CLOSED, 23 registrar_.Add(this, chrome::NOTIFICATION_EXTERNAL_TAB_CLOSED,
24 Source<NavigationController>(resource)); 24 Source<NavigationController>(resource));
25 // We also want to know about navigations so we can keep track of the last 25 // We also want to know about navigations so we can keep track of the last
26 // navigation time. 26 // navigation time.
27 registrar_.Add(this, NotificationType::LOAD_STOP, 27 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP,
28 Source<NavigationController>(resource)); 28 Source<NavigationController>(resource));
29 } 29 }
30 30
31 void AutomationTabTracker::RemoveObserver(NavigationController* resource) { 31 void AutomationTabTracker::RemoveObserver(NavigationController* resource) {
32 registrar_.Remove(this, NotificationType::TAB_CLOSING, 32 registrar_.Remove(this, content::NOTIFICATION_TAB_CLOSING,
33 Source<NavigationController>(resource)); 33 Source<NavigationController>(resource));
34 registrar_.Remove(this, NotificationType::EXTERNAL_TAB_CLOSED, 34 registrar_.Remove(this, chrome::NOTIFICATION_EXTERNAL_TAB_CLOSED,
35 Source<NavigationController>(resource)); 35 Source<NavigationController>(resource));
36 registrar_.Remove(this, NotificationType::LOAD_STOP, 36 registrar_.Remove(this, content::NOTIFICATION_LOAD_STOP,
37 Source<NavigationController>(resource)); 37 Source<NavigationController>(resource));
38 } 38 }
39 39
40 void AutomationTabTracker::Observe(NotificationType type, 40 void AutomationTabTracker::Observe(int type,
41 const NotificationSource& source, 41 const NotificationSource& source,
42 const NotificationDetails& details) { 42 const NotificationDetails& details) {
43 switch (type.value) { 43 switch (type) {
44 case NotificationType::LOAD_STOP: 44 case content::NOTIFICATION_LOAD_STOP:
45 last_navigation_times_[Source<NavigationController>(source).ptr()] = 45 last_navigation_times_[Source<NavigationController>(source).ptr()] =
46 base::Time::Now(); 46 base::Time::Now();
47 return; 47 return;
48 case NotificationType::EXTERNAL_TAB_CLOSED: 48 case chrome::NOTIFICATION_EXTERNAL_TAB_CLOSED:
49 case NotificationType::TAB_CLOSING: 49 case content::NOTIFICATION_TAB_CLOSING:
50 { 50 {
51 std::map<NavigationController*, base::Time>::iterator iter = 51 std::map<NavigationController*, base::Time>::iterator iter =
52 last_navigation_times_.find( 52 last_navigation_times_.find(
53 Source<NavigationController>(source).ptr()); 53 Source<NavigationController>(source).ptr());
54 if (iter != last_navigation_times_.end()) 54 if (iter != last_navigation_times_.end())
55 last_navigation_times_.erase(iter); 55 last_navigation_times_.erase(iter);
56 } 56 }
57 break; 57 break;
58 default: 58 default:
59 NOTREACHED(); 59 NOTREACHED();
60 } 60 }
61 AutomationResourceTracker<NavigationController*>::Observe(type, source, 61 AutomationResourceTracker<NavigationController*>::Observe(type, source,
62 details); 62 details);
63 } 63 }
64 64
65 base::Time AutomationTabTracker::GetLastNavigationTime(int handle) { 65 base::Time AutomationTabTracker::GetLastNavigationTime(int handle) {
66 if (ContainsHandle(handle)) { 66 if (ContainsHandle(handle)) {
67 NavigationController* controller = GetResource(handle); 67 NavigationController* controller = GetResource(handle);
68 if (controller) { 68 if (controller) {
69 std::map<NavigationController*, base::Time>::const_iterator iter = 69 std::map<NavigationController*, base::Time>::const_iterator iter =
70 last_navigation_times_.find(controller); 70 last_navigation_times_.find(controller);
71 if (iter != last_navigation_times_.end()) 71 if (iter != last_navigation_times_.end())
72 return iter->second; 72 return iter->second;
73 } 73 }
74 } 74 }
75 return base::Time(); 75 return base::Time();
76 } 76 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_tab_tracker.h ('k') | chrome/browser/automation/automation_window_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698