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

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

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

Powered by Google App Engine
This is Rietveld 408576698