Chromium Code Reviews| Index: chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc |
| diff --git a/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc b/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc |
| index 42ae188e229b87be87f93d236ee9a4b3ecab198d..9016ed36979c8fb4df0a6baef5063936dc15aa3e 100644 |
| --- a/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc |
| +++ b/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc |
| @@ -4,10 +4,12 @@ |
| #include "chrome/browser/ui/extensions/app_metro_infobar_delegate_win.h" |
| +#include "apps/app_launch_for_metro_restart_win.h" |
| #include "base/bind_helpers.h" |
| #include "base/message_loop.h" |
| #include "base/prefs/pref_service.h" |
| #include "chrome/browser/browser_process.h" |
| +#include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_finder.h" |
| #include "chrome/browser/ui/browser_window.h" |
| @@ -25,10 +27,17 @@ |
| namespace chrome { |
| -void AppMetroInfoBarDelegateWin::CreateAndActivateMetro(Profile* profile) { |
| +// static |
| +void AppMetroInfoBarDelegateWin::Create( |
| + Profile* profile, Mode mode, const std::string& extension_id) { |
| + if (!win8::IsSingleWindowMetroMode() || |
|
Peter Kasting
2013/03/22 19:48:21
Nit: Simpler, more similar to constructor, and com
tapted
2013/03/24 22:02:46
Done.
|
| + (mode == LAUNCH_PACKAGED_APP && extension_id.empty())) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| // Chrome should never get here via the Ash desktop, so only look for browsers |
| // on the native desktop. |
| - CHECK(win8::IsSingleWindowMetroMode()); |
| Browser* browser = FindOrCreateTabbedBrowser( |
| profile, chrome::HOST_DESKTOP_TYPE_NATIVE); |
| @@ -42,7 +51,7 @@ void AppMetroInfoBarDelegateWin::CreateAndActivateMetro(Profile* profile) { |
| InfoBarService* info_bar_service = |
| InfoBarService::FromWebContents(web_contents); |
| info_bar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( |
| - new AppMetroInfoBarDelegateWin(info_bar_service))); |
| + new AppMetroInfoBarDelegateWin(info_bar_service, mode, extension_id))); |
| // Use PostTask because we can get here in a COM SendMessage, and |
| // ActivateApplication can not be sent nested (returns error |
| @@ -53,8 +62,13 @@ void AppMetroInfoBarDelegateWin::CreateAndActivateMetro(Profile* profile) { |
| } |
| AppMetroInfoBarDelegateWin::AppMetroInfoBarDelegateWin( |
| - InfoBarService* info_bar_service) |
| - : ConfirmInfoBarDelegate(info_bar_service) { |
| + InfoBarService* info_bar_service, |
| + Mode mode, |
| + const std::string& extension_id) |
| + : ConfirmInfoBarDelegate(info_bar_service), |
| + mode_(mode), |
| + extension_id_(extension_id) { |
| + DCHECK_EQ(mode_ == SHOW_APP_LIST, extension_id_.empty()); |
| } |
| AppMetroInfoBarDelegateWin::~AppMetroInfoBarDelegateWin() {} |
| @@ -64,8 +78,9 @@ gfx::Image* AppMetroInfoBarDelegateWin::GetIcon() const { |
| } |
| string16 AppMetroInfoBarDelegateWin::GetMessageText() const { |
| - return l10n_util::GetStringUTF16( |
| - IDS_WIN8_INFOBAR_DESKTOP_RESTART_TO_LAUNCH_APPS); |
| + return l10n_util::GetStringUTF16(mode_ == SHOW_APP_LIST ? |
| + IDS_WIN8_INFOBAR_DESKTOP_RESTART_FOR_APP_LIST : |
| + IDS_WIN8_INFOBAR_DESKTOP_RESTART_FOR_PACKAGED_APP); |
| } |
| int AppMetroInfoBarDelegateWin::GetButtons() const { |
| @@ -84,9 +99,17 @@ string16 AppMetroInfoBarDelegateWin::GetButtonLabel( |
| } |
| bool AppMetroInfoBarDelegateWin::Accept() { |
| - owner()->GetWebContents()->Close(); |
| PrefService* prefs = g_browser_process->local_state(); |
| - prefs->SetBoolean(prefs::kRestartWithAppList, true); |
| + content::WebContents* web_contents = owner()->GetWebContents(); |
| + if (mode_ == SHOW_APP_LIST) { |
| + prefs->SetBoolean(prefs::kRestartWithAppList, true); |
| + } else { |
| + apps::SetAppLaunchForMetroRestart( |
| + Profile::FromBrowserContext(web_contents->GetBrowserContext()), |
| + extension_id_); |
| + } |
| + |
| + web_contents->Close(); // Note: deletes |this|. |
| chrome::AttemptRestartWithModeSwitch(); |
| return false; |
| } |