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

Side by Side Diff: chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc

Issue 22992003: Moved chrome/browser/ui/extensions apps code to chrome/browser/ui/apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Win compile Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/extensions/app_metro_infobar_delegate_win.h"
6
7 #include "apps/app_launch_for_metro_restart_win.h"
8 #include "base/bind_helpers.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/prefs/pref_service.h"
11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/metro_utils/metro_chrome_win.h"
13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/app_list/app_list_service_win.h"
15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_finder.h"
17 #include "chrome/browser/ui/browser_window.h"
18 #include "chrome/browser/ui/host_desktop.h"
19 #include "chrome/common/pref_names.h"
20 #include "content/public/browser/web_contents.h"
21 #include "content/public/common/url_constants.h"
22 #include "grit/generated_resources.h"
23 #include "grit/google_chrome_strings.h"
24 #include "ui/base/l10n/l10n_util.h"
25 #include "win8/util/win8_util.h"
26
27 // static
28 void AppMetroInfoBarDelegateWin::Create(
29 Profile* profile,
30 Mode mode,
31 const std::string& extension_id) {
32 DCHECK(win8::IsSingleWindowMetroMode());
33 DCHECK_EQ(mode == SHOW_APP_LIST, extension_id.empty());
34
35 // Chrome should never get here via the Ash desktop, so only look for browsers
36 // on the native desktop.
37 Browser* browser = FindOrCreateTabbedBrowser(
38 profile, chrome::HOST_DESKTOP_TYPE_NATIVE);
39
40 // Create a new tab at about:blank, and add the infobar.
41 content::WebContents* web_contents = browser->OpenURL(content::OpenURLParams(
42 GURL(content::kAboutBlankURL), content::Referrer(), NEW_FOREGROUND_TAB,
43 content::PAGE_TRANSITION_LINK, false));
44 InfoBarService* info_bar_service =
45 InfoBarService::FromWebContents(web_contents);
46 info_bar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
47 new AppMetroInfoBarDelegateWin(info_bar_service, mode, extension_id)));
48
49 // Use PostTask because we can get here in a COM SendMessage, and
50 // ActivateApplication can not be sent nested (returns error
51 // RPC_E_CANTCALLOUT_ININPUTSYNCCALL).
52 base::MessageLoop::current()->PostTask(
53 FROM_HERE, base::Bind(base::IgnoreResult(chrome::ActivateMetroChrome)));
54 }
55
56 AppMetroInfoBarDelegateWin::AppMetroInfoBarDelegateWin(
57 InfoBarService* info_bar_service,
58 Mode mode,
59 const std::string& extension_id)
60 : ConfirmInfoBarDelegate(info_bar_service),
61 mode_(mode),
62 extension_id_(extension_id) {
63 DCHECK_EQ(mode_ == SHOW_APP_LIST, extension_id_.empty());
64 }
65
66 AppMetroInfoBarDelegateWin::~AppMetroInfoBarDelegateWin() {}
67
68 int AppMetroInfoBarDelegateWin::GetIconID() const {
69 return chrome::GetAppListIconResourceId();
70 }
71
72 string16 AppMetroInfoBarDelegateWin::GetMessageText() const {
73 return l10n_util::GetStringUTF16(mode_ == SHOW_APP_LIST ?
74 IDS_WIN8_INFOBAR_DESKTOP_RESTART_FOR_APP_LIST :
75 IDS_WIN8_INFOBAR_DESKTOP_RESTART_FOR_PACKAGED_APP);
76 }
77
78 string16 AppMetroInfoBarDelegateWin::GetButtonLabel(
79 InfoBarButton button) const {
80 return l10n_util::GetStringUTF16(button == BUTTON_CANCEL ?
81 IDS_WIN8_INFOBAR_DESKTOP_RESTART_TO_LAUNCH_APPS_NO_BUTTON :
82 IDS_WIN8_INFOBAR_DESKTOP_RESTART_TO_LAUNCH_APPS_YES_BUTTON);
83 }
84
85 bool AppMetroInfoBarDelegateWin::Accept() {
86 PrefService* prefs = g_browser_process->local_state();
87 if (mode_ == SHOW_APP_LIST) {
88 prefs->SetBoolean(prefs::kRestartWithAppList, true);
89 } else {
90 apps::SetAppLaunchForMetroRestart(
91 Profile::FromBrowserContext(web_contents()->GetBrowserContext()),
92 extension_id_);
93 }
94
95 web_contents()->Close(); // Note: deletes |this|.
96 chrome::AttemptRestartWithModeSwitch();
97 return false;
98 }
99
100 bool AppMetroInfoBarDelegateWin::Cancel() {
101 web_contents()->Close();
102 return false;
103 }
104
105 string16 AppMetroInfoBarDelegateWin::GetLinkText() const {
106 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
107 }
108
109 bool AppMetroInfoBarDelegateWin::LinkClicked(
110 WindowOpenDisposition disposition) {
111 web_contents()->OpenURL(content::OpenURLParams(
112 GURL("https://support.google.com/chrome/?p=ib_redirect_to_desktop"),
113 content::Referrer(),
114 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
115 content::PAGE_TRANSITION_LINK, false));
116 return false;
117 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/extensions/app_metro_infobar_delegate_win.h ('k') | chrome/browser/ui/extensions/apps_metro_handler_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698