summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
authorjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-05 20:35:14 +0000
committerjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-05 20:35:14 +0000
commitb35b26b360b5d84d064d63440590902d4974b59d (patch)
treef0aa8b0b32ca80ad7eb5efc1f78a5dcd45899b13 /chrome/browser/ui
parent4d9160ff743804acf89a5a50a0b43c113aecc1ab (diff)
downloadchromium_src-b35b26b360b5d84d064d63440590902d4974b59d.zip
chromium_src-b35b26b360b5d84d064d63440590902d4974b59d.tar.gz
chromium_src-b35b26b360b5d84d064d63440590902d4974b59d.tar.bz2
Browser::Type cleanup.
BUG=None TEST=Existing tests R=ben@chromium.org,stevenjb@chromium.org,phajdan.jr@chromium.org Review URL: http://codereview.chromium.org/6697032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84303 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/browser.cc227
-rw-r--r--chrome/browser/ui/browser.h67
-rw-r--r--chrome/browser/ui/browser_init.cc2
-rw-r--r--chrome/browser/ui/browser_init_browsertest.cc16
-rw-r--r--chrome/browser/ui/browser_list.cc85
-rw-r--r--chrome/browser/ui/browser_list.h19
-rw-r--r--chrome/browser/ui/browser_list_unittest.cc10
-rw-r--r--chrome/browser/ui/browser_navigator.cc37
-rw-r--r--chrome/browser/ui/browser_navigator_browsertest.cc42
-rw-r--r--chrome/browser/ui/browser_navigator_browsertest.h1
-rw-r--r--chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm9
-rw-r--r--chrome/browser/ui/cocoa/browser_test_helper.cc2
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller.h4
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller.mm17
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_unittest.mm6
-rw-r--r--chrome/browser/ui/cocoa/extensions/extension_popup_controller_unittest.mm2
-rw-r--r--chrome/browser/ui/cocoa/framed_browser_window_unittest.mm2
-rw-r--r--chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm2
-rw-r--r--chrome/browser/ui/cocoa/notifications/balloon_controller_unittest.mm2
-rw-r--r--chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc2
-rw-r--r--chrome/browser/ui/gtk/browser_titlebar.cc22
-rw-r--r--chrome/browser/ui/gtk/browser_toolbar_gtk.cc2
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.cc23
-rw-r--r--chrome/browser/ui/gtk/gtk_util.cc6
-rw-r--r--chrome/browser/ui/gtk/location_bar_view_gtk.cc2
-rw-r--r--chrome/browser/ui/panels/panel_browser_window_gtk_browsertest.cc8
-rw-r--r--chrome/browser/ui/panels/panel_browsertest.cc6
-rw-r--r--chrome/browser/ui/tests/browser_uitest.cc56
-rw-r--r--chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc2
-rw-r--r--chrome/browser/ui/touch/frame/browser_non_client_frame_view_factory_touch.cc5
-rw-r--r--chrome/browser/ui/views/extensions/extension_install_dialog_view.cc6
-rw-r--r--chrome/browser/ui/views/file_manager_dialogs.cc2
-rw-r--r--chrome/browser/ui/views/frame/browser_frame_win.cc2
-rw-r--r--chrome/browser/ui/views/frame/browser_non_client_frame_view_factory_gtk.cc4
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc22
-rw-r--r--chrome/browser/ui/views/frame/browser_view.h18
-rw-r--r--chrome/browser/ui/views/frame/opaque_browser_frame_view.cc2
-rw-r--r--chrome/browser/ui/webui/active_downloads_ui.cc9
-rw-r--r--chrome/browser/ui/webui/mediaplayer_browsertest.cc4
-rw-r--r--chrome/browser/ui/webui/mediaplayer_ui.cc13
-rw-r--r--chrome/browser/ui/window_sizer.cc2
41 files changed, 424 insertions, 346 deletions
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 1545c27..194acff 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -193,6 +193,14 @@ const char kHashMark[] = "#";
extern bool g_log_bug53991;
+////////////////////////////////////////////////////////////////////////////////
+// Browser, CreateParams:
+
+Browser::CreateParams::CreateParams(Type type, Profile* profile)
+ : type(type),
+ profile(profile) {
+}
+
///////////////////////////////////////////////////////////////////////////////
// Browser, Constructors, Creation, Showing:
@@ -337,54 +345,59 @@ Browser::~Browser() {
// static
Browser* Browser::Create(Profile* profile) {
- Browser* browser = new Browser(TYPE_NORMAL, profile);
+ Browser* browser = new Browser(TYPE_TABBED, profile);
browser->InitBrowserWindow();
return browser;
}
// static
-Browser* Browser::CreateForType(Type type, Profile* profile) {
- Browser* browser = new Browser(type, profile);
+Browser* Browser::CreateWithParams(const CreateParams& params) {
+ Browser* browser = new Browser(params.type, params.profile);
+ browser->app_name_ = params.app_name;
+ if (!params.initial_bounds.IsEmpty())
+ browser->set_override_bounds(params.initial_bounds);
browser->InitBrowserWindow();
return browser;
}
// static
-Browser* Browser::CreateForApp(const std::string& app_name,
- const gfx::Size& window_size,
- Profile* profile,
- bool is_panel) {
- Browser::Type type = TYPE_APP;
+Browser* Browser::CreateForType(Type type, Profile* profile) {
+ CreateParams params(type, profile);
+ return CreateWithParams(params);
+}
- if (is_panel) {
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePanels)) {
- type = TYPE_APP_PANEL;
- } else {
- // TYPE_APP_PANEL is the logical choice. However, the panel UI
- // is not fully implemented. See crbug/55943.
- type = TYPE_APP_POPUP;
- }
- }
+// static
+Browser* Browser::CreateForApp(Type type,
+ const std::string& app_name,
+ const gfx::Size& window_size,
+ Profile* profile) {
+ DCHECK(type != TYPE_TABBED);
+ DCHECK(!app_name.empty());
- Browser* browser = new Browser(type, profile);
- browser->app_name_ = app_name;
+ RegisterAppPrefs(app_name, profile);
- if (!window_size.IsEmpty()) {
- gfx::Rect initial_pos(window_size);
- browser->set_override_bounds(initial_pos);
+#if !defined(OS_CHROMEOS)
+ if (type == TYPE_PANEL &&
+ !CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePanels)) {
+ // The panel UI is not fully implemented, so we default to TYPE_POPUP when
+ // the panel switch is not enabled. See crbug/55943.
+ type = TYPE_POPUP;
}
+#endif
- browser->InitBrowserWindow();
+ CreateParams params(type, profile);
+ params.app_name = app_name;
+ if (!window_size.IsEmpty())
+ params.initial_bounds.set_size(window_size);
- return browser;
+ return CreateWithParams(params);
}
// static
Browser* Browser::CreateForDevTools(Profile* profile) {
- Browser* browser = new Browser(TYPE_DEVTOOLS, profile);
- browser->app_name_ = DevToolsWindow::kDevToolsApp;
- browser->InitBrowserWindow();
- return browser;
+ CreateParams params(TYPE_POPUP, profile);
+ params.app_name = DevToolsWindow::kDevToolsApp;
+ return CreateWithParams(params);
}
void Browser::InitBrowserWindow() {
@@ -401,7 +414,7 @@ void Browser::InitBrowserWindow() {
// Set the app user model id for this application to that of the application
// name. See http://crbug.com/7028.
app::win::SetAppIdForWindow(
- type_ & TYPE_APP ?
+ is_app() ?
ShellIntegration::GetAppId(UTF8ToWide(app_name_), profile_->GetPath()) :
ShellIntegration::GetChromiumAppId(profile_->GetPath()),
window()->GetNativeHandle());
@@ -472,6 +485,14 @@ bool Browser::HasFindBarController() const {
return find_bar_controller_.get() != NULL;
}
+bool Browser::is_app() const {
+ return !app_name_.empty();
+}
+
+bool Browser::is_devtools() const {
+ return app_name_ == DevToolsWindow::kDevToolsApp;
+}
+
///////////////////////////////////////////////////////////////////////////////
// Browser, Creation Helpers:
@@ -550,17 +571,16 @@ TabContents* Browser::OpenApplicationWindow(
else
app_name = web_app::GenerateApplicationNameFromURL(url);
- RegisterAppPrefs(app_name, profile);
-
- bool as_panel = extension && (container == extension_misc::LAUNCH_PANEL);
+ Type type = extension && (container == extension_misc::LAUNCH_PANEL) ?
+ TYPE_PANEL : TYPE_POPUP;
gfx::Size window_size;
if (extension)
window_size.SetSize(extension->launch_width(),
extension->launch_height());
- Browser* browser = Browser::CreateForApp(app_name, window_size, profile,
- as_panel);
+ Browser* browser = Browser::CreateForApp(type, app_name, window_size,
+ profile);
if (app_browser)
*app_browser = browser;
@@ -608,8 +628,7 @@ TabContents* Browser::OpenAppShortcutWindow(Profile* profile,
TabContents* Browser::OpenApplicationTab(Profile* profile,
const Extension* extension,
TabContents* existing_tab) {
- Browser* browser =
- BrowserList::FindBrowserWithType(profile, Browser::TYPE_NORMAL, false);
+ Browser* browser = BrowserList::FindTabbedBrowser(profile, false);
TabContents* contents = NULL;
if (!browser)
return contents;
@@ -761,8 +780,18 @@ std::string Browser::GetWindowPlacementKey() const {
}
bool Browser::ShouldSaveWindowPlacement() const {
- // Only save the window placement of popups if they are restored.
- return (type() & TYPE_POPUP) == 0 || browser_defaults::kRestorePopups;
+ switch (type_) {
+ case TYPE_TABBED:
+ return true;
+ case TYPE_POPUP:
+ // Only save the window placement of popups if they are restored.
+ return browser_defaults::kRestorePopups;
+ case TYPE_PANEL:
+ // Do not save the window placement of panels.
+ return false;
+ default:
+ return false;
+ }
}
void Browser::SaveWindowPlacement(const gfx::Rect& bounds, bool maximized) {
@@ -842,7 +871,7 @@ string16 Browser::GetWindowTitleForCurrentTab() const {
#else
int string_id = IDS_BROWSER_WINDOW_TITLE_FORMAT;
// Don't append the app name to window titles on app frames and app popups
- if (type_ & TYPE_APP)
+ if (is_app())
string_id = IDS_BROWSER_WINDOW_TITLE_FORMAT_NO_LOGO;
return l10n_util::GetStringFUTF16(string_id, title);
#endif
@@ -915,7 +944,7 @@ void Browser::OnWindowClosing() {
TabRestoreService* tab_restore_service =
TabRestoreServiceFactory::GetForProfile(profile());
- if (tab_restore_service && type() == TYPE_NORMAL && tab_count())
+ if (tab_restore_service && is_type_tabbed() && tab_count())
tab_restore_service->BrowserClosing(tab_restore_service_delegate());
// TODO(sky): convert session/tab restore to use notification.
@@ -1142,35 +1171,34 @@ void Browser::ShowSingletonTab(const GURL& url) {
void Browser::UpdateCommandsForFullscreenMode(bool is_fullscreen) {
#if !defined(OS_MACOSX)
- const bool show_main_ui = (type() == TYPE_NORMAL) && !is_fullscreen;
+ const bool show_main_ui = is_type_tabbed() && !is_fullscreen;
#else
- const bool show_main_ui = (type() == TYPE_NORMAL);
+ const bool show_main_ui = is_type_tabbed();
#endif
- bool main_not_fullscreen_or_popup =
- show_main_ui && !is_fullscreen && (type() & TYPE_POPUP) == 0;
+ bool main_not_fullscreen = show_main_ui && !is_fullscreen;
// Navigation commands
command_updater_.UpdateCommandEnabled(IDC_OPEN_CURRENT_URL, show_main_ui);
// Window management commands
command_updater_.UpdateCommandEnabled(IDC_SHOW_AS_TAB,
- (type() & TYPE_POPUP) && !is_fullscreen);
+ type_ != TYPE_TABBED && !is_fullscreen);
// Focus various bits of UI
command_updater_.UpdateCommandEnabled(IDC_FOCUS_TOOLBAR, show_main_ui);
command_updater_.UpdateCommandEnabled(IDC_FOCUS_LOCATION, show_main_ui);
command_updater_.UpdateCommandEnabled(IDC_FOCUS_SEARCH, show_main_ui);
command_updater_.UpdateCommandEnabled(
- IDC_FOCUS_MENU_BAR, main_not_fullscreen_or_popup);
+ IDC_FOCUS_MENU_BAR, main_not_fullscreen);
command_updater_.UpdateCommandEnabled(
- IDC_FOCUS_NEXT_PANE, main_not_fullscreen_or_popup);
+ IDC_FOCUS_NEXT_PANE, main_not_fullscreen);
command_updater_.UpdateCommandEnabled(
- IDC_FOCUS_PREVIOUS_PANE, main_not_fullscreen_or_popup);
+ IDC_FOCUS_PREVIOUS_PANE, main_not_fullscreen);
command_updater_.UpdateCommandEnabled(
- IDC_FOCUS_BOOKMARKS, main_not_fullscreen_or_popup);
+ IDC_FOCUS_BOOKMARKS, main_not_fullscreen);
command_updater_.UpdateCommandEnabled(
- IDC_FOCUS_CHROMEOS_STATUS, main_not_fullscreen_or_popup);
+ IDC_FOCUS_CHROMEOS_STATUS, main_not_fullscreen);
// Show various bits of UI
command_updater_.UpdateCommandEnabled(IDC_DEVELOPER_MENU, show_main_ui);
@@ -1242,21 +1270,20 @@ bool Browser::SupportsWindowFeatureImpl(WindowFeature feature,
features |= FEATURE_DOWNLOADSHELF;
#endif // !defined(OS_CHROMEOS)
- if (type() == TYPE_NORMAL) {
+ if (is_type_tabbed())
features |= FEATURE_BOOKMARKBAR;
- }
if (!hide_ui_for_fullscreen) {
- if (type() != TYPE_NORMAL)
+ if (!is_type_tabbed())
features |= FEATURE_TITLEBAR;
- if (type() == TYPE_NORMAL)
+ if (is_type_tabbed())
features |= FEATURE_TABSTRIP;
- if (type() == TYPE_NORMAL)
+ if (is_type_tabbed())
features |= FEATURE_TOOLBAR;
- if ((type() & Browser::TYPE_APP) == 0)
+ if (!is_app())
features |= FEATURE_LOCATIONBAR;
}
return !!(features & feature);
@@ -1408,7 +1435,7 @@ void Browser::CloseWindow() {
void Browser::NewTab() {
UserMetrics::RecordAction(UserMetricsAction("NewTab"));
- if (type() == TYPE_NORMAL) {
+ if (is_type_tabbed()) {
AddBlankTab(true);
GetSelectedTabContentsWrapper()->view()->RestoreFocus();
} else {
@@ -2513,7 +2540,7 @@ Browser* Browser::CreateNewStripWithContents(
dock_info.AdjustOtherWindowBounds();
// Create an empty new browser window the same size as the old one.
- Browser* browser = new Browser(TYPE_NORMAL, profile_);
+ Browser* browser = new Browser(TYPE_TABBED, profile_);
browser->set_override_bounds(new_window_bounds);
browser->set_maximized_state(
maximize ? MAXIMIZED_STATE_MAXIMIZED : MAXIMIZED_STATE_UNMAXIMIZED);
@@ -2572,12 +2599,12 @@ void Browser::DuplicateContentsAt(int index) {
add_types);
} else {
Browser* browser = NULL;
- if (type_ & TYPE_APP) {
- CHECK_EQ((type_ & TYPE_POPUP), 0);
- CHECK_NE(type_, TYPE_APP_PANEL);
- browser = Browser::CreateForApp(app_name_, gfx::Size(), profile_,
- false);
- } else if (type_ == TYPE_POPUP) {
+ if (is_app()) {
+ CHECK(!is_type_popup());
+ CHECK(!is_type_panel());
+ browser = Browser::CreateForApp(TYPE_POPUP, app_name_, gfx::Size(),
+ profile_);
+ } else if (is_type_popup()) {
browser = Browser::CreateForType(TYPE_POPUP, profile_);
}
@@ -2633,7 +2660,7 @@ bool Browser::RunUnloadListenerBeforeClosing(TabContentsWrapper* contents) {
}
bool Browser::CanReloadContents(TabContents* source) const {
- return type() != TYPE_DEVTOOLS;
+ return !is_devtools();
}
bool Browser::CanCloseContents(std::vector<int>* indices) {
@@ -3023,7 +3050,7 @@ void Browser::CloseContents(TabContents* source) {
}
void Browser::MoveContents(TabContents* source, const gfx::Rect& pos) {
- if ((type() & TYPE_POPUP) == 0) {
+ if (!IsPopupOrPanel(source)) {
NOTREACHED() << "moving invalid browser type";
return;
}
@@ -3036,9 +3063,9 @@ void Browser::DetachContents(TabContents* source) {
tab_handler_->GetTabStripModel()->DetachTabContentsAt(index);
}
-bool Browser::IsPopup(const TabContents* source) const {
+bool Browser::IsPopupOrPanel(const TabContents* source) const {
// A non-tabbed BROWSER is an unconstrained popup.
- return !!(type() & TYPE_POPUP);
+ return is_type_popup() || is_type_panel();
}
void Browser::ContentsMouseEvent(
@@ -3107,17 +3134,16 @@ bool Browser::TakeFocus(bool reverse) {
}
bool Browser::IsApplication() const {
- return (type_ & TYPE_APP) != 0;
+ return is_app();
}
void Browser::ConvertContentsToApplication(TabContents* contents) {
const GURL& url = contents->controller().GetActiveEntry()->url();
std::string app_name = web_app::GenerateApplicationNameFromURL(url);
- RegisterAppPrefs(app_name, contents->profile());
DetachContents(contents);
Browser* app_browser = Browser::CreateForApp(
- app_name, gfx::Size(), profile_, false);
+ TYPE_POPUP, app_name, gfx::Size(), profile_);
TabContentsWrapper* wrapper =
TabContentsWrapper::GetCurrentWrapperForContents(contents);
if (!wrapper)
@@ -3455,10 +3481,8 @@ void Browser::Observe(NotificationType type,
break;
case NotificationType::EXTENSION_READY_FOR_INSTALL: {
- // Handle EXTENSION_READY_FOR_INSTALL for last active normal browser.
- if (BrowserList::FindBrowserWithType(profile(),
- Browser::TYPE_NORMAL,
- true) != this)
+ // Handle EXTENSION_READY_FOR_INSTALL for last active tabbed browser.
+ if (BrowserList::FindTabbedBrowser(profile(), true) != this)
break;
// We only want to show the loading dialog for themes, but we don't want
@@ -3514,9 +3538,9 @@ void Browser::OnStateChanged() {
DCHECK(profile_->GetProfileSyncService());
#if !defined(OS_MACOSX)
- const bool show_main_ui = (type() == TYPE_NORMAL) && !window_->IsFullscreen();
+ const bool show_main_ui = is_type_tabbed() && !window_->IsFullscreen();
#else
- const bool show_main_ui = (type() == TYPE_NORMAL);
+ const bool show_main_ui = is_type_tabbed();
#endif
command_updater_.UpdateCommandEnabled(IDC_SYNC_BOOKMARKS,
@@ -3583,7 +3607,7 @@ gfx::Rect Browser::GetInstantBounds() {
// Browser, protected:
BrowserWindow* Browser::CreateBrowserWindow() {
- if (type() == Browser::TYPE_APP_PANEL &&
+ if (type_ == TYPE_PANEL &&
CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePanels))
return PanelManager::GetInstance()->CreatePanel(this);
@@ -3690,15 +3714,14 @@ void Browser::InitCommandState() {
enable_extensions);
// Initialize other commands based on the window type.
- bool normal_window = type() == TYPE_NORMAL;
- bool non_devtools_window = type() != TYPE_DEVTOOLS;
+ bool normal_window = is_type_tabbed();
// Navigation commands
command_updater_.UpdateCommandEnabled(IDC_HOME, normal_window);
// Window management commands
command_updater_.UpdateCommandEnabled(IDC_FULLSCREEN,
- type() != TYPE_APP_PANEL);
+ !(is_type_panel() && is_app()));
command_updater_.UpdateCommandEnabled(IDC_SELECT_NEXT_TAB, normal_window);
command_updater_.UpdateCommandEnabled(IDC_SELECT_PREVIOUS_TAB,
normal_window);
@@ -3718,16 +3741,15 @@ void Browser::InitCommandState() {
#endif
// Clipboard commands
- command_updater_.UpdateCommandEnabled(IDC_COPY_URL, non_devtools_window);
+ command_updater_.UpdateCommandEnabled(IDC_COPY_URL, !is_devtools());
// Find-in-page
- command_updater_.UpdateCommandEnabled(IDC_FIND, non_devtools_window);
- command_updater_.UpdateCommandEnabled(IDC_FIND_NEXT, non_devtools_window);
- command_updater_.UpdateCommandEnabled(IDC_FIND_PREVIOUS, non_devtools_window);
+ command_updater_.UpdateCommandEnabled(IDC_FIND, !is_devtools());
+ command_updater_.UpdateCommandEnabled(IDC_FIND_NEXT, !is_devtools());
+ command_updater_.UpdateCommandEnabled(IDC_FIND_PREVIOUS, !is_devtools());
// Autofill
- command_updater_.UpdateCommandEnabled(IDC_AUTOFILL_DEFAULT,
- non_devtools_window);
+ command_updater_.UpdateCommandEnabled(IDC_AUTOFILL_DEFAULT, !is_devtools());
// Show various bits of UI
command_updater_.UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA, normal_window);
@@ -3766,9 +3788,8 @@ void Browser::UpdateCommandsForTabState() {
CanReloadContents(current_tab));
// Window management commands
- bool non_app_window = !(type() & TYPE_APP);
command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB,
- non_app_window && CanDuplicateContentsAt(active_index()));
+ !is_app() && CanDuplicateContentsAt(active_index()));
// Page-related commands
window_->SetStarredState(current_tab_wrapper->is_starred());
@@ -3847,7 +3868,7 @@ void Browser::UpdateCommandsForBookmarkEditing() {
browser_defaults::bookmarks_enabled;
command_updater_.UpdateCommandEnabled(IDC_BOOKMARK_PAGE,
- enabled && type() == TYPE_NORMAL);
+ enabled && is_type_tabbed());
command_updater_.UpdateCommandEnabled(IDC_BOOKMARK_ALL_TABS,
enabled && CanBookmarkAllTabs());
}
@@ -4212,11 +4233,11 @@ bool Browser::CanCloseWithInProgressDownloads() {
for (BrowserList::const_iterator iter = BrowserList::begin();
iter != BrowserList::end(); ++iter) {
// Don't count this browser window or any other in the process of closing.
- // Only consider normal browser windows, not popups.
+ // Only consider tabbed browser windows, not popups.
Browser* const browser = *iter;
if (browser == this
|| browser->is_attempting_to_close_browser_
- || browser->type() != Browser::TYPE_NORMAL)
+ || !browser->is_type_tabbed())
continue;
// Verify that this is not the last non-incognito or incognito browser,
@@ -4252,8 +4273,7 @@ bool Browser::CanCloseWithInProgressDownloads() {
// static
Browser* Browser::GetTabbedBrowser(Profile* profile, bool match_incognito) {
- return BrowserList::FindBrowserWithType(profile, TYPE_NORMAL,
- match_incognito);
+ return BrowserList::FindTabbedBrowser(profile, match_incognito);
}
// static
@@ -4332,22 +4352,13 @@ void Browser::TabDetachedAtImpl(TabContentsWrapper* contents, int index,
// static
void Browser::RegisterAppPrefs(const std::string& app_name, Profile* profile) {
- // A set of apps that we've already started.
- static std::set<std::string>* g_app_names = NULL;
-
- if (!g_app_names)
- g_app_names = new std::set<std::string>;
-
- // Only register once for each app name.
- if (g_app_names->find(app_name) != g_app_names->end())
- return;
- g_app_names->insert(app_name);
-
// We need to register the window position pref.
std::string window_pref(prefs::kBrowserWindowPlacement);
window_pref.append("_");
window_pref.append(app_name);
- profile->GetPrefs()->RegisterDictionaryPref(window_pref.c_str());
+ PrefService* prefs = profile->GetPrefs();
+ if (!prefs->FindPreference(window_pref.c_str()))
+ prefs->RegisterDictionaryPref(window_pref.c_str());
}
void Browser::TabRestoreServiceChanged(TabRestoreService* service) {
@@ -4414,7 +4425,7 @@ bool Browser::OpenInstant(WindowOpenDisposition disposition) {
}
void Browser::CreateInstantIfNecessary() {
- if (type() == TYPE_NORMAL && InstantController::IsEnabled(profile()) &&
+ if (is_type_tabbed() && InstantController::IsEnabled(profile()) &&
!profile()->IsOffTheRecord()) {
instant_.reset(new InstantController(profile_, this));
instant_unload_handler_.reset(new InstantUnloadHandler(this));
@@ -4467,7 +4478,7 @@ void Browser::ViewSource(TabContentsWrapper* contents,
view_source_contents,
add_types);
} else {
- Browser* browser = Browser::CreateForType(TYPE_NORMAL, profile_);
+ Browser* browser = Browser::CreateForType(TYPE_TABBED, profile_);
// Preserve the size of the original window. The new window has already
// been given an offset by the OS, so we shouldn't copy the old bounds.
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index 7cc2d82..aadb6b2 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -77,25 +77,9 @@ class Browser : public TabHandlerDelegate,
// enum, look at SessionService::WindowType to see if it needs to be
// updated.
enum Type {
- TYPE_NORMAL = 1,
+ TYPE_TABBED = 1,
TYPE_POPUP = 2,
- // The old-style app created via "Create application shortcuts".
- // Shortcuts to a URL and shortcuts to an installed application
- // both have this type.
- TYPE_APP = 4,
- TYPE_APP_POPUP = TYPE_APP | TYPE_POPUP,
- TYPE_DEVTOOLS = TYPE_APP | 8,
-
- // TODO(skerner): crbug/56776: Until the panel UI is complete on all
- // platforms, apps that set app.launch.container = "panel" have type
- // APP_POPUP. (see Browser::CreateForApp)
- // NOTE: TYPE_APP_PANEL is a superset of TYPE_APP_POPUP.
- TYPE_APP_PANEL = TYPE_APP | TYPE_POPUP | 16,
- TYPE_ANY = TYPE_NORMAL |
- TYPE_POPUP |
- TYPE_APP |
- TYPE_DEVTOOLS |
- TYPE_APP_PANEL
+ TYPE_PANEL = 3,
};
// Possible elements of the Browser window.
@@ -124,6 +108,25 @@ class Browser : public TabHandlerDelegate,
MAXIMIZED_STATE_UNMAXIMIZED
};
+ struct CreateParams {
+ CreateParams(Type type, Profile* profile);
+
+ // The browser type.
+ Type type;
+
+ // The associated profile.
+ Profile* profile;
+
+ // 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;
+
+ // The bounds of the window to open.
+ gfx::Rect initial_bounds;
+ };
+
// Constructors, Creation, Showing //////////////////////////////////////////
// Creates a new browser of the given |type| and for the given |profile|. The
@@ -138,17 +141,20 @@ class Browser : public TabHandlerDelegate,
// window is created by this function call.
static Browser* Create(Profile* profile);
+ // Like Create, but creates a browser of the specified parameters.
+ static Browser* CreateWithParams(const CreateParams& params);
+
// Like Create, but creates a browser of the specified type.
static Browser* CreateForType(Type type, Profile* profile);
// Like Create, but creates a toolbar-less "app" window for the specified
// app. |app_name| is required and is used to identify the window to the
- // shell. If |extension| is set, it is used to determine the size of the
+ // shell. If |window_size| is set, it is used to determine the size of the
// window to open.
- static Browser* CreateForApp(const std::string& app_name,
+ static Browser* CreateForApp(Type type,
+ const std::string& app_name,
const gfx::Size& window_size,
- Profile* profile,
- bool is_panel);
+ Profile* profile);
// Like Create, but creates a tabstrip-less and toolbar-less
// DevTools "app" window.
@@ -731,12 +737,20 @@ class Browser : public TabHandlerDelegate,
// Figure out if there are tabs that have beforeunload handlers.
bool TabsNeedBeforeUnloadFired();
+ bool is_type_tabbed() const { return type_ == TYPE_TABBED; }
+ bool is_type_popup() const { return type_ == TYPE_POPUP; }
+ bool is_type_panel() const { return type_ == TYPE_PANEL; }
+
+ bool is_app() const;
+ bool is_devtools() const;
+
protected:
// Wrapper for the factory method in BrowserWindow. This allows subclasses to
// set their own window.
virtual BrowserWindow* CreateBrowserWindow();
private:
+ FRIEND_TEST_ALL_PREFIXES(AppModeTest, EnableAppModeTest);
FRIEND_TEST_ALL_PREFIXES(BrowserTest, NoTabsInPopups);
FRIEND_TEST_ALL_PREFIXES(BrowserTest, ConvertTabToAppShortcut);
FRIEND_TEST_ALL_PREFIXES(BrowserTest, OpenAppWindowLikeNtp);
@@ -778,7 +792,7 @@ class Browser : public TabHandlerDelegate,
virtual void CloseContents(TabContents* source);
virtual void MoveContents(TabContents* source, const gfx::Rect& pos);
virtual void DetachContents(TabContents* source);
- virtual bool IsPopup(const TabContents* source) const;
+ virtual bool IsPopupOrPanel(const TabContents* source) const;
virtual bool CanReloadContents(TabContents* source) const;
virtual void UpdateTargetURL(TabContents* source, const GURL& url);
virtual void ContentsMouseEvent(
@@ -925,6 +939,7 @@ class Browser : public TabHandlerDelegate,
// TODO(beng): remove, and provide AutomationProvider a better way to access
// the LocationBarView's edit.
friend class AutomationProvider;
+ friend class BrowserProxy;
friend class TestingAutomationProvider;
// Returns the StatusBubble from the current toolbar. It is possible for
@@ -1079,8 +1094,10 @@ class Browser : public TabHandlerDelegate,
// The CommandUpdater that manages the browser window commands.
CommandUpdater command_updater_;
- // An optional application name which is used to retrieve and save window
- // positions.
+ // 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_;
// Unique identifier of this browser for session restore. This id is only
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc
index 6700377..71c61f0 100644
--- a/chrome/browser/ui/browser_init.cc
+++ b/chrome/browser/ui/browser_init.cc
@@ -967,7 +967,7 @@ Browser* BrowserInit::LaunchWithProfile::OpenTabsInBrowser(
if (!profile_ && browser)
profile_ = browser->profile();
- if (!browser || browser->type() != Browser::TYPE_NORMAL) {
+ if (!browser || !browser->is_type_tabbed()) {
browser = Browser::Create(profile_);
} else {
#if defined(TOOLKIT_GTK)
diff --git a/chrome/browser/ui/browser_init_browsertest.cc b/chrome/browser/ui/browser_init_browsertest.cc
index e5e9a54..929ae83 100644
--- a/chrome/browser/ui/browser_init_browsertest.cc
+++ b/chrome/browser/ui/browser_init_browsertest.cc
@@ -88,7 +88,7 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenURLsPopup) {
Browser* popup = Browser::CreateForType(Browser::TYPE_POPUP,
browser()->profile());
- ASSERT_EQ(popup->type(), Browser::TYPE_POPUP);
+ ASSERT_TRUE(popup->is_type_popup());
ASSERT_EQ(popup, observer.added_browser_);
CommandLine dummy(CommandLine::NO_PROGRAM);
@@ -122,7 +122,7 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenAppShortcutNoPref) {
ASSERT_FALSE(HasFatalFailure());
// Expect an app window.
- EXPECT_EQ(Browser::TYPE_APP, new_browser->type());
+ EXPECT_TRUE(new_browser->is_app());
// The browser's app_name should include the app's ID.
EXPECT_NE(
@@ -151,7 +151,7 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenAppShortcutWindowPref) {
ASSERT_FALSE(HasFatalFailure());
// Expect an app window.
- EXPECT_EQ(Browser::TYPE_APP, new_browser->type());
+ EXPECT_TRUE(new_browser->is_app());
// The browser's app_name should include the app's ID.
EXPECT_NE(
@@ -181,8 +181,8 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenAppShortcutTabPref) {
FindOneOtherBrowser(&new_browser);
ASSERT_FALSE(HasFatalFailure());
- // The tab should be in a normal window.
- EXPECT_EQ(Browser::TYPE_NORMAL, new_browser->type());
+ // The tab should be in a tabbed window.
+ EXPECT_TRUE(new_browser->is_type_tabbed());
// The browser's app_name should not include the app's ID: It is in a
// normal browser.
@@ -208,7 +208,11 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenAppShortcutPanel) {
ASSERT_FALSE(HasFatalFailure());
// Expect an app panel.
- EXPECT_EQ(Browser::TYPE_APP_POPUP, new_browser->type());
+#if defined(OS_CHROMEOS)
+ EXPECT_TRUE(new_browser->is_type_panel() && new_browser->is_app());
+#else
+ EXPECT_TRUE(new_browser->is_type_popup() && new_browser->is_app());
+#endif
// The new browser's app_name should include the app's ID.
EXPECT_NE(
diff --git a/chrome/browser/ui/browser_list.cc b/chrome/browser/ui/browser_list.cc
index a3ca6e5..10332e5d 100644
--- a/chrome/browser/ui/browser_list.cc
+++ b/chrome/browser/ui/browser_list.cc
@@ -99,14 +99,13 @@ class BrowserActivityObserver : public NotificationObserver {
BrowserActivityObserver* activity_observer = NULL;
-// Type used to indicate only the type should be matched.
-const int kMatchNothing = 0;
+// Type used to indicate to match anything.
+const int kMatchAny = 0;
// See BrowserMatches for details.
const int kMatchOriginalProfile = 1 << 0;
-
-// See BrowserMatches for details.
const int kMatchCanSupportWindowFeature = 1 << 1;
+const int kMatchTabbed = 1 << 2;
// Returns true if the specified |browser| matches the specified arguments.
// |match_types| is a bitmask dictating what parameters to match:
@@ -115,9 +114,9 @@ const int kMatchCanSupportWindowFeature = 1 << 1;
// incognito windows.
// . If it contains kMatchCanSupportWindowFeature
// |CanSupportWindowFeature(window_feature)| must return true.
+// . If it contains kMatchTabbed, the browser must be a tabbed browser.
bool BrowserMatches(Browser* browser,
Profile* profile,
- Browser::Type type,
Browser::WindowFeature window_feature,
uint32 match_types) {
if (match_types & kMatchCanSupportWindowFeature &&
@@ -133,8 +132,8 @@ bool BrowserMatches(Browser* browser,
return false;
}
- if (type != Browser::TYPE_ANY && browser->type() != type)
- return false;
+ if (match_types & kMatchTabbed)
+ return browser->is_type_tabbed();
return true;
}
@@ -146,16 +145,32 @@ template <class T>
Browser* FindBrowserMatching(const T& begin,
const T& end,
Profile* profile,
- Browser::Type type,
Browser::WindowFeature window_feature,
uint32 match_types) {
for (T i = begin; i != end; ++i) {
- if (BrowserMatches(*i, profile, type, window_feature, match_types))
+ if (BrowserMatches(*i, profile, window_feature, match_types))
return *i;
}
return NULL;
}
+Browser* FindBrowserWithTabbedOrAnyType(Profile* profile,
+ bool match_tabbed,
+ bool match_incognito) {
+ uint32 match_types = kMatchAny;
+ if (match_tabbed)
+ match_types |= kMatchTabbed;
+ if (match_incognito)
+ match_types |= kMatchOriginalProfile;
+ Browser* browser = FindBrowserMatching(
+ BrowserList::begin_last_active(), BrowserList::end_last_active(),
+ profile, Browser::FEATURE_NONE, match_types);
+ // Fall back to a forward scan of all Browsers if no active one was found.
+ return browser ? browser :
+ FindBrowserMatching(BrowserList::begin(), BrowserList::end(), profile,
+ Browser::FEATURE_NONE, match_types);
+}
+
} // namespace
BrowserList::BrowserVector BrowserList::browsers_;
@@ -455,9 +470,9 @@ void BrowserList::SessionEnding() {
bool BrowserList::HasBrowserWithProfile(Profile* profile) {
return FindBrowserMatching(BrowserList::begin(),
BrowserList::end(),
- profile, Browser::TYPE_ANY,
+ profile,
Browser::FEATURE_NONE,
- kMatchNothing) != NULL;
+ kMatchAny) != NULL;
}
// static
@@ -513,43 +528,40 @@ Browser* BrowserList::GetLastActive() {
}
// static
-Browser* BrowserList::GetLastActiveWithProfile(Profile* p) {
+Browser* BrowserList::GetLastActiveWithProfile(Profile* profile) {
// We are only interested in last active browsers, so we don't fall back to
// all browsers like FindBrowserWith* do.
return FindBrowserMatching(
- BrowserList::begin_last_active(), BrowserList::end_last_active(), p,
- Browser::TYPE_ANY, Browser::FEATURE_NONE, kMatchNothing);
+ BrowserList::begin_last_active(), BrowserList::end_last_active(), profile,
+ Browser::FEATURE_NONE, kMatchAny);
}
// static
-Browser* BrowserList::FindBrowserWithType(Profile* p, Browser::Type t,
- bool match_incognito) {
- uint32 match_types = match_incognito ? kMatchOriginalProfile : kMatchNothing;
- Browser* browser = FindBrowserMatching(
- BrowserList::begin_last_active(), BrowserList::end_last_active(),
- p, t, Browser::FEATURE_NONE, match_types);
- // Fall back to a forward scan of all Browsers if no active one was found.
- return browser ? browser :
- FindBrowserMatching(BrowserList::begin(), BrowserList::end(), p, t,
- Browser::FEATURE_NONE, match_types);
+Browser* BrowserList::FindTabbedBrowser(Profile* profile,
+ bool match_incognito) {
+ return FindBrowserWithTabbedOrAnyType(profile, true, match_incognito);
+}
+
+// static
+Browser* BrowserList::FindAnyBrowser(Profile* profile, bool match_incognito) {
+ return FindBrowserWithTabbedOrAnyType(profile, false, match_incognito);
}
// static
-Browser* BrowserList::FindBrowserWithFeature(Profile* p,
+Browser* BrowserList::FindBrowserWithFeature(Profile* profile,
Browser::WindowFeature feature) {
Browser* browser = FindBrowserMatching(
BrowserList::begin_last_active(), BrowserList::end_last_active(),
- p, Browser::TYPE_ANY, feature, kMatchCanSupportWindowFeature);
+ profile, feature, kMatchCanSupportWindowFeature);
// Fall back to a forward scan of all Browsers if no active one was found.
return browser ? browser :
- FindBrowserMatching(BrowserList::begin(), BrowserList::end(), p,
- Browser::TYPE_ANY, feature,
- kMatchCanSupportWindowFeature);
+ FindBrowserMatching(BrowserList::begin(), BrowserList::end(), profile,
+ feature, kMatchCanSupportWindowFeature);
}
// static
-Browser* BrowserList::FindBrowserWithProfile(Profile* p) {
- return FindBrowserWithType(p, Browser::TYPE_ANY, false);
+Browser* BrowserList::FindBrowserWithProfile(Profile* profile) {
+ return FindAnyBrowser(profile, false);
}
// static
@@ -563,23 +575,24 @@ Browser* BrowserList::FindBrowserWithID(SessionID::id_type desired_id) {
}
// static
-size_t BrowserList::GetBrowserCountForType(Profile* p, Browser::Type type) {
+size_t BrowserList::GetBrowserCountForType(Profile* profile,
+ bool match_tabbed) {
size_t result = 0;
for (BrowserList::const_iterator i = BrowserList::begin();
i != BrowserList::end(); ++i) {
- if (BrowserMatches(*i, p, type, Browser::FEATURE_NONE, kMatchNothing))
+ if (BrowserMatches(*i, profile, Browser::FEATURE_NONE,
+ match_tabbed ? kMatchTabbed : kMatchAny))
++result;
}
return result;
}
// static
-size_t BrowserList::GetBrowserCount(Profile* p) {
+size_t BrowserList::GetBrowserCount(Profile* profile) {
size_t result = 0;
for (BrowserList::const_iterator i = BrowserList::begin();
i != BrowserList::end(); ++i) {
- if (BrowserMatches(*i, p, Browser::TYPE_ANY, Browser::FEATURE_NONE,
- kMatchNothing)) {
+ if (BrowserMatches(*i, profile, Browser::FEATURE_NONE, kMatchAny)) {
result++;
}
}
diff --git a/chrome/browser/ui/browser_list.h b/chrome/browser/ui/browser_list.h
index 8825e49..1260735 100644
--- a/chrome/browser/ui/browser_list.h
+++ b/chrome/browser/ui/browser_list.h
@@ -63,28 +63,31 @@ class BrowserList {
// Identical in behavior to GetLastActive(), except that the most recently
// open browser owned by |profile| is returned. If none exist, returns NULL.
// WARNING: see warnings in GetLastActive().
- static Browser* GetLastActiveWithProfile(Profile *profile);
+ static Browser* GetLastActiveWithProfile(Profile* profile);
- // Find an existing browser window with the provided type. Searches in the
+ // Find an existing browser window with tabbed type. Searches in the
// order of last activation. Only browsers that have been active can be
// returned. If |match_incognito| is true, will match a browser with either
// a regular or incognito profile that matches the given one. Returns NULL if
// no such browser currently exists.
- static Browser* FindBrowserWithType(Profile* p, Browser::Type t,
- bool match_incognito);
+ static Browser* FindTabbedBrowser(Profile* profile, bool match_incognito);
+
+ // Find an existing browser window with any type. See comment above for
+ // additional information.
+ static Browser* FindAnyBrowser(Profile* profile, bool match_incognito);
// Find an existing browser window that can provide the specified type (this
// uses Browser::CanSupportsWindowFeature, not
// Browser::SupportsWindowFeature). This searches in the order of last
// activation. Only browsers that have been active can be returned. Returns
// NULL if no such browser currently exists.
- static Browser* FindBrowserWithFeature(Profile* p,
+ static Browser* FindBrowserWithFeature(Profile* profile,
Browser::WindowFeature feature);
// Find an existing browser window with the provided profile. Searches in the
// order of last activation. Only browsers that have been active can be
// returned. Returns NULL if no such browser currently exists.
- static Browser* FindBrowserWithProfile(Profile* p);
+ static Browser* FindBrowserWithProfile(Profile* profile);
// Find an existing browser with the provided ID. Returns NULL if no such
// browser currently exists.
@@ -152,11 +155,11 @@ class BrowserList {
// Return the number of browsers with the following profile which are
// currently open.
- static size_t GetBrowserCount(Profile* p);
+ static size_t GetBrowserCount(Profile* profile);
// Return the number of browsers with the following profile and type which are
// currently open.
- static size_t GetBrowserCountForType(Profile* p, Browser::Type type);
+ static size_t GetBrowserCountForType(Profile* profile, bool match_tabbed);
// Returns true if at least one incognito session is active.
static bool IsOffTheRecordSessionActive();
diff --git a/chrome/browser/ui/browser_list_unittest.cc b/chrome/browser/ui/browser_list_unittest.cc
index e292eec..78b677b 100644
--- a/chrome/browser/ui/browser_list_unittest.cc
+++ b/chrome/browser/ui/browser_list_unittest.cc
@@ -26,9 +26,9 @@ TEST_F(BrowserListTest, TabContentsIteratorVerifyCount) {
EXPECT_EQ(0U, CountAllTabs());
// Create more browsers/windows.
- scoped_ptr<Browser> browser2(new Browser(Browser::TYPE_NORMAL, profile()));
- scoped_ptr<Browser> browser3(new Browser(Browser::TYPE_NORMAL, profile()));
- scoped_ptr<Browser> browser4(new Browser(Browser::TYPE_NORMAL, profile()));
+ scoped_ptr<Browser> browser2(new Browser(Browser::TYPE_TABBED, profile()));
+ scoped_ptr<Browser> browser3(new Browser(Browser::TYPE_TABBED, profile()));
+ scoped_ptr<Browser> browser4(new Browser(Browser::TYPE_TABBED, profile()));
scoped_ptr<TestBrowserWindow> window2(new TestBrowserWindow(browser2.get()));
scoped_ptr<TestBrowserWindow> window3(new TestBrowserWindow(browser3.get()));
@@ -74,8 +74,8 @@ TEST_F(BrowserListTest, TabContentsIteratorVerifyBrowser) {
EXPECT_EQ(1U, BrowserList::size());
// Create more browsers/windows.
- scoped_ptr<Browser> browser2(new Browser(Browser::TYPE_NORMAL, profile()));
- scoped_ptr<Browser> browser3(new Browser(Browser::TYPE_NORMAL, profile()));
+ scoped_ptr<Browser> browser2(new Browser(Browser::TYPE_TABBED, profile()));
+ scoped_ptr<Browser> browser3(new Browser(Browser::TYPE_TABBED, profile()));
scoped_ptr<TestBrowserWindow> window2(new TestBrowserWindow(browser2.get()));
scoped_ptr<TestBrowserWindow> window3(new TestBrowserWindow(browser3.get()));
diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc
index 6666315..c2169b7 100644
--- a/chrome/browser/ui/browser_navigator.cc
+++ b/chrome/browser/ui/browser_navigator.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/extension.h"
#include "chrome/common/url_constants.h"
#include "content/browser/site_instance.h"
#include "content/browser/tab_contents/tab_contents.h"
@@ -60,9 +61,7 @@ bool WindowCanOpenTabs(Browser* browser) {
// Finds an existing Browser compatible with |profile|, making a new one if no
// such Browser is located.
Browser* GetOrCreateBrowser(Profile* profile) {
- Browser* browser = BrowserList::FindBrowserWithType(profile,
- Browser::TYPE_NORMAL,
- false);
+ Browser* browser = BrowserList::FindTabbedBrowser(profile, false);
return browser ? browser : Browser::Create(profile);
}
@@ -178,26 +177,32 @@ Browser* GetBrowserForDisposition(browser::NavigateParams* params) {
return GetOrCreateBrowser(profile);
return NULL;
case NEW_POPUP: {
- // Make a new popup window. Coerce app-style if |params->browser| or the
- // |source| represents an app.
- Browser::Type type = Browser::TYPE_POPUP;
- if ((params->browser && (params->browser->type() & Browser::TYPE_APP)) ||
- (params->source_contents &&
- params->source_contents->extension_tab_helper()->is_app())) {
- type = Browser::TYPE_APP_POPUP;
- }
+ // Make a new popup window.
if (profile) {
- Browser* browser = new Browser(type, profile);
- browser->set_override_bounds(params->window_bounds);
- browser->InitBrowserWindow();
- return browser;
+ // Coerce app-style if |params->browser| or |source| represents an app.
+ std::string app_name;
+ if (params->browser && !params->browser->app_name().empty()) {
+ app_name = params->browser->app_name();
+ } else if (params->source_contents &&
+ params->source_contents->extension_tab_helper()->is_app()) {
+ app_name = params->source_contents->extension_tab_helper()->
+ extension_app()->id();
+ }
+ if (app_name.empty()) {
+ Browser::CreateParams browser_params(Browser::TYPE_POPUP, profile);
+ browser_params.initial_bounds = params->window_bounds;
+ return Browser::CreateWithParams(browser_params);
+ } else {
+ return Browser::CreateForApp(Browser::TYPE_POPUP, app_name,
+ params->window_bounds.size(), profile);
+ }
}
return NULL;
}
case NEW_WINDOW:
// Make a new normal browser window.
if (profile) {
- Browser* browser = new Browser(Browser::TYPE_NORMAL, profile);
+ Browser* browser = new Browser(Browser::TYPE_TABBED, profile);
browser->InitBrowserWindow();
return browser;
}
diff --git a/chrome/browser/ui/browser_navigator_browsertest.cc b/chrome/browser/ui/browser_navigator_browsertest.cc
index 1efab77..156db2d 100644
--- a/chrome/browser/ui/browser_navigator_browsertest.cc
+++ b/chrome/browser/ui/browser_navigator_browsertest.cc
@@ -39,6 +39,14 @@ Browser* BrowserNavigatorTest::CreateEmptyBrowserForType(Browser::Type type,
return browser;
}
+Browser* BrowserNavigatorTest::CreateEmptyBrowserForApp(Browser::Type type,
+ Profile* profile) {
+ Browser* browser = Browser::CreateForApp(Browser::TYPE_POPUP, "Test",
+ gfx::Size(), profile);
+ browser->AddBlankTab(true);
+ return browser;
+}
+
TabContentsWrapper* BrowserNavigatorTest::CreateTabContents() {
return Browser::TabContentsFactory(
browser()->profile(),
@@ -215,7 +223,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
// need a different profile, and creating a popup window with an incognito
// profile is a quick and dirty way of achieving this.
Browser* popup = CreateEmptyBrowserForType(
- Browser::TYPE_POPUP, browser()->profile()->GetOffTheRecordProfile());
+ Browser::TYPE_POPUP,
+ browser()->profile()->GetOffTheRecordProfile());
browser::NavigateParams p(MakeNavigateParams(popup));
p.disposition = NEW_FOREGROUND_TAB;
browser::Navigate(&p);
@@ -236,7 +245,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
EXPECT_EQ(1, browser()->tab_count());
EXPECT_EQ(1, popup->tab_count());
EXPECT_EQ(1, p.browser->tab_count());
- EXPECT_EQ(Browser::TYPE_NORMAL, p.browser->type());
+ EXPECT_TRUE(p.browser->is_type_tabbed());
}
// This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
@@ -255,7 +264,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup) {
// TODO(stevenjb): Enable this test. See: crbug.com/79493
EXPECT_TRUE(p.browser->window()->IsActive());
#endif
- EXPECT_EQ(Browser::TYPE_POPUP, p.browser->type());
+ EXPECT_TRUE(p.browser->is_type_popup());
+ EXPECT_FALSE(p.browser->is_app());
// We should have two windows, the browser() provided by the framework and the
// new popup window.
@@ -280,7 +290,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromPopup) {
// Navigate() should have opened a new normal popup window.
EXPECT_NE(p1.browser, p2.browser);
- EXPECT_EQ(Browser::TYPE_POPUP, p2.browser->type());
+ EXPECT_TRUE(p2.browser->is_type_popup());
+ EXPECT_FALSE(p2.browser->is_app());
// We should have three windows, the browser() provided by the framework,
// the first popup window, and the second popup window.
@@ -294,8 +305,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromPopup) {
// from an app frame results in a new Browser with TYPE_APP_POPUP.
IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
Disposition_NewPopupFromAppWindow) {
- Browser* app_browser = CreateEmptyBrowserForType(Browser::TYPE_APP,
- browser()->profile());
+ Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED,
+ browser()->profile());
browser::NavigateParams p(MakeNavigateParams(app_browser));
p.disposition = NEW_POPUP;
p.window_bounds = gfx::Rect(0, 0, 200, 200);
@@ -304,7 +315,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
// Navigate() should have opened a new popup app window.
EXPECT_NE(app_browser, p.browser);
EXPECT_NE(browser(), p.browser);
- EXPECT_EQ(Browser::TYPE_APP_POPUP, p.browser->type());
+ EXPECT_TRUE(p.browser->is_type_popup());
+ EXPECT_TRUE(p.browser->is_app());
// We should now have three windows, the app window, the app popup it created,
// and the original browser() provided by the framework.
@@ -318,8 +330,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
// from an app popup results in a new Browser also of TYPE_APP_POPUP.
IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
Disposition_NewPopupFromAppPopup) {
- Browser* app_browser = CreateEmptyBrowserForType(Browser::TYPE_APP,
- browser()->profile());
+ Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED,
+ browser()->profile());
// Open an app popup.
browser::NavigateParams p1(MakeNavigateParams(app_browser));
p1.disposition = NEW_POPUP;
@@ -334,7 +346,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
// Navigate() should have opened a new popup app window.
EXPECT_NE(browser(), p1.browser);
EXPECT_NE(p1.browser, p2.browser);
- EXPECT_EQ(Browser::TYPE_APP_POPUP, p2.browser->type());
+ EXPECT_TRUE(p2.browser->is_type_popup());
+ EXPECT_TRUE(p2.browser->is_app());
// We should now have four windows, the app window, the first app popup,
// the second app popup, and the original browser() provided by the framework.
@@ -381,7 +394,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewWindow) {
// Navigate() should have opened a new toplevel window.
EXPECT_NE(browser(), p.browser);
- EXPECT_EQ(Browser::TYPE_NORMAL, p.browser->type());
+ EXPECT_TRUE(p.browser->is_type_tabbed());
// We should now have two windows, the browser() provided by the framework and
// the new normal window.
@@ -417,7 +430,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_Incognito) {
// reuses an existing incognito window when possible.
IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IncognitoRefocus) {
Browser* incognito_browser =
- CreateEmptyBrowserForType(Browser::TYPE_NORMAL,
+ CreateEmptyBrowserForType(Browser::TYPE_TABBED,
browser()->profile()->GetOffTheRecordProfile());
browser::NavigateParams p(MakeNavigateParams());
p.disposition = OFF_THE_RECORD;
@@ -480,7 +493,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, DISABLED_TargetContents_Popup) {
// Navigate() should have opened a new popup window.
EXPECT_NE(browser(), p.browser);
- EXPECT_EQ(Browser::TYPE_POPUP, p.browser->type());
+ EXPECT_TRUE(p.browser->is_type_popup());
+ EXPECT_FALSE(p.browser->is_app());
// The web platform is weird. The window bounds specified in
// |p.window_bounds| are used as follows:
@@ -576,7 +590,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewWindow) {
// Navigate() should have created a new browser.
EXPECT_NE(browser(), p.browser);
- EXPECT_EQ(Browser::TYPE_NORMAL, p.browser->type());
+ EXPECT_TRUE( p.browser->is_type_tabbed());
// We should now have two windows, the browser() provided by the framework and
// the new normal window.
diff --git a/chrome/browser/ui/browser_navigator_browsertest.h b/chrome/browser/ui/browser_navigator_browsertest.h
index 4f9aa3b..31e480b 100644
--- a/chrome/browser/ui/browser_navigator_browsertest.h
+++ b/chrome/browser/ui/browser_navigator_browsertest.h
@@ -31,6 +31,7 @@ class BrowserNavigatorTest : public InProcessBrowserTest,
browser::NavigateParams MakeNavigateParams(Browser* browser) const;
Browser* CreateEmptyBrowserForType(Browser::Type type, Profile* profile);
+ Browser* CreateEmptyBrowserForApp(Browser::Type type, Profile* profile);
TabContentsWrapper* CreateTabContents();
diff --git a/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm b/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm
index 73e5167..37a0530 100644
--- a/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm
+++ b/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -21,10 +21,10 @@ IN_PROC_BROWSER_TEST_F(BrowserCrApplicationAppleScriptTest, Creation) {
// Create additional |Browser*| objects of different type.
Profile* profile = browser()->profile();
Browser* b1 = Browser::CreateForType(Browser::TYPE_POPUP, profile);
- Browser* b2 = Browser::CreateForApp("", gfx::Size(), profile, true);
- Browser* b3 = Browser::CreateForApp("", gfx::Size(), profile, false);
+ Browser* b2 = Browser::CreateForApp(Browser::TYPE_PANEL, "Test",
+ gfx::Size(), profile);
- EXPECT_EQ(4U, [[NSApp appleScriptWindows] count]);
+ EXPECT_EQ(3U, [[NSApp appleScriptWindows] count]);
for (WindowAppleScript* window in [NSApp appleScriptWindows]) {
EXPECT_NSEQ(AppleScript::kWindowsProperty,
[window containerProperty]);
@@ -34,7 +34,6 @@ IN_PROC_BROWSER_TEST_F(BrowserCrApplicationAppleScriptTest, Creation) {
// Close the additional browsers.
b1->CloseAllTabs();
b2->CloseAllTabs();
- b3->CloseAllTabs();
}
// Insert a new window.
diff --git a/chrome/browser/ui/cocoa/browser_test_helper.cc b/chrome/browser/ui/cocoa/browser_test_helper.cc
index d1a22ca..08cc8c2 100644
--- a/chrome/browser/ui/cocoa/browser_test_helper.cc
+++ b/chrome/browser/ui/cocoa/browser_test_helper.cc
@@ -20,7 +20,7 @@ BrowserTestHelper::BrowserTestHelper()
profile_->CreateAutocompleteClassifier();
profile_->CreateTemplateURLModel();
- browser_.reset(new Browser(Browser::TYPE_NORMAL, profile_.get()));
+ browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get()));
}
BrowserTestHelper::~BrowserTestHelper() {
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.h b/chrome/browser/ui/cocoa/browser_window_controller.h
index cc72002..f390dee 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.h
+++ b/chrome/browser/ui/cocoa/browser_window_controller.h
@@ -309,11 +309,11 @@ class TabContents;
// does, NO otherwise). (E.g., normal browser windows may, pop-ups may not.)
- (BOOL)supportsBookmarkBar;
-// Called to check if this controller's window is a normal window (e.g., not a
+// Called to check if this controller's window is a tabbed window (e.g., not a
// pop-up window). Returns YES if it is, NO otherwise.
// Note: The |-has...| methods are usually preferred, so this method is largely
// deprecated.
-- (BOOL)isNormalWindow;
+- (BOOL)isTabbedWindow;
@end // @interface BrowserWindowController(WindowType)
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm
index f94d18c..ec58717 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller.mm
@@ -276,8 +276,8 @@ enum {
// When we are given x/y coordinates of 0 on a created popup window, assume
// none were given by the window.open() command.
- if (browser_->type() & Browser::TYPE_POPUP &&
- windowRect.x() == 0 && windowRect.y() == 0) {
+ if ((browser_->is_type_popup() || browser_->is_type_panel()) &&
+ windowRect.x() == 0 && windowRect.y() == 0) {
gfx::Size size = windowRect.size();
windowRect.set_origin(WindowSizer::GetDefaultPopupOrigin(size));
}
@@ -373,7 +373,7 @@ enum {
// out, measure the current content area size and grow if needed. The
// window has not been placed onscreen yet, so this extra resize will not
// cause visible jank.
- if (browser_->type() & Browser::TYPE_POPUP) {
+ if (browser_->is_type_popup() || browser_->is_type_panel()) {
CGFloat deltaH = desiredContentRect.height() -
NSHeight([[self tabContentArea] frame]);
// Do not shrink the window, as that may break minimum size invariants.
@@ -1536,11 +1536,10 @@ enum {
if (browser_->profile()->IsOffTheRecord())
style |= THEMED_INCOGNITO;
- Browser::Type type = browser_->type();
- if (type == Browser::TYPE_POPUP)
- style |= THEMED_POPUP;
- else if (type == Browser::TYPE_DEVTOOLS)
+ if (browser_->is_devtools())
style |= THEMED_DEVTOOLS;
+ if (browser_->is_type_popup())
+ style |= THEMED_POPUP;
return style;
}
@@ -2187,8 +2186,8 @@ willAnimateFromState:(bookmarks::VisualState)oldState
return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
}
-- (BOOL)isNormalWindow {
- return browser_->type() == Browser::TYPE_NORMAL;
+- (BOOL)isTabbedWindow {
+ return browser_->is_type_tabbed();
}
@end // @implementation BrowserWindowController(WindowType)
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
index 5666f2c..c3cec87 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
@@ -112,7 +112,7 @@ TEST_F(BrowserWindowControllerTest, TestNormal) {
[controller_ updateBookmarkBarVisibilityWithAnimation:NO];
// Make sure a normal BrowserWindowController is, uh, normal.
- EXPECT_TRUE([controller_ isNormalWindow]);
+ EXPECT_TRUE([controller_ isTabbedWindow]);
EXPECT_TRUE([controller_ hasTabStrip]);
EXPECT_FALSE([controller_ hasTitleBar]);
EXPECT_TRUE([controller_ isBookmarkBarVisible]);
@@ -125,7 +125,7 @@ TEST_F(BrowserWindowControllerTest, TestNormal) {
BrowserWindowController* controller =
static_cast<BrowserWindowController*>([cocoaWindow windowController]);
ASSERT_TRUE([controller isKindOfClass:[BrowserWindowController class]]);
- EXPECT_FALSE([controller isNormalWindow]);
+ EXPECT_FALSE([controller isTabbedWindow]);
EXPECT_FALSE([controller hasTabStrip]);
EXPECT_TRUE([controller hasTitleBar]);
EXPECT_FALSE([controller isBookmarkBarVisible]);
@@ -154,7 +154,7 @@ TEST_F(BrowserWindowControllerTest, BookmarkBarControllerIndirection) {
TEST_F(BrowserWindowControllerTest, TestIncognitoWidthSpace) {
scoped_ptr<TestingProfile> incognito_profile(new TestingProfile());
incognito_profile->set_off_the_record(true);
- scoped_ptr<Browser> browser(new Browser(Browser::TYPE_NORMAL,
+ scoped_ptr<Browser> browser(new Browser(Browser::TYPE_TABBED,
incognito_profile.get()));
controller_.reset([[BrowserWindowController alloc]
initWithBrowser:browser.get()
diff --git a/chrome/browser/ui/cocoa/extensions/extension_popup_controller_unittest.mm b/chrome/browser/ui/cocoa/extensions/extension_popup_controller_unittest.mm
index 55f8c6c..fd2464f 100644
--- a/chrome/browser/ui/cocoa/extensions/extension_popup_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/extensions/extension_popup_controller_unittest.mm
@@ -73,7 +73,7 @@ class ExtensionPopupControllerTest : public CocoaTest {
CocoaTest::SetUp();
profile_.reset(new ExtensionTestingProfile());
profile_->InitExtensionProfile();
- browser_.reset(new Browser(Browser::TYPE_NORMAL, profile_.get()));
+ browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get()));
[ExtensionPopupController showURL:GURL("http://google.com")
inBrowser:browser_.get()
anchoredAt:NSZeroPoint
diff --git a/chrome/browser/ui/cocoa/framed_browser_window_unittest.mm b/chrome/browser/ui/cocoa/framed_browser_window_unittest.mm
index 8de5ebf..26a730a 100644
--- a/chrome/browser/ui/cocoa/framed_browser_window_unittest.mm
+++ b/chrome/browser/ui/cocoa/framed_browser_window_unittest.mm
@@ -131,7 +131,7 @@ TEST_F(FramedBrowserWindowTest, WindowWidgetLocation) {
isKindOfClass:[BrowserWindowController class]];
[[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] hasTabStrip];
[[[controller expect] andReturnValue:OCMOCK_VALUE(no)] hasTitleBar];
- [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] isNormalWindow];
+ [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] isTabbedWindow];
[window_ setWindowController:controller];
closeBoxControl = [window_ standardWindowButton:NSWindowCloseButton];
diff --git a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm
index ae50e5b..46b3f5d 100644
--- a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm
+++ b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm
@@ -284,7 +284,7 @@
// drop handler when the type of window is known.
BrowserWindowController* windowController =
[BrowserWindowController browserWindowControllerForView:self];
- if ([windowController isNormalWindow])
+ if ([windowController isTabbedWindow])
dropHandler_.reset([[URLDropTargetHandler alloc] initWithView:self]);
}
}
diff --git a/chrome/browser/ui/cocoa/notifications/balloon_controller_unittest.mm b/chrome/browser/ui/cocoa/notifications/balloon_controller_unittest.mm
index 35d8f7d..9d3e144 100644
--- a/chrome/browser/ui/cocoa/notifications/balloon_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/notifications/balloon_controller_unittest.mm
@@ -58,7 +58,7 @@ class BalloonControllerTest : public RenderViewHostTestHarness {
CocoaTest::BootstrapCocoa();
profile_.reset(new TestingProfile());
profile_->CreateRequestContext();
- browser_.reset(new Browser(Browser::TYPE_NORMAL, profile_.get()));
+ browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get()));
collection_.reset(new MockBalloonCollection());
}
diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc
index 1ef312f..8b10866 100644
--- a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc
+++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc
@@ -33,7 +33,7 @@ class BookmarkBarGtkUnittest : public ::testing::Test {
profile_.reset(new TestingProfile());
profile_->CreateBookmarkModel(true);
profile_->BlockUntilBookmarkModelLoaded();
- browser_.reset(new Browser(Browser::TYPE_NORMAL, profile_.get()));
+ browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get()));
origin_provider_.reset(new EmptyTabstripOriginProvider);
bookmark_bar_.reset(new BookmarkBarGtk(NULL, profile_.get(), browser_.get(),
diff --git a/chrome/browser/ui/gtk/browser_titlebar.cc b/chrome/browser/ui/gtk/browser_titlebar.cc
index 14e6d4d..3fd1a25 100644
--- a/chrome/browser/ui/gtk/browser_titlebar.cc
+++ b/chrome/browser/ui/gtk/browser_titlebar.cc
@@ -288,7 +288,7 @@ void BrowserTitlebar::Init() {
gtk_box_pack_start(GTK_BOX(container_hbox_), titlebar_left_buttons_vbox_,
FALSE, FALSE, 0);
if (browser_window_->browser()->profile()->IsOffTheRecord() &&
- browser_window_->browser()->type() == Browser::TYPE_NORMAL) {
+ browser_window_->browser()->is_type_tabbed()) {
titlebar_left_spy_frame_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
gtk_widget_set_no_show_all(titlebar_left_spy_frame_, TRUE);
gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_left_spy_frame_), 0,
@@ -317,7 +317,7 @@ void BrowserTitlebar::Init() {
// We use an alignment to control the titlebar height.
titlebar_alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
- if (browser_window_->browser()->type() == Browser::TYPE_NORMAL) {
+ if (browser_window_->browser()->is_type_tabbed()) {
gtk_box_pack_start(GTK_BOX(container_hbox_), titlebar_alignment_, TRUE,
TRUE, 0);
@@ -449,7 +449,7 @@ void BrowserTitlebar::BuildButtons(const std::string& button_string) {
// If we are in incognito mode, add the spy guy to either the end of the left
// or the beginning of the right depending on which side has fewer buttons.
if (browser_window_->browser()->profile()->IsOffTheRecord() &&
- browser_window_->browser()->type() == Browser::TYPE_NORMAL) {
+ browser_window_->browser()->is_type_tabbed()) {
GtkWidget* spy_guy = gtk_image_new_from_pixbuf(GetOTRAvatar());
gtk_misc_set_alignment(GTK_MISC(spy_guy), 0.0, 1.0);
gtk_widget_set_size_request(spy_guy, -1, 0);
@@ -549,10 +549,9 @@ void BrowserTitlebar::UpdateTitleAndIcon() {
string16 title = browser_window_->browser()->GetWindowTitleForCurrentTab();
gtk_label_set_text(GTK_LABEL(app_mode_title_), UTF16ToUTF8(title).c_str());
- // Note: this isn't browser_window_->browser()->type() & Browser::TYPE_APP
- // because we want to exclude Browser::TYPE_APP_POPUP.
- if (browser_window_->browser()->type() == Browser::TYPE_APP ||
- browser_window_->browser()->type() == Browser::TYPE_APP_PANEL) {
+ // Note: we want to exclude the application popup window.
+ if (browser_window_->browser()->is_app() &&
+ !browser_window_->browser()->is_type_popup()) {
// Update the system app icon. We don't need to update the icon in the top
// left of the custom frame, that will get updated when the throbber is
// updated.
@@ -577,10 +576,9 @@ void BrowserTitlebar::UpdateThrobber(TabContents* tab_contents) {
} else {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- // Note: this isn't browser_window_->browser()->type() & Browser::TYPE_APP
- // because we want to exclude Browser::TYPE_APP_POPUP.
- if (browser_window_->browser()->type() == Browser::TYPE_APP ||
- browser_window_->browser()->type() == Browser::TYPE_APP_PANEL) {
+ // Note: we want to exclude the application popup window.
+ if (browser_window_->browser()->is_app() &&
+ !browser_window_->browser()->is_type_popup()) {
SkBitmap icon = browser_window_->browser()->GetCurrentPageIcon();
if (icon.empty()) {
// Fallback to the Chromium icon if the page has no icon.
@@ -600,7 +598,7 @@ void BrowserTitlebar::UpdateThrobber(TabContents* tab_contents) {
}
void BrowserTitlebar::UpdateTitlebarAlignment() {
- if (browser_window_->browser()->type() == Browser::TYPE_NORMAL) {
+ if (browser_window_->browser()->is_type_tabbed()) {
int top_padding = 0;
int side_padding = 0;
int vertical_offset = kNormalVerticalOffset;
diff --git a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc
index 18a2b54..863fe3d 100644
--- a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc
@@ -630,7 +630,7 @@ void BrowserToolbarGtk::NotifyPrefChanged(const std::string* pref) {
bool BrowserToolbarGtk::ShouldOnlyShowLocation() const {
// If we're a popup window, only show the location bar (omnibox).
- return browser_->type() != Browser::TYPE_NORMAL;
+ return !browser_->is_type_tabbed();
}
gboolean BrowserToolbarGtk::OnWrenchMenuButtonExpose(GtkWidget* sender,
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc
index b79d6ac..8d8f117 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -322,7 +322,7 @@ void BrowserWindowGtk::Init() {
gtk_window_group_add_window(gtk_window_group_new(), window_);
g_object_unref(gtk_window_get_group(window_));
- if (browser_->type() & Browser::TYPE_APP) {
+ if (browser_->is_app()) {
std::string app_name = browser_->app_name();
if (app_name != DevToolsWindow::kDevToolsApp) {
std::string wmclassname = web_app::GetWMClassFromAppName(app_name);
@@ -353,7 +353,7 @@ void BrowserWindowGtk::Init() {
// popups need the widgets inited before they can set the window size
// properly. For other windows, we set the geometry first to prevent resize
// flicker.
- if (browser_->type() & Browser::TYPE_POPUP) {
+ if (browser_->is_type_popup() || browser_->is_type_panel()) {
InitWidgets();
SetGeometryHints();
} else {
@@ -763,7 +763,7 @@ void BrowserWindowGtk::UpdateLoadingAnimations(bool should_animate) {
}
void BrowserWindowGtk::LoadingAnimationCallback() {
- if (browser_->type() == Browser::TYPE_NORMAL) {
+ if (browser_->is_type_tabbed()) {
// Loading animations are shown in the tab for tabbed windows. We check the
// browser type instead of calling IsTabStripVisible() because the latter
// will return false for fullscreen windows, but we still need to update
@@ -1554,11 +1554,12 @@ void BrowserWindowGtk::SetGeometryHints() {
//
// For popup windows, we assume that if x == y == 0, the opening page
// did not specify a position. Let the WM position the popup instead.
- bool is_popup = browser_->type() & Browser::TYPE_POPUP;
- bool popup_without_position = is_popup &&
+ bool is_popup_or_panel = browser_->is_type_popup() ||
+ browser_->is_type_panel();
+ bool popup_without_position = is_popup_or_panel &&
bounds.x() == 0 && bounds.y() == 0;
bool move = browser_->bounds_overridden() && !popup_without_position;
- SetBoundsImpl(bounds, !is_popup, move);
+ SetBoundsImpl(bounds, !is_popup_or_panel, move);
}
void BrowserWindowGtk::ConnectHandlersToSignals() {
@@ -2248,7 +2249,7 @@ bool BrowserWindowGtk::UsingCustomPopupFrame() const {
GtkThemeService* theme_provider = GtkThemeService::GetFrom(
browser()->profile());
return !theme_provider->UsingNativeTheme() &&
- browser()->type() & Browser::TYPE_POPUP;
+ (browser()->is_type_popup() || browser()->is_type_panel());
}
bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) {
@@ -2259,7 +2260,7 @@ bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) {
// detect the window edge for behavioral purposes. The edge if any is present
// only for visual aspects.
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePanels) &&
- browser_->type() == Browser::TYPE_APP_PANEL)
+ browser_->is_type_panel())
return false;
if (IsMaximized() || IsFullscreen())
@@ -2318,13 +2319,11 @@ bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) {
bool BrowserWindowGtk::UseCustomFrame() {
// We always use custom frame for panels.
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePanels) &&
- browser_->type() == Browser::TYPE_APP_PANEL)
+ browser_->is_type_panel())
return true;
// We don't use the custom frame for app mode windows or app window popups.
- return use_custom_frame_pref_.GetValue() &&
- browser_->type() != Browser::TYPE_APP &&
- browser_->type() != Browser::TYPE_APP_POPUP;
+ return use_custom_frame_pref_.GetValue() && !browser_->is_app();
}
bool BrowserWindowGtk::BoundsMatchMonitorSize() {
diff --git a/chrome/browser/ui/gtk/gtk_util.cc b/chrome/browser/ui/gtk/gtk_util.cc
index 547caaa..0776afb 100644
--- a/chrome/browser/ui/gtk/gtk_util.cc
+++ b/chrome/browser/ui/gtk/gtk_util.cc
@@ -1028,10 +1028,8 @@ void GetTextColors(GdkColor* normal_base,
GtkWindow* GetLastActiveBrowserWindow() {
if (Browser* b = BrowserList::GetLastActive()) {
- if (b->type() != Browser::TYPE_NORMAL) {
- b = BrowserList::FindBrowserWithType(b->profile(),
- Browser::TYPE_NORMAL,
- true);
+ if (!b->is_type_tabbed()) {
+ b = BrowserList::FindTabbedBrowser(b->profile(), true);
}
if (b)
diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
index 6941fa1..7e1e60d 100644
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
@@ -1154,7 +1154,7 @@ void LocationBarViewGtk::UpdateStarIcon() {
}
bool LocationBarViewGtk::ShouldOnlyShowLocation() {
- return browser_->type() != Browser::TYPE_NORMAL;
+ return !browser_->is_type_tabbed();
}
void LocationBarViewGtk::AdjustChildrenVisibility() {
diff --git a/chrome/browser/ui/panels/panel_browser_window_gtk_browsertest.cc b/chrome/browser/ui/panels/panel_browser_window_gtk_browsertest.cc
index 3a5ab1b..3421b7a 100644
--- a/chrome/browser/ui/panels/panel_browser_window_gtk_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_browser_window_gtk_browsertest.cc
@@ -22,9 +22,11 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserWindowGtkTest, CreatePanel) {
PanelManager* panel_manager = PanelManager::GetInstance();
EXPECT_EQ(0, panel_manager->active_count()); // No panels initially.
- Browser* panel_browser = Browser::CreateForType(Browser::TYPE_APP_PANEL,
- browser()->profile());
- EXPECT_EQ(Browser::TYPE_APP_PANEL, panel_browser->type());
+ Browser* panel_browser = Browser::CreateForApp(Browser::TYPE_PANEL,
+ "PanelTest",
+ gfx::Size(),
+ browser()->profile());
+ EXPECT_TRUE(panel_browser->is_type_panel());
EXPECT_EQ(1, panel_manager->active_count());
gfx::Rect bounds = panel_browser->window()->GetBounds();
diff --git a/chrome/browser/ui/panels/panel_browsertest.cc b/chrome/browser/ui/panels/panel_browsertest.cc
index 58647a5..7bd45b8 100644
--- a/chrome/browser/ui/panels/panel_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_browsertest.cc
@@ -24,9 +24,9 @@ class PanelBrowserTest : public InProcessBrowserTest {
// Panel is now only supported on windows.
#if defined(OS_WIN)
IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreatePanel) {
- Browser* panel = Browser::CreateForApp("", gfx::Size(),
- browser()->profile(), true);
- EXPECT_EQ(Browser::TYPE_APP_PANEL, panel->type());
+ Browser* panel = Browser::CreateForApp(Browser::TYPE_PANEL, "PanelTest",
+ gfx::Size(), browser()->profile());
+ EXPECT_EQ(Browser::TYPE_PANEL, panel->type());
panel->window()->Show();
panel->window()->Close();
}
diff --git a/chrome/browser/ui/tests/browser_uitest.cc b/chrome/browser/ui/tests/browser_uitest.cc
index ead99ff..7fae5b6 100644
--- a/chrome/browser/ui/tests/browser_uitest.cc
+++ b/chrome/browser/ui/tests/browser_uitest.cc
@@ -306,31 +306,6 @@ TEST_F(LaunchBrowserWithNonAsciiUserDatadir, TestNonAsciiUserDataDir) {
}
#endif // defined(OS_WIN)
-class AppModeTest : public UITest {
- public:
- AppModeTest() {
- // Load a local file.
- FilePath test_file(test_data_directory_);
- test_file = test_file.AppendASCII("title1.html");
- GURL test_file_url(net::FilePathToFileURL(test_file));
-
- launch_arguments_.AppendSwitchASCII(switches::kApp, test_file_url.spec());
- }
-};
-
-TEST_F(AppModeTest, EnableAppModeTest) {
- // Test that an application browser window loads correctly.
-
- // Verify that the window is present.
- scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
- ASSERT_TRUE(browser.get());
-
- // Verify the browser is an application.
- Browser::Type type;
- ASSERT_TRUE(browser->GetType(&type));
- EXPECT_EQ(Browser::TYPE_APP, type);
-}
-
// Tests to ensure that the browser continues running in the background after
// the last window closes.
class RunInBackgroundTest : public UITest {
@@ -352,7 +327,7 @@ TEST_F(RunInBackgroundTest, RunInBackgroundBasicTest) {
ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
EXPECT_EQ(0, window_count);
ASSERT_TRUE(IsBrowserRunning());
- ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, true));
+ ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_TABBED, true));
ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
EXPECT_EQ(1, window_count);
}
@@ -375,9 +350,36 @@ TEST_F(NoStartupWindowTest, NoStartupWindowBasicTest) {
// Starting a browser window should work just fine.
ASSERT_TRUE(IsBrowserRunning());
- ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, true));
+ ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_TABBED, true));
ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
EXPECT_EQ(1, window_count);
}
} // namespace
+
+// This test needs to be placed outside the anonymouse namespace because we
+// need to access private type of Browser.
+class AppModeTest : public UITest {
+ public:
+ AppModeTest() {
+ // Load a local file.
+ FilePath test_file(test_data_directory_);
+ test_file = test_file.AppendASCII("title1.html");
+ GURL test_file_url(net::FilePathToFileURL(test_file));
+
+ launch_arguments_.AppendSwitchASCII(switches::kApp, test_file_url.spec());
+ }
+};
+
+TEST_F(AppModeTest, EnableAppModeTest) {
+ // Test that an application browser window loads correctly.
+
+ // Verify that the window is present.
+ scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get());
+
+ // Verify the browser is in application mode.
+ bool is_application;
+ ASSERT_TRUE(browser->IsApplication(&is_application));
+ EXPECT_TRUE(is_application);
+}
diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc
index f7dbd76..645d0aa 100644
--- a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc
+++ b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc
@@ -497,7 +497,7 @@ TEST_F(BackFwdMenuModelTest, EscapeLabel) {
TEST_F(BackFwdMenuModelTest, FaviconLoadTest) {
profile()->CreateHistoryService(true, false);
profile()->CreateFaviconService();
- Browser browser(Browser::TYPE_NORMAL, profile());
+ Browser browser(Browser::TYPE_TABBED, profile());
FaviconDelegate favicon_delegate;
BackForwardMenuModel back_model(
diff --git a/chrome/browser/ui/touch/frame/browser_non_client_frame_view_factory_touch.cc b/chrome/browser/ui/touch/frame/browser_non_client_frame_view_factory_touch.cc
index 5223640..de4e0ef 100644
--- a/chrome/browser/ui/touch/frame/browser_non_client_frame_view_factory_touch.cc
+++ b/chrome/browser/ui/touch/frame/browser_non_client_frame_view_factory_touch.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -11,7 +11,8 @@ namespace browser {
BrowserNonClientFrameView* CreateBrowserNonClientFrameView(
BrowserFrame* frame, BrowserView* browser_view) {
- if (browser_view->IsBrowserTypePopup()) {
+ if (browser_view->IsBrowserTypePopup() ||
+ browser_view->IsBrowserTypePanel()) {
// TODO(anicolao): implement popups for touch
NOTIMPLEMENTED();
return NULL;
diff --git a/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc b/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc
index 2b9ede0..27a52e2 100644
--- a/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc
+++ b/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc
@@ -319,10 +319,8 @@ void ShowExtensionInstallDialog(
const std::vector<string16>& permissions,
ExtensionInstallUI::PromptType type) {
#if defined(OS_CHROMEOS)
- // Use a normal browser window as parent on ChromeOS.
- Browser* browser = BrowserList::FindBrowserWithType(profile,
- Browser::TYPE_NORMAL,
- true);
+ // Use a tabbed browser window as parent on ChromeOS.
+ Browser* browser = BrowserList::FindTabbedBrowser(profile, true);
#else
Browser* browser = BrowserList::GetLastActiveWithProfile(profile);
#endif
diff --git a/chrome/browser/ui/views/file_manager_dialogs.cc b/chrome/browser/ui/views/file_manager_dialogs.cc
index acea5c9..1d3c076 100644
--- a/chrome/browser/ui/views/file_manager_dialogs.cc
+++ b/chrome/browser/ui/views/file_manager_dialogs.cc
@@ -176,7 +176,7 @@ void FileManagerDialog::SelectFileImpl(
if (browser_mode_) {
Browser* browser = BrowserList::GetLastActive();
if (browser) {
- DCHECK_EQ(browser->type(), Browser::TYPE_NORMAL);
+ DCHECK_EQ(browser->type(), Browser::TYPE_TABBED);
CreateHtmlDialogView(browser->profile(), params);
return;
}
diff --git a/chrome/browser/ui/views/frame/browser_frame_win.cc b/chrome/browser/ui/views/frame/browser_frame_win.cc
index e537d99..49e14db 100644
--- a/chrome/browser/ui/views/frame/browser_frame_win.cc
+++ b/chrome/browser/ui/views/frame/browser_frame_win.cc
@@ -207,7 +207,7 @@ ui::ThemeProvider* BrowserFrameWin::GetThemeProviderForFrame() const {
bool BrowserFrameWin::AlwaysUseNativeFrame() const {
// App panel windows draw their own frame.
- if (browser_view_->IsBrowserTypePanel())
+ if (browser_view_->IsBrowserTypePanel() && browser_view_->IsBrowserTypeApp())
return false;
// We don't theme popup or app windows, so regardless of whether or not a
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_factory_gtk.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_factory_gtk.cc
index 93b2c8c..cda4b37 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_factory_gtk.cc
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_factory_gtk.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,7 +12,7 @@ namespace browser {
BrowserNonClientFrameView* CreateBrowserNonClientFrameView(
BrowserFrame* frame, BrowserView* browser_view) {
- if (browser_view->IsBrowserTypePopup())
+ if (browser_view->IsBrowserTypePopup() || browser_view->IsBrowserTypePanel())
return new PopupNonClientFrameView();
else
return new OpaqueBrowserFrameView(frame, browser_view);
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 263d218..f95a326 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -143,10 +143,10 @@ const char BrowserView::kViewClassName[] = "browser/ui/views/BrowserView";
// normal browser.
static gfx::NativeWindow GetNormalBrowserWindowForBrowser(Browser* browser,
Profile* profile) {
- if (browser->type() != Browser::TYPE_NORMAL) {
- Browser* normal_browser = BrowserList::FindBrowserWithType(
+ if (!browser->is_type_tabbed()) {
+ Browser* normal_browser = BrowserList::FindTabbedBrowser(
profile ? profile : browser->profile(),
- Browser::TYPE_NORMAL, true);
+ true);
if (normal_browser && normal_browser->window())
return normal_browser->window()->GetNativeHandle();
}
@@ -1440,7 +1440,7 @@ bool BrowserView::ShouldShowWindowTitle() const {
}
SkBitmap BrowserView::GetWindowAppIcon() {
- if (browser_->type() & Browser::TYPE_APP) {
+ if (browser_->is_app()) {
TabContentsWrapper* contents = browser_->GetSelectedTabContentsWrapper();
if (contents && contents->extension_tab_helper()->GetExtensionAppIcon())
return *contents->extension_tab_helper()->GetExtensionAppIcon();
@@ -1450,7 +1450,7 @@ SkBitmap BrowserView::GetWindowAppIcon() {
}
SkBitmap BrowserView::GetWindowIcon() {
- if (browser_->type() & Browser::TYPE_APP)
+ if (browser_->is_app())
return browser_->GetCurrentPageIcon();
return SkBitmap();
}
@@ -1488,7 +1488,7 @@ void BrowserView::SaveWindowPlacement(const gfx::Rect& bounds,
bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const {
*bounds = browser_->GetSavedWindowBounds();
- if (browser_->type() & Browser::TYPE_POPUP) {
+ if (browser_->is_type_popup() || browser_->is_type_panel()) {
// We are a popup window. The value passed in |bounds| represents two
// pieces of information:
// - the position of the window, in screen coordinates (outer position).
@@ -1854,7 +1854,7 @@ void BrowserView::LoadingAnimationCallback() {
now - last_animation_time_);
}
last_animation_time_ = now;
- if (browser_->type() == Browser::TYPE_NORMAL) {
+ if (browser_->is_type_tabbed()) {
// Loading animations are shown in the tab for tabbed windows. We check the
// browser type instead of calling IsTabStripVisible() because the latter
// will return false for fullscreen windows, but we still need to update
@@ -1881,7 +1881,7 @@ void BrowserView::InitSystemMenu() {
if (IsBrowserTypeNormal())
BuildSystemMenuForBrowserWindow();
else
- BuildSystemMenuForAppOrPopupWindow(browser_->type() == Browser::TYPE_APP);
+ BuildSystemMenuForAppOrPopupWindow();
system_menu_.reset(
new views::NativeMenuWin(system_menu_contents_.get(),
frame_->GetWindow()->GetNativeWindow()));
@@ -2247,8 +2247,8 @@ void BrowserView::BuildSystemMenuForBrowserWindow() {
// since it already has menus (Page, Chrome).
}
-void BrowserView::BuildSystemMenuForAppOrPopupWindow(bool is_app) {
- if (is_app) {
+void BrowserView::BuildSystemMenuForAppOrPopupWindow() {
+ if (browser_->is_app()) {
system_menu_contents_->AddSeparator();
system_menu_contents_->AddItemWithStringId(IDC_TASK_MANAGER,
IDS_TASK_MANAGER);
@@ -2268,7 +2268,7 @@ void BrowserView::BuildSystemMenuForAppOrPopupWindow(bool is_app) {
system_menu_contents_->AddItemWithStringId(IDC_COPY, IDS_COPY);
system_menu_contents_->AddItemWithStringId(IDC_CUT, IDS_CUT);
system_menu_contents_->AddSeparator();
- if (is_app) {
+ if (browser_->is_app()) {
system_menu_contents_->AddItemWithStringId(IDC_NEW_TAB,
IDS_APP_MENU_NEW_WEB_PAGE);
} else {
diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h
index 0184d14..c80cee6 100644
--- a/chrome/browser/ui/views/frame/browser_view.h
+++ b/chrome/browser/ui/views/frame/browser_view.h
@@ -185,21 +185,27 @@ class BrowserView : public BrowserBubbleHost,
#endif
// Returns true if the Browser object associated with this BrowserView is a
- // normal-type window (i.e. a browser window, not an app or popup).
+ // tabbed-type window (i.e. a browser window, not an app or popup).
bool IsBrowserTypeNormal() const {
- return browser_->type() == Browser::TYPE_NORMAL;
+ return browser_->is_type_tabbed();
}
// Returns true if the Browser object associated with this BrowserView is a
- // app panel window.
+ // panel window.
bool IsBrowserTypePanel() const {
- return browser_->type() == Browser::TYPE_APP_PANEL;
+ return browser_->is_type_panel();
}
// Returns true if the Browser object associated with this BrowserView is a
// popup window.
bool IsBrowserTypePopup() const {
- return (browser_->type() & Browser::TYPE_POPUP) != 0;
+ return browser_->is_type_popup();
+ }
+
+ // Returns true if the Browser object associated with this BrowserView
+ // represents an app.
+ bool IsBrowserTypeApp() const {
+ return browser_->is_app();
}
// Register preferences specific to this view.
@@ -492,7 +498,7 @@ class BrowserView : public BrowserBubbleHost,
#if defined(OS_WIN)
// Builds the correct menu for when we have minimal chrome.
void BuildSystemMenuForBrowserWindow();
- void BuildSystemMenuForAppOrPopupWindow(bool is_app);
+ void BuildSystemMenuForAppOrPopupWindow();
#endif
// Retrieves the command id for the specified Windows app command.
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
index 663dc7e..69f3565 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
@@ -1069,7 +1069,7 @@ void OpaqueBrowserFrameView::LayoutWindowControls() {
restore_button_->SetVisible(false);
maximize_button_->SetVisible(false);
- if (browser_view_->browser()->type() == Browser::TYPE_DEVTOOLS) {
+ if (browser_view_->browser()->is_devtools()) {
close_button_->SetVisible(true);
minimize_button_->SetBounds(close_button_->bounds().x(), 0, 0, 0);
} else {
diff --git a/chrome/browser/ui/webui/active_downloads_ui.cc b/chrome/browser/ui/webui/active_downloads_ui.cc
index 35fcf0e..9bd9ddd 100644
--- a/chrome/browser/ui/webui/active_downloads_ui.cc
+++ b/chrome/browser/ui/webui/active_downloads_ui.cc
@@ -61,6 +61,7 @@ static const int kPopupHeight = 36 * 2 + 29;
static const char kPropertyPath[] = "path";
static const char kPropertyTitle[] = "title";
static const char kPropertyDirectory[] = "isDirectory";
+static const char kActiveDownloadAppName[] = "active-downloads";
class ActiveDownloadsUIHTMLSource : public ChromeURLDataManager::DataSource {
public:
@@ -282,7 +283,8 @@ void ActiveDownloadsHandler::OpenNewPopupWindow(const ListValue* args) {
void ActiveDownloadsHandler::OpenNewWindow(const ListValue* args, bool popup) {
std::string url = UTF16ToUTF8(ExtractStringValue(args));
Browser* browser = popup ?
- Browser::CreateForType(Browser::TYPE_APP_PANEL, profile_) :
+ Browser::CreateForApp(Browser::TYPE_PANEL, kActiveDownloadAppName,
+ gfx::Size(), profile_) :
BrowserList::GetLastActive();
browser::NavigateParams params(browser, GURL(url), PageTransition::LINK);
params.disposition = NEW_FOREGROUND_TAB;
@@ -386,7 +388,8 @@ Browser* ActiveDownloadsUI::OpenPopup(Profile* profile) {
// Create new browser if no matching pop up is found.
if (browser == NULL) {
- browser = Browser::CreateForType(Browser::TYPE_APP_PANEL, profile);
+ browser = Browser::CreateForApp(Browser::TYPE_PANEL, kActiveDownloadAppName,
+ gfx::Size(), profile);
browser::NavigateParams params(
browser,
@@ -412,7 +415,7 @@ Browser* ActiveDownloadsUI::GetPopup(Profile* profile) {
for (BrowserList::const_iterator it = BrowserList::begin();
it != BrowserList::end();
++it) {
- if (((*it)->type() == Browser::TYPE_APP_PANEL)) {
+ if ((*it)->is_type_panel() && (*it)->is_app()) {
TabContents* tab_contents = (*it)->GetSelectedTabContents();
DCHECK(tab_contents);
if (!tab_contents)
diff --git a/chrome/browser/ui/webui/mediaplayer_browsertest.cc b/chrome/browser/ui/webui/mediaplayer_browsertest.cc
index 0d5fb19..2bd67e4 100644
--- a/chrome/browser/ui/webui/mediaplayer_browsertest.cc
+++ b/chrome/browser/ui/webui/mediaplayer_browsertest.cc
@@ -28,7 +28,7 @@ class MediaPlayerBrowserTest : public InProcessBrowserTest {
bool IsPlayerVisible() {
for (BrowserList::const_iterator it = BrowserList::begin();
it != BrowserList::end(); ++it) {
- if ((*it)->type() == Browser::TYPE_APP_PANEL) {
+ if ((*it)->is_type_panel() && (*it)->is_app()) {
const GURL& url =
(*it)->GetTabContentsAt((*it)->active_index())->GetURL();
@@ -44,7 +44,7 @@ class MediaPlayerBrowserTest : public InProcessBrowserTest {
bool IsPlaylistVisible() {
for (BrowserList::const_iterator it = BrowserList::begin();
it != BrowserList::end(); ++it) {
- if ((*it)->type() == Browser::TYPE_APP_PANEL) {
+ if ((*it)->is_type_panel() && (*it)->is_app()) {
const GURL& url =
(*it)->GetTabContentsAt((*it)->active_index())->GetURL();
diff --git a/chrome/browser/ui/webui/mediaplayer_ui.cc b/chrome/browser/ui/webui/mediaplayer_ui.cc
index c6bfaa6..0f7523c 100644
--- a/chrome/browser/ui/webui/mediaplayer_ui.cc
+++ b/chrome/browser/ui/webui/mediaplayer_ui.cc
@@ -55,6 +55,7 @@ static const char kPropertyError[] = "error";
static const char* kMediaplayerURL = "chrome://mediaplayer";
static const char* kMediaplayerPlaylistURL = "chrome://mediaplayer#playlist";
+static const char* kMediaPlayerAppName = "mediaplayer";
static const int kPopupLeft = 0;
static const int kPopupTop = 0;
static const int kPopupWidth = 350;
@@ -504,8 +505,10 @@ void MediaPlayer::RemoveHandler(MediaplayerHandler* handler) {
void MediaPlayer::PopupPlaylist(Browser* creator) {
Profile* profile = BrowserList::GetLastActive()->profile();
- playlist_browser_ = Browser::CreateForType(Browser::TYPE_APP_PANEL,
- profile);
+ playlist_browser_ = Browser::CreateForApp(Browser::TYPE_PANEL,
+ kMediaPlayerAppName,
+ gfx::Size(),
+ profile);
playlist_browser_->AddSelectedTabWithURL(GURL(kMediaplayerPlaylistURL),
PageTransition::LINK);
playlist_browser_->window()->SetBounds(gfx::Rect(kPopupLeft,
@@ -524,8 +527,10 @@ void MediaPlayer::PopupMediaPlayer(Browser* creator) {
return;
}
Profile* profile = BrowserList::GetLastActive()->profile();
- mediaplayer_browser_ = Browser::CreateForType(Browser::TYPE_APP_PANEL,
- profile);
+ mediaplayer_browser_ = Browser::CreateForApp(Browser::TYPE_PANEL,
+ kMediaPlayerAppName,
+ gfx::Size(),
+ profile);
#if defined(OS_CHROMEOS)
// Since we are on chromeos, popups should be a PanelBrowserView,
// so we can just cast it.
diff --git a/chrome/browser/ui/window_sizer.cc b/chrome/browser/ui/window_sizer.cc
index e5663d2..2c46c0c 100644
--- a/chrome/browser/ui/window_sizer.cc
+++ b/chrome/browser/ui/window_sizer.cc
@@ -83,7 +83,7 @@ class DefaultStateProvider : public WindowSizer::StateProvider {
BrowserList::const_reverse_iterator end = BrowserList::end_last_active();
for (; (it != end); ++it) {
Browser* last_active = *it;
- if (last_active && last_active->type() == Browser::TYPE_NORMAL) {
+ if (last_active && last_active->is_type_tabbed()) {
window = last_active->window();
DCHECK(window);
break;