Commit 3e0aa504 authored by mad@chromium.org's avatar mad@chromium.org

Switch about box to web ui on Windows.

This CLs adds proper support for update check on Windows so that we can turn on the WebUI support and eventually remove the code for about box in a modal dialog.

BUG=115123
TEST=Make sure about works and properly checks for updates.


Review URL: https://chromiumcodereview.appspot.com/10698106

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146738 0039d316-1c4b-4281-b951-d872f2087c98
parent eccf8031
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/google/google_update.h"
#include "chrome/browser/google/google_update_win.h"
#include <atlbase.h>
#include <atlcom.h>
......@@ -77,7 +77,7 @@ HRESULT CoCreateInstanceAsAdmin(REFCLSID class_id, REFIID interface_id,
if (!interface_ptr)
return E_POINTER;
// For Vista we need to instantiate the COM server via the elevation
// For Vista, need to instantiate the COM server via the elevation
// moniker. This ensures that the UAC dialog shows up.
if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
wchar_t class_id_as_string[MAX_PATH] = {0};
......@@ -106,14 +106,10 @@ HRESULT CoCreateInstanceAsAdmin(REFCLSID class_id, REFIID interface_id,
} // namespace
////////////////////////////////////////////////////////////////////////////////
//
// The GoogleUpdateJobObserver COM class is responsible for receiving status
// reports from google Update. It keeps track of the progress as Google Update
// notifies us and ends the message loop we are spinning in once Google Update
// reports that it is done.
//
////////////////////////////////////////////////////////////////////////////////
// reports from google Update. It keeps track of the progress as GoogleUpdate
// notifies this observer and ends the message loop that is spinning in once
// GoogleUpdate reports that it is done.
class GoogleUpdateJobObserver
: public CComObjectRootEx<CComSingleThreadModel>,
public IJobObserver {
......@@ -177,7 +173,7 @@ class GoogleUpdateJobObserver
event_sink_ = NULL;
// We no longer need to spin the message loop that we started spinning in
// No longer need to spin the message loop that started spinning in
// InitiateGoogleUpdateCheck.
MessageLoop::current()->Quit();
return S_OK;
......@@ -235,9 +231,8 @@ GoogleUpdate::GoogleUpdate()
GoogleUpdate::~GoogleUpdate() {
}
void GoogleUpdate::CheckForUpdate(bool install_if_newer,
views::Widget* window) {
// We need to shunt this request over to InitiateGoogleUpdateCheck and have
void GoogleUpdate::CheckForUpdate(bool install_if_newer, HWND window) {
// Need to shunt this request over to InitiateGoogleUpdateCheck and have
// it run in the file thread.
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
......@@ -249,7 +244,7 @@ void GoogleUpdate::CheckForUpdate(bool install_if_newer,
// GoogleUpdate, private:
void GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer,
views::Widget* window,
HWND window,
MessageLoop* main_loop) {
FilePath chrome_exe;
if (!PathService::Get(base::DIR_EXE, &chrome_exe))
......@@ -290,18 +285,13 @@ void GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer,
hr = on_demand.CreateInstance(CLSID_OnDemandUserAppsClass);
} else {
// The Update operation needs Admin privileges for writing
// to %ProgramFiles%. On Vista we need to elevate before instantiating
// to %ProgramFiles%. On Vista, need to elevate before instantiating
// the updater instance.
if (!install_if_newer) {
hr = on_demand.CreateInstance(CLSID_OnDemandMachineAppsClass);
} else {
HWND foreground_hwnd = NULL;
if (window != NULL) {
foreground_hwnd = window->GetNativeWindow();
}
hr = CoCreateInstanceAsAdmin(CLSID_OnDemandMachineAppsClass,
IID_IGoogleUpdate, foreground_hwnd,
IID_IGoogleUpdate, window,
reinterpret_cast<void**>(on_demand.Receive()));
}
system_level = true;
......@@ -339,7 +329,7 @@ void GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer,
return;
}
// We need to spin the message loop while Google Update is running so that it
// Need to spin the message loop while Google Update is running so that it
// can report back to us through GoogleUpdateJobObserver. This message loop
// will terminate once Google Update sends us the completion status
// (success/error). See OnComplete().
......@@ -389,7 +379,7 @@ void GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer,
void GoogleUpdate::ReportResults(GoogleUpdateUpgradeResult results,
GoogleUpdateErrorCode error_code,
const string16& error_message) {
// If we get an error, then error code must not be blank, and vice versa.
// If there is an error, then error code must not be blank, and vice versa.
DCHECK(results == UPGRADE_ERROR ? error_code != GOOGLE_UPDATE_NO_ERROR :
error_code == GOOGLE_UPDATE_NO_ERROR);
if (listener_) {
......
......@@ -2,15 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_H_
#define CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_H_
#ifndef CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_
#define CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/string16.h"
#if defined(OS_WIN)
#include "google_update/google_update_idl.h"
#endif
class MessageLoop;
namespace views {
......@@ -28,7 +26,7 @@ enum GoogleUpdateUpgradeResult {
UPGRADE_IS_AVAILABLE,
// The upgrade happened successfully.
UPGRADE_SUCCESSFUL,
// No need to upgrade, we are up to date.
// No need to upgrade, Chrome is up to date.
UPGRADE_ALREADY_UP_TO_DATE,
// An error occurred.
UPGRADE_ERROR,
......@@ -94,7 +92,7 @@ class GoogleUpdate : public base::RefCountedThreadSafe<GoogleUpdate> {
// |window| should point to a foreground window. This is needed to ensure
// that Vista/Windows 7 UAC prompts show up in the foreground. It may also
// be null.
void CheckForUpdate(bool install_if_newer, views::Widget* window);
void CheckForUpdate(bool install_if_newer, HWND window);
// Pass NULL to clear the listener
void set_status_listener(GoogleUpdateStatusListener* listener) {
......@@ -106,24 +104,18 @@ class GoogleUpdate : public base::RefCountedThreadSafe<GoogleUpdate> {
virtual ~GoogleUpdate();
// The chromeos implementation is in browser/chromeos/google_update.cpp
#if defined(OS_WIN)
// This function reports failure from the Google Update operation to the
// listener.
// Note, after this function completes, this object will have deleted itself.
bool ReportFailure(HRESULT hr, GoogleUpdateErrorCode error_code,
const string16& error_message, MessageLoop* main_loop);
#endif
// We need to run the update check on another thread than the main thread, and
// The update check needs to run on another thread than the main thread, and
// therefore CheckForUpdate will delegate to this function. |main_loop| points
// to the message loop that we want the response to come from.
// to the message loop that the response must come from.
// |window| should point to a foreground window. This is needed to ensure that
// Vista/Windows 7 UAC prompts show up in the foreground. It may also be null.
void InitiateGoogleUpdateCheck(bool install_if_newer, views::Widget* window,
void InitiateGoogleUpdateCheck(bool install_if_newer, HWND window,
MessageLoop* main_loop);
// This function reports the results of the GoogleUpdate operation to the
......@@ -144,4 +136,4 @@ class GoogleUpdate : public base::RefCountedThreadSafe<GoogleUpdate> {
DISALLOW_COPY_AND_ASSIGN(GoogleUpdate);
};
#endif // CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_H_
#endif // CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_
......@@ -158,15 +158,10 @@ void ShowInstantConfirmDialog(Browser* browser) {
void ShowAboutChrome(Browser* browser) {
content::RecordAction(UserMetricsAction("AboutChrome"));
#if !defined(OS_WIN)
NavigateParams params(
GetSingletonTabNavigateParams(browser, GURL(kChromeUIUberURL)));
params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE;
ShowSingletonTabOverwritingNTP(browser, params);
#else
// crbug.com/115123.
browser->window()->ShowAboutChromeDialog();
#endif
}
void ShowSearchEngineSettings(Browser* browser) {
......
......@@ -528,7 +528,7 @@ void AboutChromeView::ViewHierarchyChanged(bool is_add,
!base::win::UserAccountControlIsEnabled())) {
UpdateStatus(UPGRADE_CHECK_STARTED, GOOGLE_UPDATE_NO_ERROR, string16());
// CheckForUpdate(false, ...) means don't upgrade yet.
google_updater_->CheckForUpdate(false, GetWidget());
google_updater_->CheckForUpdate(false, GetWidget()->GetNativeWindow());
}
#endif
} else {
......@@ -681,7 +681,7 @@ void AboutChromeView::UpdateStatus(GoogleUpdateUpgradeResult result,
google_updater_->set_status_listener(this);
UpdateStatus(UPGRADE_STARTED, GOOGLE_UPDATE_NO_ERROR, string16());
// CheckForUpdate(true,...) means perform upgrade if new version found.
google_updater_->CheckForUpdate(true, GetWidget());
google_updater_->CheckForUpdate(true, GetWidget()->GetNativeWindow());
// TODO(seanparent): Need to see if this code needs to change to
// force a machine restart.
return;
......
......@@ -16,7 +16,7 @@
#include "ui/views/window/dialog_delegate.h"
#if defined(OS_WIN) && !defined(USE_AURA)
#include "chrome/browser/google/google_update.h"
#include "chrome/browser/google/google_update_win.h"
#endif
namespace views {
......
......@@ -143,8 +143,8 @@ void HelpHandler::GetLocalizedValues(DictionaryValue* localized_strings) {
{ "upToDate", IDS_UPGRADE_UP_TO_DATE },
{ "updating", IDS_UPGRADE_UPDATING },
{ "updateAlmostDone", IDS_UPGRADE_SUCCESSFUL_RELAUNCH },
{ "getHelpWithChrome", IDS_GET_HELP_USING_CHROME },
{ "reportAnIssue", IDS_REPORT_AN_ISSUE },
{ "getHelpWithChrome", IDS_GET_HELP_USING_CHROME },
{ "reportAnIssue", IDS_REPORT_AN_ISSUE },
#if defined(OS_CHROMEOS)
{ "platform", IDS_PLATFORM_LABEL },
{ "firmware", IDS_ABOUT_PAGE_FIRMWARE },
......
......@@ -12,7 +12,6 @@
#include "chrome/browser/chromeos/cros_settings_names.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/google/google_update.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power_manager_client.h"
#include "grit/generated_resources.h"
......@@ -101,8 +100,7 @@ void VersionUpdaterCros::UpdateStatusChanged(
case UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT:
my_status = FAILED;
// TODO(derat): More-detailed error info if UpdateEngineClient exposes it.
message = l10n_util::GetStringFUTF16Int(IDS_UPGRADE_ERROR,
GOOGLE_UPDATE_ERROR_UPDATING);
message = l10n_util::GetStringFUTF16Int(IDS_UPGRADE_ERROR, 0);
break;
case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE:
my_status = CHECKING;
......
This diff is collapsed.
......@@ -1096,9 +1096,9 @@
'browser/google/google_search_counter.h',
'browser/google/google_search_metrics.cc',
'browser/google/google_search_metrics.h',
'browser/google/google_update.cc',
'browser/google/google_update.h',
'browser/google/google_update_settings_posix.cc',
'browser/google/google_update_win.cc',
'browser/google/google_update_win.h',
'browser/google/google_url_tracker.cc',
'browser/google/google_url_tracker.h',
'browser/google/google_url_tracker_factory.cc',
......@@ -3969,6 +3969,7 @@
'browser/ui/webui/help/version_updater_chromeos.h',
'browser/ui/webui/help/version_updater_mac.mm',
'browser/ui/webui/help/version_updater_mac.h',
'browser/ui/webui/help/version_updater_win.cc',
'browser/ui/webui/history_ui.cc',
'browser/ui/webui/history_ui.h',
'browser/ui/webui/inspect_ui.cc',
......@@ -4610,8 +4611,8 @@
['exclude', '^browser/automation/testing_automation_provider_win.cc'],
['exclude', '^browser/first_run/try_chrome_dialog_view.cc'],
['exclude', '^browser/first_run/try_chrome_dialog_view.h'],
['exclude', '^browser/google/google_update.cc'],
['exclude', '^browser/google/google_update.h'],
['exclude', '^browser/google/google_update_win.cc'],
['exclude', '^browser/google/google_update_win.h'],
['exclude', '^browser/hang_monitor/hung_plugin_action.cc'],
['exclude', '^browser/hang_monitor/hung_plugin_action.h'],
['exclude', '^browser/hang_monitor/hung_window_detector.cc'],
......@@ -5128,6 +5129,8 @@
'browser/ui/views/keyboard_overlay_delegate.cc',
'browser/ui/views/keyboard_overlay_dialog_view.cc',
'browser/ui/views/simple_message_box_views.cc',
'browser/ui/webui/help/version_updater_basic.cc',
'browser/ui/webui/help/version_updater_basic.h',
'browser/ui/webui/tab_modal_confirm_dialog_webui.cc',
'browser/ui/webui/tab_modal_confirm_dialog_webui.h',
],
......@@ -5143,7 +5146,6 @@
# Exclude files that should be excluded for all non-Windows platforms.
['exclude', '^browser/first_run/try_chrome_dialog_view.cc'],
['exclude', '^browser/first_run/try_chrome_dialog_view.h'],
['exclude', '^browser/google/google_update.cc'],
['exclude', '^browser/importer/ie_importer.cc'],
['exclude', '^browser/ui/network_profile_bubble.cc'],
['exclude', '^browser/ui/network_profile_bubble.h'],
......@@ -5170,8 +5172,6 @@
'<(INTERMEDIATE_DIR)/chrome',
],
'sources/': [
['exclude', '^browser/google/google_update.cc'],
['exclude', '^browser/google/google_update.h'],
['exclude', '^browser/platform_util_common_linux.cc'],
['exclude', '^browser/ui/views/frame/app_panel_browser_frame_view.cc'],
['exclude', '^browser/ui/views/frame/app_panel_browser_frame_view.h'],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment