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

Side by Side Diff: chrome/browser/ui/extensions/application_launch.cc

Issue 10536093: TabContentsWrapper -> TabContents, part 39. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « no previous file | chrome/browser/ui/extensions/shell_window.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/extensions/application_launch.h" 5 #include "chrome/browser/ui/extensions/application_launch.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "chrome/browser/extensions/default_apps_trial.h" 10 #include "chrome/browser/extensions/default_apps_trial.h"
11 #include "chrome/browser/extensions/extension_prefs.h" 11 #include "chrome/browser/extensions/extension_prefs.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/extension_tab_helper.h" 13 #include "chrome/browser/extensions/extension_tab_helper.h"
14 #include "chrome/browser/extensions/platform_app_launcher.h" 14 #include "chrome/browser/extensions/platform_app_launcher.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 16 #include "chrome/browser/ui/tab_contents/tab_contents.h"
17 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_finder.h" 18 #include "chrome/browser/ui/browser_finder.h"
19 #include "chrome/browser/ui/browser_window.h" 19 #include "chrome/browser/ui/browser_window.h"
20 #include "chrome/browser/ui/panels/panel_manager.h" 20 #include "chrome/browser/ui/panels/panel_manager.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" 21 #include "chrome/browser/ui/tabs/tab_strip_model.h"
22 #include "chrome/browser/web_applications/web_app.h" 22 #include "chrome/browser/web_applications/web_app.h"
23 #include "chrome/common/extensions/extension.h" 23 #include "chrome/common/extensions/extension.h"
24 #include "chrome/common/extensions/extension_constants.h" 24 #include "chrome/common/extensions/extension_constants.h"
25 #include "chrome/common/url_constants.h" 25 #include "chrome/common/url_constants.h"
26 #include "content/public/browser/render_view_host.h" 26 #include "content/public/browser/render_view_host.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 else if (launch_type == ExtensionPrefs::LAUNCH_WINDOW) 191 else if (launch_type == ExtensionPrefs::LAUNCH_WINDOW)
192 params.initial_show_state = ui::SHOW_STATE_NORMAL; 192 params.initial_show_state = ui::SHOW_STATE_NORMAL;
193 } 193 }
194 #endif 194 #endif
195 195
196 Browser* browser = Browser::CreateWithParams(params); 196 Browser* browser = Browser::CreateWithParams(params);
197 197
198 if (app_browser) 198 if (app_browser)
199 *app_browser = browser; 199 *app_browser = browser;
200 200
201 TabContentsWrapper* wrapper = 201 TabContents* tab_contents =
202 browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_START_PAGE); 202 browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_START_PAGE);
203 WebContents* contents = wrapper->web_contents(); 203 WebContents* contents = tab_contents->web_contents();
204 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 204 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
205 contents->GetRenderViewHost()->SyncRendererPrefs(); 205 contents->GetRenderViewHost()->SyncRendererPrefs();
206 // TODO(stevenjb): Find the right centralized place to do this. Currently it 206 // TODO(stevenjb): Find the right centralized place to do this. Currently it
207 // is only done for app tabs in normal browsers through SetExtensionAppById. 207 // is only done for app tabs in normal browsers through SetExtensionAppById.
208 if (extension && type == Browser::TYPE_PANEL) 208 if (extension && type == Browser::TYPE_PANEL) {
209 wrapper->extension_tab_helper()->SetExtensionAppIconById(extension->id()); 209 tab_contents->extension_tab_helper()->
210 SetExtensionAppIconById(extension->id());
211 }
210 212
211 browser->window()->Show(); 213 browser->window()->Show();
212 214
213 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial 215 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial
214 // focus explicitly. 216 // focus explicitly.
215 contents->GetView()->SetInitialFocus(); 217 contents->GetView()->SetInitialFocus();
216 return contents; 218 return contents;
217 } 219 }
218 220
219 WebContents* OpenAppShortcutWindow(Profile* profile, 221 WebContents* OpenAppShortcutWindow(Profile* profile,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 285
284 GURL extension_url = UrlForExtension(extension, override_url); 286 GURL extension_url = UrlForExtension(extension, override_url);
285 // TODO(erikkay): START_PAGE doesn't seem like the right transition in all 287 // TODO(erikkay): START_PAGE doesn't seem like the right transition in all
286 // cases. 288 // cases.
287 browser::NavigateParams params(browser, extension_url, 289 browser::NavigateParams params(browser, extension_url,
288 content::PAGE_TRANSITION_START_PAGE); 290 content::PAGE_TRANSITION_START_PAGE);
289 params.tabstrip_add_types = add_type; 291 params.tabstrip_add_types = add_type;
290 params.disposition = disposition; 292 params.disposition = disposition;
291 293
292 if (disposition == CURRENT_TAB) { 294 if (disposition == CURRENT_TAB) {
293 WebContents* existing_tab = browser->GetSelectedWebContents(); 295 WebContents* existing_tab = browser->GetActiveWebContents();
294 TabStripModel* model = browser->tab_strip_model(); 296 TabStripModel* model = browser->tab_strip_model();
295 int tab_index = model->GetIndexOfWebContents(existing_tab); 297 int tab_index = model->GetIndexOfWebContents(existing_tab);
296 298
297 existing_tab->OpenURL(content::OpenURLParams( 299 existing_tab->OpenURL(content::OpenURLParams(
298 extension_url, 300 extension_url,
299 content::Referrer(existing_tab->GetURL(), 301 content::Referrer(existing_tab->GetURL(),
300 WebKit::WebReferrerPolicyDefault), 302 WebKit::WebReferrerPolicyDefault),
301 disposition, content::PAGE_TRANSITION_LINK, false)); 303 disposition, content::PAGE_TRANSITION_LINK, false));
302 // Reset existing_tab as OpenURL() may have clobbered it. 304 // Reset existing_tab as OpenURL() may have clobbered it.
303 existing_tab = browser->GetSelectedWebContents(); 305 existing_tab = browser->GetActiveWebContents();
304 if (params.tabstrip_add_types & TabStripModel::ADD_PINNED) { 306 if (params.tabstrip_add_types & TabStripModel::ADD_PINNED) {
305 model->SetTabPinned(tab_index, true); 307 model->SetTabPinned(tab_index, true);
306 // Pinning may have moved the tab. 308 // Pinning may have moved the tab.
307 tab_index = model->GetIndexOfWebContents(existing_tab); 309 tab_index = model->GetIndexOfWebContents(existing_tab);
308 } 310 }
309 if (params.tabstrip_add_types & TabStripModel::ADD_ACTIVE) 311 if (params.tabstrip_add_types & TabStripModel::ADD_ACTIVE)
310 model->ActivateTabAt(tab_index, true); 312 model->ActivateTabAt(tab_index, true);
311 313
312 contents = existing_tab; 314 contents = existing_tab;
313 } else { 315 } else {
(...skipping 13 matching lines...) Expand all
327 if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN && 329 if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN &&
328 !browser->window()->IsFullscreen()) { 330 !browser->window()->IsFullscreen()) {
329 browser->ToggleFullscreenMode(); 331 browser->ToggleFullscreenMode();
330 } 332 }
331 #endif 333 #endif
332 334
333 return contents; 335 return contents;
334 } 336 }
335 337
336 } // namespace application_launch 338 } // namespace application_launch
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/extensions/shell_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698