summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-05 23:31:23 +0000
committergrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-05 23:31:23 +0000
commitd1fa3fbb09712181bb7675ef7e9b892b2911c0a5 (patch)
treefb659390e63f741c7f26d41defb284d8d28955e3
parenta77809f6c4c703fbb9c34a47cf24e3b77056a02f (diff)
downloadchromium_src-d1fa3fbb09712181bb7675ef7e9b892b2911c0a5.zip
chromium_src-d1fa3fbb09712181bb7675ef7e9b892b2911c0a5.tar.gz
chromium_src-d1fa3fbb09712181bb7675ef7e9b892b2911c0a5.tar.bz2
No longer switch to metro mode when Chrome is made the default on first run.
BUG=145795 TEST=delete "First Run" beacon and profile dir, make IE the default, launch Chrome, make it the default when asked, and note that you're left in desktop Chrome rather than switched to metro. Review URL: https://chromiumcodereview.appspot.com/10910086 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155048 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/win/metro.cc2
-rw-r--r--base/win/metro.h6
-rw-r--r--chrome/browser/shell_integration.h5
-rw-r--r--chrome/browser/shell_integration_win.cc48
-rw-r--r--chrome/browser/ui/webui/set_as_default_browser_ui.cc101
5 files changed, 22 insertions, 140 deletions
diff --git a/base/win/metro.cc b/base/win/metro.cc
index 6cc8a85..9e0e043 100644
--- a/base/win/metro.cc
+++ b/base/win/metro.cc
@@ -12,8 +12,6 @@
namespace base {
namespace win {
-const char kActivateApplication[] = "ActivateApplication";
-
HMODULE GetMetroModule() {
const HMODULE kUninitialized = reinterpret_cast<HMODULE>(1);
static HMODULE metro_module = kUninitialized;
diff --git a/base/win/metro.h b/base/win/metro.h
index a500174..87b603b 100644
--- a/base/win/metro.h
+++ b/base/win/metro.h
@@ -42,12 +42,6 @@ struct CurrentTabInfo {
wchar_t* url;
};
-// The types of exports in metro_driver.dll.
-typedef HRESULT (*ActivateApplicationFn)(const wchar_t*);
-
-// The names of the exports in metro_driver.dll.
-BASE_EXPORT extern const char kActivateApplication[];
-
// Returns the handle to the metro dll loaded in the process. A NULL return
// indicates that the metro dll was not loaded in the process.
BASE_EXPORT HMODULE GetMetroModule();
diff --git a/chrome/browser/shell_integration.h b/chrome/browser/shell_integration.h
index e5ef657..9eb9b37 100644
--- a/chrome/browser/shell_integration.h
+++ b/chrome/browser/shell_integration.h
@@ -146,11 +146,6 @@ class ShellIntegration {
// see http://crbug.com/28104
static void MigrateChromiumShortcuts();
- // Activates Chrome in metro-mode on Windows 8. Returns false if called on
- // earlier versions of Windows, if called from within metro-mode, if Chrome
- // is not the default browser, or if an actual error occurs.
- static bool ActivateMetroChrome();
-
// Returns the path to the Start Menu shortcut for the given Chrome.
static FilePath GetStartMenuShortcut(const FilePath& chrome_exe);
#endif // defined(OS_WIN)
diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc
index 7cdb24e..97dae75 100644
--- a/chrome/browser/shell_integration_win.cc
+++ b/chrome/browser/shell_integration_win.cc
@@ -14,12 +14,10 @@
#include "base/file_util.h"
#include "base/message_loop.h"
#include "base/path_service.h"
-#include "base/scoped_native_library.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
-#include "base/win/metro.h"
#include "base/win/registry.h"
#include "base/win/scoped_co_mem.h"
#include "base/win/scoped_comptr.h"
@@ -389,40 +387,6 @@ void MigrateChromiumShortcutsCallback() {
}
}
-// Activates the application with the given AppUserModelId.
-bool ActivateApplication(const string16& app_id) {
- // Not supported when running in metro mode.
- // TODO(grt) This should perhaps check that this Chrome isn't in metro mode
- // or, if it is, that |app_id| doesn't identify this Chrome.
- if (base::win::IsMetroProcess())
- return false;
-
- // Delegate to metro_driver, which has the brains to invoke the activation
- // wizardry.
- bool success = false;
- const FilePath metro_driver_path(chrome::kMetroDriverDll);
- base::ScopedNativeLibrary metro_driver(metro_driver_path);
- if (!metro_driver.is_valid()) {
- PLOG(ERROR) << "Failed to load metro_driver.";
- } else {
- base::win::ActivateApplicationFn activate_application =
- reinterpret_cast<base::win::ActivateApplicationFn>(
- metro_driver.GetFunctionPointer(base::win::kActivateApplication));
- if (!activate_application) {
- PLOG(ERROR) << "Failed to find activation method in metro_driver.";
- } else {
- HRESULT hr = activate_application(app_id.c_str());
- if (FAILED(hr)) {
- LOG(ERROR) << "Failed to activate " << app_id
- << "; hr=0x" << std::hex << hr;
- } else {
- success = true;
- }
- }
- }
- return success;
-}
-
} // namespace
ShellIntegration::DefaultWebClientSetPermission
@@ -601,18 +565,6 @@ void ShellIntegration::MigrateChromiumShortcuts() {
base::Bind(&MigrateChromiumShortcutsCallback));
}
-bool ShellIntegration::ActivateMetroChrome() {
- BrowserDistribution* dist = BrowserDistribution::GetDistribution();
- FilePath chrome_exe;
- if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
- NOTREACHED();
- return false;
- }
- const string16 app_id(
- ShellUtil::GetBrowserModelId(dist, chrome_exe.value()));
- return ActivateApplication(app_id);
-}
-
FilePath ShellIntegration::GetStartMenuShortcut(const FilePath& chrome_exe) {
static const int kFolderIds[] = {
base::DIR_COMMON_START_MENU,
diff --git a/chrome/browser/ui/webui/set_as_default_browser_ui.cc b/chrome/browser/ui/webui/set_as_default_browser_ui.cc
index 1e68b3e..7924a49 100644
--- a/chrome/browser/ui/webui/set_as_default_browser_ui.cc
+++ b/chrome/browser/ui/webui/set_as_default_browser_ui.cc
@@ -79,7 +79,6 @@ ChromeWebUIDataSource* CreateSetAsDefaultBrowserUIHTMLSource() {
// interaction.
class ResponseDelegate {
public:
- virtual void SetChromeShutdownRequired(bool shutdown_chrome) = 0;
virtual void SetDialogInteractionResult(MakeChromeDefaultResult result) = 0;
protected:
@@ -111,12 +110,7 @@ class SetAsDefaultBrowserHandler
void HandleLaunchSetDefaultBrowserFlow(const ListValue* args);
// Close this web ui.
- void ConcludeInteraction(bool mark_success);
-
- // If required and possible, spawns a new Chrome in Metro mode and closes the
- // current instance. Windows 8 only, on earlier systems it will simply close
- // this UI.
- void ActivateMetroChrome();
+ void ConcludeInteraction(MakeChromeDefaultResult interaction_result);
scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_;
bool set_default_returned_;
@@ -155,29 +149,14 @@ void SetAsDefaultBrowserHandler::SetDefaultWebClientUIState(
if (state == ShellIntegration::STATE_NOT_DEFAULT && set_default_result_) {
// The operation concluded, but Chrome is still not the default.
// If the call has succeeded, this suggests user has decided not to make
- // chrome the default. We fold this UI and move on.
- if (response_delegate_) {
- response_delegate_->SetDialogInteractionResult(
- MAKE_CHROME_DEFAULT_REGRETTED);
- }
-
- ConcludeInteraction(false);
+ // chrome the default.
+ ConcludeInteraction(MAKE_CHROME_DEFAULT_REGRETTED);
} else if (state == ShellIntegration::STATE_IS_DEFAULT) {
- if (response_delegate_) {
- response_delegate_->SetDialogInteractionResult(
- MAKE_CHROME_DEFAULT_ACCEPTED);
- }
-
- if (!Profile::FromWebUI(web_ui())->GetPrefs()->GetBoolean(
- prefs::kSuppressSwitchToMetroModeOnSetDefault)) {
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- base::Bind(&SetAsDefaultBrowserHandler::ActivateMetroChrome,
- base::Unretained(this)));
- } else {
- ConcludeInteraction(false);
- }
+ ConcludeInteraction(MAKE_CHROME_DEFAULT_ACCEPTED);
}
+
+ // Otherwise, keep the dialog open since the user probably didn't make a
+ // choice.
}
void SetAsDefaultBrowserHandler::OnSetAsDefaultConcluded(bool call_result) {
@@ -196,11 +175,14 @@ void SetAsDefaultBrowserHandler::HandleLaunchSetDefaultBrowserFlow(
default_browser_worker_->StartSetAsDefault();
}
-void SetAsDefaultBrowserHandler::ConcludeInteraction(bool close_chrome) {
+void SetAsDefaultBrowserHandler::ConcludeInteraction(
+ MakeChromeDefaultResult interaction_result) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- WebContents* contents = web_ui()->GetWebContents();
+
if (response_delegate_)
- response_delegate_->SetChromeShutdownRequired(close_chrome);
+ response_delegate_->SetDialogInteractionResult(interaction_result);
+
+ WebContents* contents = web_ui()->GetWebContents();
if (contents) {
content::WebContentsDelegate* delegate = contents->GetDelegate();
@@ -209,28 +191,6 @@ void SetAsDefaultBrowserHandler::ConcludeInteraction(bool close_chrome) {
}
}
-void SetAsDefaultBrowserHandler::ActivateMetroChrome() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- FilePath cur_chrome_exe;
- bool sentinel_removed = false;
- if (PathService::Get(base::FILE_EXE, &cur_chrome_exe) &&
- first_run::IsChromeFirstRun() &&
- InstallUtil::IsPerUserInstall(cur_chrome_exe.value().c_str())) {
- // If this is per-user install, we will have to remove the sentinel file
- // to assure the user goes through the intended 'first-run flow'.
- sentinel_removed = first_run::RemoveSentinel();
- }
-
- bool metro_chrome_activated = ShellIntegration::ActivateMetroChrome();
- if (!metro_chrome_activated && sentinel_removed)
- first_run::CreateSentinel();
-
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&SetAsDefaultBrowserHandler::ConcludeInteraction,
- base::Unretained(this), metro_chrome_activated));
-}
-
// A web dialog delegate implementation for when 'Make Chrome Metro' UI
// is displayed on a dialog.
class SetAsDefaultBrowserDialogImpl : public ui::WebDialogDelegate,
@@ -258,7 +218,6 @@ class SetAsDefaultBrowserDialogImpl : public ui::WebDialogDelegate,
const content::ContextMenuParams& params) OVERRIDE;
// Overridden from ResponseDelegate:
- virtual void SetChromeShutdownRequired(bool shutdown_chrome);
virtual void SetDialogInteractionResult(MakeChromeDefaultResult result);
private:
@@ -267,7 +226,6 @@ class SetAsDefaultBrowserDialogImpl : public ui::WebDialogDelegate,
mutable bool owns_handler_;
SetAsDefaultBrowserHandler* handler_;
MakeChromeDefaultResult dialog_interation_result_;
- bool response_is_close_chrome_;
DISALLOW_COPY_AND_ASSIGN(SetAsDefaultBrowserDialogImpl);
};
@@ -278,8 +236,7 @@ SetAsDefaultBrowserDialogImpl::SetAsDefaultBrowserDialogImpl(Profile* profile,
browser_(browser),
owns_handler_(true),
handler_(new SetAsDefaultBrowserHandler(this)),
- dialog_interation_result_(MAKE_CHROME_DEFAULT_DECLINED),
- response_is_close_chrome_(false) {
+ dialog_interation_result_(MAKE_CHROME_DEFAULT_DECLINED) {
}
SetAsDefaultBrowserDialogImpl::~SetAsDefaultBrowserDialogImpl() {
@@ -333,23 +290,14 @@ void SetAsDefaultBrowserDialogImpl::OnDialogClosed(
dialog_interation_result_,
MAKE_CHROME_DEFAULT_MAX);
- if (response_is_close_chrome_) {
- // If Metro Chrome has been activated, we should close this process.
- // We are restarting as metro now.
- BrowserList::CloseAllBrowsersWithProfile(profile_);
- } else {
- // This will be false if the user closed the dialog without doing anything
- // or if operation failed for any reason (including invocation under a
- // Windows version earlier than 8).
- // In such case we just carry on with a normal chrome session. However, for
- // the purpose of surfacing this dialog the actual browser window had to
- // remain hidden. Now it's the time to show it.
- BrowserWindow* window = browser_->window();
- WebContents* contents = chrome::GetActiveWebContents(browser_);
- window->Show();
- if (contents)
- contents->GetView()->SetInitialFocus();
- }
+ // Carry on with a normal chrome session. For the purpose of surfacing this
+ // dialog the actual browser window had to remain hidden. Now it's time to
+ // show it.
+ BrowserWindow* window = browser_->window();
+ WebContents* contents = chrome::GetActiveWebContents(browser_);
+ window->Show();
+ if (contents)
+ contents->GetView()->SetInitialFocus();
delete this;
}
@@ -368,11 +316,6 @@ bool SetAsDefaultBrowserDialogImpl::HandleContextMenu(
return true;
}
-void SetAsDefaultBrowserDialogImpl::SetChromeShutdownRequired(
- bool shutdown_chrome) {
- response_is_close_chrome_ = shutdown_chrome;
-}
-
void SetAsDefaultBrowserDialogImpl::SetDialogInteractionResult(
MakeChromeDefaultResult result) {
dialog_interation_result_ = result;