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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "chrome/browser/history/history.h" | 11 #include "chrome/browser/history/history.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 16 #include "chrome/common/chrome_notification_types.h" |
16 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
17 #include "content/public/browser/navigation_details.h" | 18 #include "content/public/browser/navigation_details.h" |
18 #include "content/public/browser/navigation_entry.h" | 19 #include "content/public/browser/navigation_entry.h" |
19 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
20 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
21 #include "content/public/browser/notification_types.h" | |
22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
23 #include "content/public/browser/web_contents_observer.h" | 23 #include "content/public/browser/web_contents_observer.h" |
24 #include "content/public/common/frame_navigate_params.h" | 24 #include "content/public/common/frame_navigate_params.h" |
25 #include "content/public/common/page_transition_types.h" | 25 #include "content/public/common/page_transition_types.h" |
26 | 26 |
27 using content::NavigationEntry; | 27 using content::NavigationEntry; |
28 using content::WebContents; | 28 using content::WebContents; |
29 | 29 |
30 class TabFinder::WebContentsObserverImpl : public content::WebContentsObserver { | 30 class TabFinder::WebContentsObserverImpl : public content::WebContentsObserver { |
31 public: | 31 public: |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 112 } |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 return NULL; | 116 return NULL; |
117 } | 117 } |
118 | 118 |
119 void TabFinder::Observe(int type, | 119 void TabFinder::Observe(int type, |
120 const content::NotificationSource& source, | 120 const content::NotificationSource& source, |
121 const content::NotificationDetails& details) { | 121 const content::NotificationDetails& details) { |
122 DCHECK_EQ(type, content::NOTIFICATION_TAB_PARENTED); | 122 DCHECK_EQ(type, chrome::NOTIFICATION_TAB_PARENTED); |
123 | 123 |
124 // The tab was added to a browser. Query for its state now. | 124 // The tab was added to a browser. Query for its state now. |
125 TabContentsWrapper* tab = content::Source<TabContentsWrapper>(source).ptr(); | 125 TabContentsWrapper* tab = content::Source<TabContentsWrapper>(source).ptr(); |
126 TrackTab(tab->web_contents()); | 126 TrackTab(tab->web_contents()); |
127 } | 127 } |
128 | 128 |
129 TabFinder::TabFinder() { | 129 TabFinder::TabFinder() { |
130 registrar_.Add(this, content::NOTIFICATION_TAB_PARENTED, | 130 registrar_.Add(this, chrome::NOTIFICATION_TAB_PARENTED, |
131 content::NotificationService::AllSources()); | 131 content::NotificationService::AllSources()); |
132 } | 132 } |
133 | 133 |
134 TabFinder::~TabFinder() { | 134 TabFinder::~TabFinder() { |
135 STLDeleteElements(&tab_contents_observers_); | 135 STLDeleteElements(&tab_contents_observers_); |
136 } | 136 } |
137 | 137 |
138 void TabFinder::DidNavigateAnyFrame( | 138 void TabFinder::DidNavigateAnyFrame( |
139 WebContents* source, | 139 WebContents* source, |
140 const content::LoadCommittedDetails& details, | 140 const content::LoadCommittedDetails& details, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 GURL url, | 234 GURL url, |
235 bool success, | 235 bool success, |
236 history::RedirectList* redirects) { | 236 history::RedirectList* redirects) { |
237 if (success && !redirects->empty()) { | 237 if (success && !redirects->empty()) { |
238 WebContents* web_contents = | 238 WebContents* web_contents = |
239 callback_consumer_.GetClientDataForCurrentRequest(); | 239 callback_consumer_.GetClientDataForCurrentRequest(); |
240 DCHECK(web_contents); | 240 DCHECK(web_contents); |
241 web_contents_to_url_[web_contents] = redirects->back(); | 241 web_contents_to_url_[web_contents] = redirects->back(); |
242 } | 242 } |
243 } | 243 } |
OLD | NEW |