OLD | NEW |
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/tabs/tab_finder.h" | 5 #include "chrome/browser/tabs/tab_finder.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
9 #include "chrome/browser/history/history.h" | 9 #include "chrome/browser/history/history.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_list.h" | 12 #include "chrome/browser/ui/browser_list.h" |
13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
15 #include "content/browser/tab_contents/navigation_details.h" | 15 #include "content/browser/tab_contents/navigation_details.h" |
16 #include "content/browser/tab_contents/navigation_entry.h" | 16 #include "content/browser/tab_contents/navigation_entry.h" |
17 #include "content/browser/tab_contents/tab_contents.h" | 17 #include "content/browser/tab_contents/tab_contents.h" |
18 #include "content/browser/tab_contents/tab_contents_observer.h" | 18 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 19 #include "content/common/content_notification_types.h" |
19 #include "content/common/notification_service.h" | 20 #include "content/common/notification_service.h" |
20 #include "content/common/notification_source.h" | 21 #include "content/common/notification_source.h" |
21 #include "content/common/notification_type.h" | |
22 #include "content/common/page_transition_types.h" | 22 #include "content/common/page_transition_types.h" |
23 #include "content/common/view_messages.h" | 23 #include "content/common/view_messages.h" |
24 | 24 |
25 class TabFinder::TabContentsObserverImpl : public TabContentsObserver { | 25 class TabFinder::TabContentsObserverImpl : public TabContentsObserver { |
26 public: | 26 public: |
27 TabContentsObserverImpl(TabContents* tab, TabFinder* finder); | 27 TabContentsObserverImpl(TabContents* tab, TabFinder* finder); |
28 virtual ~TabContentsObserverImpl(); | 28 virtual ~TabContentsObserverImpl(); |
29 | 29 |
30 TabContents* tab_contents() { return TabContentsObserver::tab_contents(); } | 30 TabContents* tab_contents() { return TabContentsObserver::tab_contents(); } |
31 | 31 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (tab_in_browser) { | 102 if (tab_in_browser) { |
103 *existing_browser = *i; | 103 *existing_browser = *i; |
104 return tab_in_browser; | 104 return tab_in_browser; |
105 } | 105 } |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 return NULL; | 109 return NULL; |
110 } | 110 } |
111 | 111 |
112 void TabFinder::Observe(NotificationType type, | 112 void TabFinder::Observe(int type, |
113 const NotificationSource& source, | 113 const NotificationSource& source, |
114 const NotificationDetails& details) { | 114 const NotificationDetails& details) { |
115 DCHECK_EQ(type.value, NotificationType::TAB_PARENTED); | 115 DCHECK_EQ(type, content::NOTIFICATION_TAB_PARENTED); |
116 | 116 |
117 // The tab was added to a browser. Query for its state now. | 117 // The tab was added to a browser. Query for its state now. |
118 TabContentsWrapper* tab = Source<TabContentsWrapper>(source).ptr(); | 118 TabContentsWrapper* tab = Source<TabContentsWrapper>(source).ptr(); |
119 TrackTab(tab->tab_contents()); | 119 TrackTab(tab->tab_contents()); |
120 } | 120 } |
121 | 121 |
122 TabFinder::TabFinder() { | 122 TabFinder::TabFinder() { |
123 registrar_.Add(this, NotificationType::TAB_PARENTED, | 123 registrar_.Add(this, content::NOTIFICATION_TAB_PARENTED, |
124 NotificationService::AllSources()); | 124 NotificationService::AllSources()); |
125 } | 125 } |
126 | 126 |
127 TabFinder::~TabFinder() { | 127 TabFinder::~TabFinder() { |
128 STLDeleteElements(&tab_contents_observers_); | 128 STLDeleteElements(&tab_contents_observers_); |
129 } | 129 } |
130 | 130 |
131 void TabFinder::DidNavigateAnyFramePostCommit( | 131 void TabFinder::DidNavigateAnyFramePostCommit( |
132 TabContents* source, | 132 TabContents* source, |
133 const content::LoadCommittedDetails& details, | 133 const content::LoadCommittedDetails& details, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 GURL url, | 222 GURL url, |
223 bool success, | 223 bool success, |
224 history::RedirectList* redirects) { | 224 history::RedirectList* redirects) { |
225 if (success && !redirects->empty()) { | 225 if (success && !redirects->empty()) { |
226 TabContents* tab_contents = | 226 TabContents* tab_contents = |
227 callback_consumer_.GetClientDataForCurrentRequest(); | 227 callback_consumer_.GetClientDataForCurrentRequest(); |
228 DCHECK(tab_contents); | 228 DCHECK(tab_contents); |
229 tab_contents_to_url_[tab_contents] = redirects->back(); | 229 tab_contents_to_url_[tab_contents] = redirects->back(); |
230 } | 230 } |
231 } | 231 } |
OLD | NEW |