#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/chrome_pages.h"
+#include "chrome/browser/ui/settings_window_manager.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/extensions/extension_constants.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/common/url_constants.h"
#include "grit/ash_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "ui/gfx/image/image.h"
#include "ui/wm/core/window_animations.h"
+namespace {
+
+bool IsSettingsBrowser(Browser* browser) {
+ // Normally this test is sufficient. TODO(stevenjb): Replace this with a
+ // better mechanism (Settings WebUI or Browser type).
+ if (chrome::IsTrustedPopupWindowWithScheme(browser, content::kChromeUIScheme))
+ return true;
+ // If a settings window navigates away from a kChromeUIScheme (e.g. after a
+ // crash), the above may not be true, so also test against the known list
+ // of settings browsers (which will not be valid during chrome::Navigate
+ // which is why we still need the above test).
+ if (chrome::SettingsWindowManager::GetInstance()->IsSettingsBrowser(browser))
+ return true;
+ return false;
+}
+
+} // namespace
+
BrowserShortcutLauncherItemController::BrowserShortcutLauncherItemController(
ChromeLauncherController* launcher_controller)
: LauncherItemController(TYPE_SHORTCUT,
}
}
+void BrowserShortcutLauncherItemController::SetShelfIDForBrowserWindowContents(
+ Browser* browser,
+ content::WebContents* web_contents) {
+ // We need to call SetShelfIDForWindow for V1 applications since they are
+ // content which might change and as such change the application type.
+ if (!browser ||
+ !launcher_controller()->IsBrowserFromActiveUser(browser) ||
+ browser->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH ||
+ IsSettingsBrowser(browser))
+ return;
+
+ ash::SetShelfIDForWindow(
+ launcher_controller()->GetShelfIDForWebContents(web_contents),
+ browser->window()->GetNativeWindow());
+}
+
bool BrowserShortcutLauncherItemController::IsOpen() const {
const BrowserList* ash_browser_list =
BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
gfx::Image BrowserShortcutLauncherItemController::GetBrowserListIcon(
content::WebContents* web_contents) const {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
return rb.GetImageNamed(IsIncognito(web_contents) ?
- IDR_AURA_LAUNCHER_LIST_INCOGNITO_BROWSER :
- IDR_AURA_LAUNCHER_LIST_BROWSER);
+ IDR_ASH_SHELF_LIST_INCOGNITO_BROWSER :
+ IDR_ASH_SHELF_LIST_BROWSER);
}
base::string16 BrowserShortcutLauncherItemController::GetBrowserListTitle(
bool BrowserShortcutLauncherItemController::IsBrowserRepresentedInBrowserList(
Browser* browser) {
- return (browser &&
- launcher_controller()->IsBrowserFromActiveUser(browser) &&
- browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH &&
- (browser->is_type_tabbed() ||
- !browser->is_app() ||
- !browser->is_type_popup() ||
- launcher_controller()->
- GetShelfIDForAppID(web_app::GetExtensionIdFromApplicationName(
- browser->app_name())) <= 0));
+ // Only Ash desktop browser windows for the active user are represented.
+ if (!browser ||
+ !launcher_controller()->IsBrowserFromActiveUser(browser) ||
+ browser->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH)
+ return false;
+
+ // v1 App popup windows with a valid app id have their own icon.
+ if (browser->is_app() &&
+ browser->is_type_popup() &&
+ launcher_controller()->GetShelfIDForAppID(
+ web_app::GetExtensionIdFromApplicationName(browser->app_name())) > 0)
+ return false;
+
+ // Settings browsers have their own icon.
+ if (IsSettingsBrowser(browser))
+ return false;
+
+ // Tabbed browser and other popup windows are all represented.
+ return true;
}