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

Side by Side Diff: chrome/browser/ui/browser_tabstrip.cc

Issue 10868072: Make TabContents ctor private; poke hole for existing callers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: all green Created 8 years, 4 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/ui/browser_tabstrip.h" 5 #include "chrome/browser/ui/browser_tabstrip.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" 9 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_navigator.h" 11 #include "chrome/browser/ui/browser_navigator.h"
12 #include "chrome/browser/ui/browser_window.h" 12 #include "chrome/browser/ui/browser_window.h"
13 #include "chrome/browser/ui/tab_contents/tab_contents.h" 13 #include "chrome/browser/ui/tab_contents/tab_contents.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
17 #include "content/public/browser/navigation_entry.h" 17 #include "content/public/browser/navigation_entry.h"
18 #include "content/public/browser/render_view_host.h" 18 #include "content/public/browser/render_view_host.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 20
21 // TODO(avi): Kill this when TabContents goes away.
22 class BrowserTabstripTabContentsCreator {
23 public:
24 static TabContents* CreateTabContents(content::WebContents* contents) {
25 return TabContents::Factory::CreateTabContents(contents);
26 }
27 };
28
21 namespace chrome { 29 namespace chrome {
22 30
23 int GetIndexOfTab(const Browser* browser, 31 int GetIndexOfTab(const Browser* browser,
24 const content::WebContents* contents) { 32 const content::WebContents* contents) {
25 return browser->tab_strip_model()->GetIndexOfWebContents(contents); 33 return browser->tab_strip_model()->GetIndexOfWebContents(contents);
26 } 34 }
27 35
28 TabContents* GetActiveTabContents(const Browser* browser) { 36 TabContents* GetActiveTabContents(const Browser* browser) {
29 return browser->tab_strip_model()->GetActiveTabContents(); 37 return browser->tab_strip_model()->GetActiveTabContents();
30 } 38 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 const gfx::Rect& initial_pos, 101 const gfx::Rect& initial_pos,
94 bool user_gesture) { 102 bool user_gesture) {
95 // No code for this yet. 103 // No code for this yet.
96 DCHECK(disposition != SAVE_TO_DISK); 104 DCHECK(disposition != SAVE_TO_DISK);
97 // Can't create a new contents for the current tab - invalid case. 105 // Can't create a new contents for the current tab - invalid case.
98 DCHECK(disposition != CURRENT_TAB); 106 DCHECK(disposition != CURRENT_TAB);
99 107
100 TabContents* source_tab_contents = NULL; 108 TabContents* source_tab_contents = NULL;
101 BlockedContentTabHelper* source_blocked_content = NULL; 109 BlockedContentTabHelper* source_blocked_content = NULL;
102 TabContents* new_tab_contents = TabContents::FromWebContents(new_contents); 110 TabContents* new_tab_contents = TabContents::FromWebContents(new_contents);
103 if (!new_tab_contents) 111 if (!new_tab_contents) {
104 new_tab_contents = new TabContents(new_contents); 112 new_tab_contents =
113 BrowserTabstripTabContentsCreator::CreateTabContents(new_contents);
114 }
105 if (source_contents) { 115 if (source_contents) {
106 source_tab_contents = TabContents::FromWebContents(source_contents); 116 source_tab_contents = TabContents::FromWebContents(source_contents);
107 source_blocked_content = source_tab_contents->blocked_content_tab_helper(); 117 source_blocked_content = source_tab_contents->blocked_content_tab_helper();
108 } 118 }
109 119
110 if (source_tab_contents) { 120 if (source_tab_contents) {
111 // Handle blocking of all contents. 121 // Handle blocking of all contents.
112 if (source_blocked_content->all_contents_blocked()) { 122 if (source_blocked_content->all_contents_blocked()) {
113 source_blocked_content->AddTabContents(new_tab_contents, 123 source_blocked_content->AddTabContents(new_tab_contents,
114 disposition, 124 disposition,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 164
155 void CloseAllTabs(Browser* browser) { 165 void CloseAllTabs(Browser* browser) {
156 browser->tab_strip_model()->CloseAllTabs(); 166 browser->tab_strip_model()->CloseAllTabs();
157 } 167 }
158 168
159 TabContents* TabContentsFactory( 169 TabContents* TabContentsFactory(
160 Profile* profile, 170 Profile* profile,
161 content::SiteInstance* site_instance, 171 content::SiteInstance* site_instance,
162 int routing_id, 172 int routing_id,
163 const content::WebContents* base_web_contents) { 173 const content::WebContents* base_web_contents) {
164 return new TabContents(content::WebContents::Create(profile, 174 return BrowserTabstripTabContentsCreator::CreateTabContents(
165 site_instance, 175 content::WebContents::Create(profile,
166 routing_id, 176 site_instance,
167 base_web_contents)); 177 routing_id,
178 base_web_contents));
168 } 179 }
169 180
170 TabContents* TabContentsWithSessionStorageFactory( 181 TabContents* TabContentsWithSessionStorageFactory(
171 Profile* profile, 182 Profile* profile,
172 content::SiteInstance* site_instance, 183 content::SiteInstance* site_instance,
173 int routing_id, 184 int routing_id,
174 const content::WebContents* base_web_contents, 185 const content::WebContents* base_web_contents,
175 const content::SessionStorageNamespaceMap& session_storage_namespace_map) { 186 const content::SessionStorageNamespaceMap& session_storage_namespace_map) {
176 return new TabContents( 187 return BrowserTabstripTabContentsCreator::CreateTabContents(
177 content::WebContents::CreateWithSessionStorage( 188 content::WebContents::CreateWithSessionStorage(
178 profile, 189 profile,
179 site_instance, 190 site_instance,
180 routing_id, 191 routing_id,
181 base_web_contents, 192 base_web_contents,
182 session_storage_namespace_map)); 193 session_storage_namespace_map));
183 } 194 }
184 195
185 } // namespace chrome 196 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_commands.cc ('k') | chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698