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

Side by Side Diff: chrome/browser/ui/tabs/tab_finder.cc

Issue 10537062: TabContentsWrapper -> TabContents, part 13. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fiz Created 8 years, 6 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
« no previous file with comments | « chrome/browser/ui/tabs/pinned_tab_codec.cc ('k') | chrome/browser/ui/tabs/tab_strip_model.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ui/tabs/tab_finder.h" 5 #include "chrome/browser/ui/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.h"
16 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
18 #include "content/public/browser/navigation_details.h" 18 #include "content/public/browser/navigation_details.h"
19 #include "content/public/browser/navigation_entry.h" 19 #include "content/public/browser/navigation_entry.h"
20 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
21 #include "content/public/browser/notification_source.h" 21 #include "content/public/browser/notification_source.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"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 82 }
83 83
84 WebContents* TabFinder::FindTab(Browser* browser, 84 WebContents* TabFinder::FindTab(Browser* browser,
85 const GURL& url, 85 const GURL& url,
86 Browser** existing_browser) { 86 Browser** existing_browser) {
87 if (browser->profile()->IsOffTheRecord()) 87 if (browser->profile()->IsOffTheRecord())
88 return NULL; 88 return NULL;
89 89
90 // If the current tab matches the url, ignore it and let the user reload the 90 // If the current tab matches the url, ignore it and let the user reload the
91 // existing tab. 91 // existing tab.
92 WebContents* selected_tab = browser->GetSelectedWebContents(); 92 WebContents* selected_tab = browser->GetActiveWebContents();
93 if (TabMatchesURL(selected_tab, url)) 93 if (TabMatchesURL(selected_tab, url))
94 return NULL; 94 return NULL;
95 95
96 // See if the current browser has a tab matching the specified url. 96 // See if the current browser has a tab matching the specified url.
97 WebContents* tab_in_browser = FindTabInBrowser(browser, url); 97 WebContents* tab_in_browser = FindTabInBrowser(browser, url);
98 if (tab_in_browser) { 98 if (tab_in_browser) {
99 *existing_browser = browser; 99 *existing_browser = browser;
100 return tab_in_browser; 100 return tab_in_browser;
101 } 101 }
102 102
(...skipping 12 matching lines...) Expand all
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, chrome::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 TabContents* tab = content::Source<TabContents>(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, chrome::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_);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tabs/pinned_tab_codec.cc ('k') | chrome/browser/ui/tabs/tab_strip_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698