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

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

Issue 10917026: Switch Extensions::TabHelper to use WebContents, WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 8 years, 3 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/browser_commands.cc ('k') | chrome/browser/ui/browser_tabrestore.cc » ('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/browser_navigator.h" 5 #include "chrome/browser/ui/browser_navigator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return GetOrCreateBrowser(profile); 125 return GetOrCreateBrowser(profile);
126 case NEW_POPUP: { 126 case NEW_POPUP: {
127 // Make a new popup window. 127 // Make a new popup window.
128 // Coerce app-style if |source| represents an app. 128 // Coerce app-style if |source| represents an app.
129 std::string app_name; 129 std::string app_name;
130 if (!params->extension_app_id.empty()) { 130 if (!params->extension_app_id.empty()) {
131 app_name = web_app::GenerateApplicationNameFromExtensionId( 131 app_name = web_app::GenerateApplicationNameFromExtensionId(
132 params->extension_app_id); 132 params->extension_app_id);
133 } else if (!params->browser->app_name().empty()) { 133 } else if (!params->browser->app_name().empty()) {
134 app_name = params->browser->app_name(); 134 app_name = params->browser->app_name();
135 } else if (params->source_contents && 135 } else if (params->source_contents) {
136 params->source_contents->extension_tab_helper()->is_app()) { 136 extensions::TabHelper* extensions_tab_helper =
137 app_name = web_app::GenerateApplicationNameFromExtensionId( 137 extensions::TabHelper::FromWebContents(
138 params->source_contents->extension_tab_helper()-> 138 params->source_contents->web_contents());
139 extension_app()->id()); 139 if (extensions_tab_helper->is_app()) {
140 app_name = web_app::GenerateApplicationNameFromExtensionId(
141 extensions_tab_helper->extension_app()->id());
142 }
140 } 143 }
141 if (app_name.empty()) { 144 if (app_name.empty()) {
142 Browser::CreateParams browser_params(Browser::TYPE_POPUP, profile); 145 Browser::CreateParams browser_params(Browser::TYPE_POPUP, profile);
143 browser_params.initial_bounds = params->window_bounds; 146 browser_params.initial_bounds = params->window_bounds;
144 return new Browser(browser_params); 147 return new Browser(browser_params);
145 } 148 }
146 149
147 return new Browser(Browser::CreateParams::CreateForApp( 150 return new Browser(Browser::CreateParams::CreateForApp(
148 Browser::TYPE_POPUP, app_name, params->window_bounds, profile)); 151 Browser::TYPE_POPUP, app_name, params->window_bounds, profile));
149 } 152 }
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 params->target_contents = 480 params->target_contents =
478 chrome::TabContentsFactory( 481 chrome::TabContentsFactory(
479 params->browser->profile(), 482 params->browser->profile(),
480 tab_util::GetSiteInstanceForNewTab( 483 tab_util::GetSiteInstanceForNewTab(
481 params->browser->profile(), url), 484 params->browser->profile(), url),
482 MSG_ROUTING_NONE, 485 MSG_ROUTING_NONE,
483 source_contents); 486 source_contents);
484 // This function takes ownership of |params->target_contents| until it 487 // This function takes ownership of |params->target_contents| until it
485 // is added to a TabStripModel. 488 // is added to a TabStripModel.
486 target_contents_owner.TakeOwnership(); 489 target_contents_owner.TakeOwnership();
487 params->target_contents->extension_tab_helper()-> 490 extensions::TabHelper::FromWebContents(
488 SetExtensionAppById(params->extension_app_id); 491 params->target_contents->web_contents())->
492 SetExtensionAppById(params->extension_app_id);
489 // TODO(sky): figure out why this is needed. Without it we seem to get 493 // TODO(sky): figure out why this is needed. Without it we seem to get
490 // failures in startup tests. 494 // failures in startup tests.
491 // By default, content believes it is not hidden. When adding contents 495 // By default, content believes it is not hidden. When adding contents
492 // in the background, tell it that it's hidden. 496 // in the background, tell it that it's hidden.
493 if ((params->tabstrip_add_types & TabStripModel::ADD_ACTIVE) == 0) { 497 if ((params->tabstrip_add_types & TabStripModel::ADD_ACTIVE) == 0) {
494 // TabStripModel::AddTabContents invokes WasHidden if not foreground. 498 // TabStripModel::AddTabContents invokes WasHidden if not foreground.
495 params->target_contents->web_contents()->WasHidden(); 499 params->target_contents->web_contents()->WasHidden();
496 } 500 }
497 } else { 501 } else {
498 // ... otherwise if we're loading in the current tab, the target is the 502 // ... otherwise if we're loading in the current tab, the target is the
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 return !(url.scheme() == chrome::kChromeUIScheme && 595 return !(url.scheme() == chrome::kChromeUIScheme &&
592 (url.host() == chrome::kChromeUISettingsHost || 596 (url.host() == chrome::kChromeUISettingsHost ||
593 url.host() == chrome::kChromeUISettingsFrameHost || 597 url.host() == chrome::kChromeUISettingsFrameHost ||
594 url.host() == chrome::kChromeUIExtensionsHost || 598 url.host() == chrome::kChromeUIExtensionsHost ||
595 url.host() == chrome::kChromeUIBookmarksHost || 599 url.host() == chrome::kChromeUIBookmarksHost ||
596 url.host() == chrome::kChromeUISyncPromoHost || 600 url.host() == chrome::kChromeUISyncPromoHost ||
597 url.host() == chrome::kChromeUIUberHost)); 601 url.host() == chrome::kChromeUIUberHost));
598 } 602 }
599 603
600 } // namespace chrome 604 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_commands.cc ('k') | chrome/browser/ui/browser_tabrestore.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698