summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-14 20:20:53 +0000
committerstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-14 20:20:53 +0000
commitd2202e2a3ea471caeab836e7f215bfdc20f23f2f (patch)
treeb0d9d5c692dc7ce84f70ba7252d800d263f8d64c
parent78aa60534d3302169d247727efa2d15e9a7ba938 (diff)
downloadchromium_src-d2202e2a3ea471caeab836e7f215bfdc20f23f2f.zip
chromium_src-d2202e2a3ea471caeab836e7f215bfdc20f23f2f.tar.gz
chromium_src-d2202e2a3ea471caeab836e7f215bfdc20f23f2f.tar.bz2
Replace Browser::AppType with is_trusted_source_
This CL eliminates Browser::AppType and introdices is_trusted_source_ which identifies both primary v1 App windows and system (settings) windows. BUG=342983, 359815 Review URL: https://codereview.chromium.org/227623007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263716 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/api/tabs/tabs_api.cc2
-rw-r--r--chrome/browser/sessions/session_restore.cc12
-rw-r--r--chrome/browser/sessions/session_service.cc12
-rw-r--r--chrome/browser/ui/ash/accelerator_commands_browsertest.cc12
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc12
-rw-r--r--chrome/browser/ui/browser.cc38
-rw-r--r--chrome/browser/ui/browser.h41
-rw-r--r--chrome/browser/ui/browser_commands.cc15
-rw-r--r--chrome/browser/ui/browser_navigator.cc10
-rw-r--r--chrome/browser/ui/browser_navigator.h3
-rw-r--r--chrome/browser/ui/browser_navigator_browsertest.cc33
-rw-r--r--chrome/browser/ui/browser_navigator_browsertest.h2
-rw-r--r--chrome/browser/ui/browser_tab_restore_service_delegate.cc3
-rw-r--r--chrome/browser/ui/chrome_pages.cc15
-rw-r--r--chrome/browser/ui/chrome_pages.h3
-rw-r--r--chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm2
-rw-r--r--chrome/browser/ui/extensions/application_launch.cc19
-rw-r--r--chrome/browser/ui/settings_window_manager.cc1
-rw-r--r--chrome/browser/ui/views/frame/browser_frame_ash.cc2
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc12
-rw-r--r--chrome/test/base/browser_with_test_window_test.cc12
-rw-r--r--chrome/test/base/in_process_browser_test.cc2
22 files changed, 154 insertions, 109 deletions
diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc
index 62a2441..2a53199 100644
--- a/chrome/browser/extensions/api/tabs/tabs_api.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_api.cc
@@ -564,8 +564,8 @@ bool WindowsCreateFunction::RunImpl() {
create_params.initial_bounds = window_bounds;
} else {
create_params = Browser::CreateParams::CreateForApp(
- window_type,
web_app::GenerateApplicationNameFromExtensionId(extension_id),
+ false /* trusted_source */,
window_bounds,
window_profile,
host_desktop_type);
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc
index 84624e8..adfd8f9 100644
--- a/chrome/browser/sessions/session_restore.cc
+++ b/chrome/browser/sessions/session_restore.cc
@@ -1072,8 +1072,16 @@ class SessionRestoreImpl : public content::NotificationObserver {
ui::WindowShowState show_state,
const std::string& app_name) {
Browser::CreateParams params(type, profile_, host_desktop_type_);
- params.app_name = app_name;
- params.initial_bounds = bounds;
+ if (!app_name.empty()) {
+ const bool trusted_source = true; // We only store trusted app windows.
+ params = Browser::CreateParams::CreateForApp(app_name,
+ trusted_source,
+ bounds,
+ profile_,
+ host_desktop_type_);
+ } else {
+ params.initial_bounds = bounds;
+ }
params.initial_show_state = show_state;
params.is_session_restore = true;
return new Browser(params);
diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc
index 703c3df..be2d677 100644
--- a/chrome/browser/sessions/session_service.cc
+++ b/chrome/browser/sessions/session_service.cc
@@ -1574,9 +1574,17 @@ bool SessionService::ShouldTrackChangesToWindow(
}
bool SessionService::ShouldTrackBrowser(Browser* browser) const {
+ if (browser->profile() != profile())
+ return false;
+ // Never track app popup windows that do not have a trusted source (i.e.
+ // popup windows spawned by an app). If this logic changes, be sure to also
+ // change SessionRestoreImpl::CreateRestoredBrowser().
+ if (browser->is_app() && browser->is_type_popup() &&
+ !browser->is_trusted_source()) {
+ return false;
+ }
AppType app_type = browser->is_app() ? TYPE_APP : TYPE_NORMAL;
- return browser->profile() == profile() &&
- should_track_changes_for_browser_type(browser->type(), app_type);
+ return should_track_changes_for_browser_type(browser->type(), app_type);
}
bool SessionService::should_track_changes_for_browser_type(Browser::Type type,
diff --git a/chrome/browser/ui/ash/accelerator_commands_browsertest.cc b/chrome/browser/ui/ash/accelerator_commands_browsertest.cc
index 6d1d00c..77b1ace 100644
--- a/chrome/browser/ui/ash/accelerator_commands_browsertest.cc
+++ b/chrome/browser/ui/ash/accelerator_commands_browsertest.cc
@@ -156,9 +156,12 @@ IN_PROC_BROWSER_TEST_P(AcceleratorCommandsFullscreenBrowserTest,
EXPECT_TRUE(IsInitialShowState(window_state));
// 3) Hosted apps.
- Browser::CreateParams browser_create_params(Browser::TYPE_POPUP,
- browser()->profile(), chrome::HOST_DESKTOP_TYPE_ASH);
- browser_create_params.app_name = "Test";
+ Browser::CreateParams browser_create_params(
+ Browser::CreateParams::CreateForApp("Test",
+ true /* trusted_source */,
+ gfx::Rect(),
+ browser()->profile(),
+ chrome::HOST_DESKTOP_TYPE_ASH));
Browser* app_host_browser = new Browser(browser_create_params);
ASSERT_TRUE(app_host_browser->is_app());
@@ -177,7 +180,8 @@ IN_PROC_BROWSER_TEST_P(AcceleratorCommandsFullscreenBrowserTest,
EXPECT_TRUE(IsInitialShowState(window_state));
// 4) Popup browser windows.
- browser_create_params.app_name = "";
+ browser_create_params = Browser::CreateParams(
+ Browser::TYPE_POPUP, browser()->profile(), chrome::HOST_DESKTOP_TYPE_ASH);
Browser* popup_browser = new Browser(browser_create_params);
ASSERT_TRUE(popup_browser->is_type_popup());
ASSERT_FALSE(popup_browser->is_app());
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc
index aee63e8..fcc11ff 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc
@@ -706,12 +706,12 @@ class V1App : public TestBrowserWindow {
aura::client::ParentWindowWithContext(native_window_.get(),
ash::Shell::GetPrimaryRootWindow(),
gfx::Rect(10, 10, 20, 30));
- Browser::CreateParams params = Browser::CreateParams::CreateForApp(
- Browser::TYPE_POPUP,
- kCrxAppPrefix + app_name,
- gfx::Rect(),
- profile,
- chrome::HOST_DESKTOP_TYPE_ASH);
+ Browser::CreateParams params =
+ Browser::CreateParams::CreateForApp(kCrxAppPrefix + app_name,
+ true /* trusted_source */,
+ gfx::Rect(),
+ profile,
+ chrome::HOST_DESKTOP_TYPE_ASH);
params.window = this;
browser_.reset(new Browser(params));
chrome::AddTabAt(browser_.get(), GURL(), 0, true);
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index b353ff2..d9d4fb1 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -253,7 +253,7 @@ Browser::CreateParams::CreateParams(Profile* profile,
: type(TYPE_TABBED),
profile(profile),
host_desktop_type(host_desktop_type),
- app_type(APP_TYPE_HOST),
+ trusted_source(false),
initial_show_state(ui::SHOW_STATE_DEFAULT),
is_session_restore(false),
window(NULL) {
@@ -265,7 +265,7 @@ Browser::CreateParams::CreateParams(Type type,
: type(type),
profile(profile),
host_desktop_type(host_desktop_type),
- app_type(APP_TYPE_HOST),
+ trusted_source(false),
initial_show_state(ui::SHOW_STATE_DEFAULT),
is_session_restore(false),
window(NULL) {
@@ -273,17 +273,16 @@ Browser::CreateParams::CreateParams(Type type,
// static
Browser::CreateParams Browser::CreateParams::CreateForApp(
- Type type,
const std::string& app_name,
+ bool trusted_source,
const gfx::Rect& window_bounds,
Profile* profile,
chrome::HostDesktopType host_desktop_type) {
- DCHECK(type != TYPE_TABBED);
DCHECK(!app_name.empty());
- CreateParams params(type, profile, host_desktop_type);
+ CreateParams params(TYPE_POPUP, profile, host_desktop_type);
params.app_name = app_name;
- params.app_type = APP_TYPE_CHILD;
+ params.trusted_source = trusted_source;
params.initial_bounds = window_bounds;
return params;
@@ -295,6 +294,7 @@ Browser::CreateParams Browser::CreateParams::CreateForDevTools(
chrome::HostDesktopType host_desktop_type) {
CreateParams params(TYPE_POPUP, profile, host_desktop_type);
params.app_name = DevToolsWindow::kDevToolsApp;
+ params.trusted_source = true;
return params;
}
@@ -335,7 +335,7 @@ Browser::Browser(const CreateParams& params)
tab_strip_model_(new TabStripModel(tab_strip_model_delegate_.get(),
params.profile)),
app_name_(params.app_name),
- app_type_(params.app_type),
+ is_trusted_source_(params.trusted_source),
cancel_download_confirmation_state_(NOT_PROMPTED),
override_bounds_(params.initial_bounds),
initial_show_state_(params.initial_show_state),
@@ -2235,22 +2235,24 @@ void Browser::TabDetachedAtImpl(content::WebContents* contents,
}
bool Browser::ShouldShowLocationBar() const {
- if (!is_app()) {
- // Hide the URL for singleton settings windows.
- // TODO(stevenjb): We could avoid this check by setting a Browser
- // property for "system" windows, possibly shared with hosted app windows.
- // crbug.com/350128.
- if (chrome::IsSettingsWindow(this))
- return false;
+ // Tabbed browser always show a location bar.
+ if (is_type_tabbed())
+ return true;
+
+ // Trusted app windows and system windows never show a location bar.
+ if (is_trusted_source())
+ return false;
+
+ // Other non-app browsers always show a location bar.
+ if (!is_app())
return true;
- }
// Normally apps do not show a location bar.
- if (app_type() != APP_TYPE_HOST ||
- app_name() == DevToolsWindow::kDevToolsApp ||
+ if (app_name() == DevToolsWindow::kDevToolsApp ||
!CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableStreamlinedHostedApps))
+ switches::kEnableStreamlinedHostedApps)) {
return false;
+ }
// If kEnableStreamlinedHostedApps is true, show the locaiton bar for non
// legacy packaged apps.
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index ccb83b9..f1c2cac 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -116,14 +116,6 @@ class Browser : public TabStripModelObserver,
TYPE_POPUP = 2
};
- // Distinguishes between browsers that host an app (opened from
- // ApplicationLauncher::OpenApplication), and child browsers created by an app
- // from Browser::CreateForApp (e.g. by windows.open or the extension API).
- enum AppType {
- APP_TYPE_HOST = 1,
- APP_TYPE_CHILD = 2
- };
-
// Possible elements of the Browser window.
enum WindowFeature {
FEATURE_NONE = 0,
@@ -157,8 +149,8 @@ class Browser : public TabStripModelObserver,
Profile* profile,
chrome::HostDesktopType host_desktop_type);
- static CreateParams CreateForApp(Type type,
- const std::string& app_name,
+ static CreateParams CreateForApp(const std::string& app_name,
+ bool trusted_source,
const gfx::Rect& window_bounds,
Profile* profile,
chrome::HostDesktopType host_desktop_type);
@@ -176,14 +168,8 @@ class Browser : public TabStripModelObserver,
// The host desktop the browser is created on.
chrome::HostDesktopType host_desktop_type;
- // The application name that is also the name of the window to the shell.
- // This name should be set when:
- // 1) we launch an application via an application shortcut or extension API.
- // 2) we launch an undocked devtool window.
- std::string app_name;
-
- // Type of app (host or child). See description of AppType.
- AppType app_type;
+ // Specifies the browser is_trusted_source_ value.
+ bool trusted_source;
// The bounds of the window to open.
gfx::Rect initial_bounds;
@@ -195,6 +181,17 @@ class Browser : public TabStripModelObserver,
// Supply a custom BrowserWindow implementation, to be used instead of the
// default. Intended for testing.
BrowserWindow* window;
+
+ private:
+ friend class Browser;
+
+ // The application name that is also the name of the window to the shell.
+ // Do not set this value directly, use CreateForApp.
+ // This name will be set for:
+ // 1) v1 applications launched via an application shortcut or extension API.
+ // 2) undocked devtool windows.
+ // 3) popup windows spawned from v1 applications.
+ std::string app_name;
};
// Constructors, Creation, Showing //////////////////////////////////////////
@@ -231,7 +228,7 @@ class Browser : public TabStripModelObserver,
Type type() const { return type_; }
const std::string& app_name() const { return app_name_; }
- AppType app_type() const { return app_type_; }
+ bool is_trusted_source() const { return is_trusted_source_; }
Profile* profile() const { return profile_; }
gfx::Rect override_bounds() const { return override_bounds_; }
@@ -828,8 +825,10 @@ class Browser : public TabStripModelObserver,
// 2) we launch an undocked devtool window.
std::string app_name_;
- // Type of app (host or child). See description of AppType.
- AppType app_type_;
+ // True if the source is trusted (i.e. we do not need to show the URL in a
+ // a popup window). Also used to determine which app windows to save and
+ // restore on Chrome OS.
+ bool is_trusted_source_;
// Unique identifier of this browser for session restore. This id is only
// unique within the current session, and is not guaranteed to be unique
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc
index d132c4c..27c6269 100644
--- a/chrome/browser/ui/browser_commands.cc
+++ b/chrome/browser/ui/browser_commands.cc
@@ -662,11 +662,10 @@ WebContents* DuplicateTabAt(Browser* browser, int index) {
index + 1, contents_dupe, add_types);
} else {
Browser* new_browser = NULL;
- if (browser->is_app() &&
- !browser->is_type_popup()) {
+ if (browser->is_app() && !browser->is_type_popup()) {
new_browser = new Browser(
- Browser::CreateParams::CreateForApp(browser->type(),
- browser->app_name(),
+ Browser::CreateParams::CreateForApp(browser->app_name(),
+ browser->is_trusted_source(),
gfx::Rect(),
browser->profile(),
browser->host_desktop_type()));
@@ -1261,9 +1260,11 @@ void ConvertTabToAppWindow(Browser* browser,
browser->tab_strip_model()->DetachWebContentsAt(index);
Browser* app_browser = new Browser(
- Browser::CreateParams::CreateForApp(
- Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile(),
- browser->host_desktop_type()));
+ Browser::CreateParams::CreateForApp(app_name,
+ true /* trusted_source */,
+ gfx::Rect(),
+ browser->profile(),
+ browser->host_desktop_type()));
app_browser->tab_strip_model()->AppendWebContents(contents, true);
contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc
index 3b6f66e..473a0dd 100644
--- a/chrome/browser/ui/browser_navigator.cc
+++ b/chrome/browser/ui/browser_navigator.cc
@@ -167,12 +167,16 @@ Browser* GetBrowserForDisposition(chrome::NavigateParams* params) {
if (app_name.empty()) {
Browser::CreateParams browser_params(
Browser::TYPE_POPUP, profile, params->host_desktop_type);
+ browser_params.trusted_source = params->trusted_source;
browser_params.initial_bounds = params->window_bounds;
return new Browser(browser_params);
}
return new Browser(Browser::CreateParams::CreateForApp(
- Browser::TYPE_POPUP, app_name, params->window_bounds, profile,
+ app_name,
+ params->trusted_source,
+ params->window_bounds,
+ profile,
params->host_desktop_type));
}
case NEW_WINDOW: {
@@ -398,6 +402,7 @@ NavigateParams::NavigateParams(Browser* a_browser,
target_contents(NULL),
source_contents(NULL),
disposition(CURRENT_TAB),
+ trusted_source(false),
transition(a_transition),
is_renderer_initiated(false),
tabstrip_index(-1),
@@ -420,6 +425,7 @@ NavigateParams::NavigateParams(Browser* a_browser,
target_contents(a_target_contents),
source_contents(NULL),
disposition(CURRENT_TAB),
+ trusted_source(false),
transition(content::PAGE_TRANSITION_LINK),
is_renderer_initiated(false),
tabstrip_index(-1),
@@ -444,6 +450,7 @@ NavigateParams::NavigateParams(Profile* a_profile,
target_contents(NULL),
source_contents(NULL),
disposition(NEW_FOREGROUND_TAB),
+ trusted_source(false),
transition(a_transition),
is_renderer_initiated(false),
tabstrip_index(-1),
@@ -468,6 +475,7 @@ void FillNavigateParamsFromOpenURLParams(chrome::NavigateParams* nav_params,
nav_params->redirect_chain = params.redirect_chain;
nav_params->extra_headers = params.extra_headers;
nav_params->disposition = params.disposition;
+ nav_params->trusted_source = false;
nav_params->is_renderer_initiated = params.is_renderer_initiated;
nav_params->transferred_global_request_id =
params.transferred_global_request_id;
diff --git a/chrome/browser/ui/browser_navigator.h b/chrome/browser/ui/browser_navigator.h
index 140ef6c..5cb200f 100644
--- a/chrome/browser/ui/browser_navigator.h
+++ b/chrome/browser/ui/browser_navigator.h
@@ -125,6 +125,9 @@ struct NavigateParams {
// |tabstrip_add_types|.
WindowOpenDisposition disposition;
+ // Sets browser->is_trusted_source. Default is false.
+ bool trusted_source;
+
// The transition type of the navigation. Default is
// content::PAGE_TRANSITION_LINK when target_contents is specified in the
// constructor.
diff --git a/chrome/browser/ui/browser_navigator_browsertest.cc b/chrome/browser/ui/browser_navigator_browsertest.cc
index 434001c..9a8e237 100644
--- a/chrome/browser/ui/browser_navigator_browsertest.cc
+++ b/chrome/browser/ui/browser_navigator_browsertest.cc
@@ -116,11 +116,10 @@ Browser* BrowserNavigatorTest::CreateEmptyBrowserForType(Browser::Type type,
return browser;
}
-Browser* BrowserNavigatorTest::CreateEmptyBrowserForApp(Browser::Type type,
- Profile* profile) {
+Browser* BrowserNavigatorTest::CreateEmptyBrowserForApp(Profile* profile) {
Browser* browser = new Browser(
Browser::CreateParams::CreateForApp(
- Browser::TYPE_POPUP, "Test", gfx::Rect(), profile,
+ "Test", false /* trusted_source */, gfx::Rect(), profile,
chrome::GetActiveDesktop()));
chrome::AddTabAt(browser, GURL(), -1, true);
return browser;
@@ -512,11 +511,10 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromPopup) {
}
// This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
-// from an app frame results in a new Browser with TYPE_APP_POPUP.
+// from an app frame results in a new Browser with TYPE_POPUP.
IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
Disposition_NewPopupFromAppWindow) {
- Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED,
- browser()->profile());
+ Browser* app_browser = CreateEmptyBrowserForApp(browser()->profile());
chrome::NavigateParams p(MakeNavigateParams(app_browser));
p.disposition = NEW_POPUP;
p.window_bounds = gfx::Rect(0, 0, 200, 200);
@@ -537,11 +535,10 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
}
// This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
-// from an app popup results in a new Browser also of TYPE_APP_POPUP.
+// from an app popup results in a new Browser also of TYPE_POPUP.
IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
Disposition_NewPopupFromAppPopup) {
- Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED,
- browser()->profile());
+ Browser* app_browser = CreateEmptyBrowserForApp(browser()->profile());
// Open an app popup.
chrome::NavigateParams p1(MakeNavigateParams(app_browser));
p1.disposition = NEW_POPUP;
@@ -594,6 +591,24 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupUnfocused) {
#endif
}
+// This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
+// and trusted_source = true results in a new Browser where is_trusted_source()
+// is true.
+IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupTrusted) {
+ chrome::NavigateParams p(MakeNavigateParams());
+ p.disposition = NEW_POPUP;
+ p.trusted_source = true;
+ p.window_bounds = gfx::Rect(0, 0, 200, 200);
+ // Wait for new popup to to load and gain focus.
+ ui_test_utils::NavigateToURL(&p);
+
+ // Navigate() should have opened a new popup window of TYPE_TRUSTED_POPUP.
+ EXPECT_NE(browser(), p.browser);
+ EXPECT_TRUE(p.browser->is_type_popup());
+ EXPECT_TRUE(p.browser->is_trusted_source());
+}
+
+
// This test verifies that navigating with WindowOpenDisposition = NEW_WINDOW
// always opens a new window.
IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewWindow) {
diff --git a/chrome/browser/ui/browser_navigator_browsertest.h b/chrome/browser/ui/browser_navigator_browsertest.h
index 45f507e..7821c89 100644
--- a/chrome/browser/ui/browser_navigator_browsertest.h
+++ b/chrome/browser/ui/browser_navigator_browsertest.h
@@ -31,7 +31,7 @@ class BrowserNavigatorTest : public InProcessBrowserTest,
chrome::NavigateParams MakeNavigateParams(Browser* browser) const;
Browser* CreateEmptyBrowserForType(Browser::Type type, Profile* profile);
- Browser* CreateEmptyBrowserForApp(Browser::Type type, Profile* profile);
+ Browser* CreateEmptyBrowserForApp(Profile* profile);
content::WebContents* CreateWebContents();
diff --git a/chrome/browser/ui/browser_tab_restore_service_delegate.cc b/chrome/browser/ui/browser_tab_restore_service_delegate.cc
index df6c9b5..75e1c24 100644
--- a/chrome/browser/ui/browser_tab_restore_service_delegate.cc
+++ b/chrome/browser/ui/browser_tab_restore_service_delegate.cc
@@ -92,9 +92,10 @@ TabRestoreServiceDelegate* TabRestoreServiceDelegate::Create(
if (app_name.empty()) {
browser = new Browser(Browser::CreateParams(profile, host_desktop_type));
} else {
+ // Only trusted app popup windows should ever be restored.
browser = new Browser(
Browser::CreateParams::CreateForApp(
- Browser::TYPE_POPUP, app_name, gfx::Rect(), profile,
+ app_name, true /* trusted_source */, gfx::Rect(), profile,
host_desktop_type));
}
if (browser)
diff --git a/chrome/browser/ui/chrome_pages.cc b/chrome/browser/ui/chrome_pages.cc
index 4c8aa34..bb713e8 100644
--- a/chrome/browser/ui/chrome_pages.cc
+++ b/chrome/browser/ui/chrome_pages.cc
@@ -212,21 +212,6 @@ GURL GetSettingsUrl(const std::string& sub_page) {
return GURL(url);
}
-bool IsSettingsWindow(const Browser* browser) {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableSettingsWindow))
- return false;
- if (browser->is_type_tabbed())
- return false;
- const content::WebContents* web_contents =
- browser->tab_strip_model()->GetWebContentsAt(0);
- if (!web_contents)
- return false;
- GURL url(web_contents->GetURL());
- return (url.SchemeIs(content::kChromeUIScheme) &&
- url.spec().find(chrome::kChromeUISettingsURL) == 0);
-}
-
void ShowSettings(Browser* browser) {
ShowSettingsSubPage(browser, std::string());
}
diff --git a/chrome/browser/ui/chrome_pages.h b/chrome/browser/ui/chrome_pages.h
index d780520..0214132 100644
--- a/chrome/browser/ui/chrome_pages.h
+++ b/chrome/browser/ui/chrome_pages.h
@@ -57,9 +57,6 @@ void ShowSlow(Browser* browser);
// Constructs a settings GURL for the specified |sub_page|.
GURL GetSettingsUrl(const std::string& sub_page);
-// Returns true if |browser| is a popup window containing a settings page.
-bool IsSettingsWindow(const Browser* browser);
-
// Various things that open in a settings UI.
void ShowSettings(Browser* browser);
void ShowSettingsSubPage(Browser* browser, const std::string& sub_page);
diff --git a/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm b/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm
index 12bdcb9..41fe5cb 100644
--- a/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm
+++ b/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm
@@ -28,7 +28,7 @@ IN_PROC_BROWSER_TEST_F(BrowserCrApplicationAppleScriptTest, Creation) {
browser()->host_desktop_type()));
Browser* b2 = new Browser(
Browser::CreateParams::CreateForApp(
- Browser::TYPE_POPUP, "Test", gfx::Rect(), profile,
+ "Test", true /* trusted_source */, gfx::Rect(), profile,
browser()->host_desktop_type()));
EXPECT_EQ(3U, [[NSApp appleScriptWindows] count]);
diff --git a/chrome/browser/ui/extensions/application_launch.cc b/chrome/browser/ui/extensions/application_launch.cc
index beb23cd..fc131d5 100644
--- a/chrome/browser/ui/extensions/application_launch.cc
+++ b/chrome/browser/ui/extensions/application_launch.cc
@@ -190,22 +190,27 @@ WebContents* OpenApplicationWindow(const AppLaunchParams& params) {
DCHECK(!url_input.is_empty() || extension);
GURL url = UrlForExtension(extension, url_input);
- Browser::CreateParams browser_params(
- Browser::TYPE_POPUP, profile, params.desktop_type);
-
- browser_params.app_name = extension ?
+ std::string app_name = extension ?
web_app::GenerateApplicationNameFromExtensionId(extension->id()) :
web_app::GenerateApplicationNameFromURL(url);
+ gfx::Rect initial_bounds;
if (!params.override_bounds.IsEmpty()) {
- browser_params.initial_bounds = params.override_bounds;
+ initial_bounds = params.override_bounds;
} else if (extension) {
- browser_params.initial_bounds.set_width(
+ initial_bounds.set_width(
extensions::AppLaunchInfo::GetLaunchWidth(extension));
- browser_params.initial_bounds.set_height(
+ initial_bounds.set_height(
extensions::AppLaunchInfo::GetLaunchHeight(extension));
}
+ Browser::CreateParams browser_params(
+ Browser::CreateParams::CreateForApp(app_name,
+ true /* trusted_source */,
+ initial_bounds,
+ profile,
+ params.desktop_type));
+
browser_params.initial_show_state = DetermineWindowShowState(profile,
params.container,
extension);
diff --git a/chrome/browser/ui/settings_window_manager.cc b/chrome/browser/ui/settings_window_manager.cc
index f2a93ad..5c8f345 100644
--- a/chrome/browser/ui/settings_window_manager.cc
+++ b/chrome/browser/ui/settings_window_manager.cc
@@ -48,6 +48,7 @@ void SettingsWindowManager::ShowForProfile(Profile* profile,
// No existing browser window, create one.
NavigateParams params(profile, gurl, content::PAGE_TRANSITION_AUTO_BOOKMARK);
params.disposition = NEW_POPUP;
+ params.trusted_source = true;
params.window_action = NavigateParams::SHOW_WINDOW;
params.user_gesture = true;
params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE;
diff --git a/chrome/browser/ui/views/frame/browser_frame_ash.cc b/chrome/browser/ui/views/frame/browser_frame_ash.cc
index 3346bd0..5cd1ac0 100644
--- a/chrome/browser/ui/views/frame/browser_frame_ash.cc
+++ b/chrome/browser/ui/views/frame/browser_frame_ash.cc
@@ -123,7 +123,7 @@ BrowserFrameAsh::~BrowserFrameAsh() {
// BrowserFrameAsh, private:
void BrowserFrameAsh::SetWindowAutoManaged() {
- if (browser_view_->browser()->type() != Browser::TYPE_POPUP ||
+ if (!browser_view_->browser()->is_type_popup() ||
browser_view_->browser()->is_app()) {
ash::wm::GetWindowState(GetNativeWindow())->
set_window_position_managed(true);
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 7bca2bc..0430823 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -1590,7 +1590,8 @@ bool BrowserView::ShouldShowWindowTitle() const {
// For Ash only, app host windows do not show an icon, crbug.com/119411.
// Child windows (i.e. popups) do show an icon.
if (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH &&
- browser_->is_app() && browser_->app_type() == Browser::APP_TYPE_HOST)
+ browser_->is_app() &&
+ browser_->is_trusted_source())
return false;
return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR);
@@ -1619,7 +1620,8 @@ bool BrowserView::ShouldShowWindowIcon() const {
// For Ash only, app host windows do not show an icon, crbug.com/119411.
// Child windows (i.e. popups) do show an icon.
if (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH &&
- browser_->is_app() && browser_->app_type() == Browser::APP_TYPE_HOST)
+ browser_->is_app() &&
+ browser_->is_trusted_source())
return false;
return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR);
@@ -1679,9 +1681,9 @@ bool BrowserView::GetSavedWindowPlacement(
if (browser_->is_type_popup() &&
!browser_->is_app() &&
- !browser_->is_devtools()) {
- // This is non-app popup window. The value passed in |bounds| represents
- // two pieces of information:
+ !browser_->is_trusted_source()) {
+ // This is normal non-app popup window. The value passed in |bounds|
+ // represents two pieces of information:
// - the position of the window, in screen coordinates (outer position).
// - the size of the content area (inner size).
// We need to use these values to determine the appropriate size and
diff --git a/chrome/test/base/browser_with_test_window_test.cc b/chrome/test/base/browser_with_test_window_test.cc
index 47d682b..c45f7fa 100644
--- a/chrome/test/base/browser_with_test_window_test.cc
+++ b/chrome/test/base/browser_with_test_window_test.cc
@@ -226,10 +226,16 @@ Browser* BrowserWithTestWindowTest::CreateBrowser(
chrome::HostDesktopType host_desktop_type,
BrowserWindow* browser_window) {
Browser::CreateParams params(profile, host_desktop_type);
- params.type = browser_type;
+ if (hosted_app) {
+ params = Browser::CreateParams::CreateForApp("Test",
+ true /* trusted_source */,
+ gfx::Rect(),
+ profile,
+ host_desktop_type);
+ } else {
+ params.type = browser_type;
+ }
params.window = browser_window;
- if (hosted_app)
- params.app_name = "Test";
return new Browser(params);
}
diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc
index 67555ed..b8b3efd 100644
--- a/chrome/test/base/in_process_browser_test.cc
+++ b/chrome/test/base/in_process_browser_test.cc
@@ -325,7 +325,7 @@ Browser* InProcessBrowserTest::CreateBrowserForApp(
Profile* profile) {
Browser* browser = new Browser(
Browser::CreateParams::CreateForApp(
- Browser::TYPE_POPUP, app_name, gfx::Rect(), profile,
+ app_name, false /* trusted_source */, gfx::Rect(), profile,
chrome::GetActiveDesktop()));
AddBlankTabAndShow(browser);
return browser;