Changing linux platform for chromeos.  This involved moving platform_util and extension_error_reporter to browser, so that the UIs surrounding them can be in the browser.

BUG=none
TEST=none
Review URL: http://codereview.chromium.org/1705009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45986 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index a878fca..f46038a 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -59,6 +59,7 @@
 #include "chrome/browser/login_prompt.h"
 #include "chrome/browser/net/url_request_context_getter.h"
 #include "chrome/browser/net/url_request_mock_util.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/browser/pref_service.h"
 #include "chrome/browser/profile_manager.h"
 #include "chrome/browser/renderer_host/render_process_host.h"
@@ -72,7 +73,6 @@
 #include "chrome/common/extensions/extension.h"
 #include "chrome/common/json_value_serializer.h"
 #include "chrome/common/notification_service.h"
-#include "chrome/common/platform_util.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/common/url_constants.h"
 #include "chrome/test/automation/automation_messages.h"
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 0a6bfe5..6513680 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -52,6 +52,7 @@
 #include "chrome/browser/net/browser_url_util.h"
 #include "chrome/browser/net/url_fixer_upper.h"
 #include "chrome/browser/options_window.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/browser/pref_service.h"
 #include "chrome/browser/profile.h"
 #include "chrome/browser/renderer_host/render_view_host.h"
@@ -74,7 +75,6 @@
 #include "chrome/common/extensions/extension.h"
 #include "chrome/common/notification_service.h"
 #include "chrome/common/page_transition_types.h"
-#include "chrome/common/platform_util.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/common/url_constants.h"
 #include "grit/chromium_strings.h"
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc
index 13950f7..e3f8dbd6 100644
--- a/chrome/browser/browser_about_handler.cc
+++ b/chrome/browser/browser_about_handler.cc
@@ -30,6 +30,7 @@
 #include "chrome/browser/memory_details.h"
 #include "chrome/browser/metrics/histogram_synchronizer.h"
 #include "chrome/browser/net/dns_global.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/browser/pref_service.h"
 #include "chrome/browser/profile.h"
 #include "chrome/browser/profile_manager.h"
@@ -38,7 +39,6 @@
 #include "chrome/browser/sync/profile_sync_service.h"
 #include "chrome/common/chrome_paths.h"
 #include "chrome/common/jstemplate_builder.h"
-#include "chrome/common/platform_util.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/common/render_messages.h"
 #include "chrome/common/url_constants.h"
diff --git a/chrome/browser/browser_uitest.cc b/chrome/browser/browser_uitest.cc
index 08a6a9c4..8efef73 100644
--- a/chrome/browser/browser_uitest.cc
+++ b/chrome/browser/browser_uitest.cc
@@ -9,9 +9,9 @@
 #include "base/test/test_file_util.h"
 #include "base/values.h"
 #include "chrome/app/chrome_dll_resource.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/common/chrome_switches.h"
 #include "chrome/common/chrome_constants.h"
-#include "chrome/common/platform_util.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/test/automation/browser_proxy.h"
 #include "chrome/test/automation/tab_proxy.h"
diff --git a/chrome/browser/cocoa/about_window_controller.mm b/chrome/browser/cocoa/about_window_controller.mm
index 6a2537e7..d03d5de 100644
--- a/chrome/browser/cocoa/about_window_controller.mm
+++ b/chrome/browser/cocoa/about_window_controller.mm
@@ -11,10 +11,10 @@
 #include "base/string_util.h"
 #include "base/sys_string_conversions.h"
 #include "chrome/browser/browser_list.h"
+#include "chrome/browser/platform_util.h"
 #import "chrome/browser/cocoa/background_tile_view.h"
 #import "chrome/browser/cocoa/keystone_glue.h"
 #include "chrome/browser/cocoa/restart_browser.h"
-#include "chrome/common/platform_util.h"
 #include "chrome/common/url_constants.h"
 #include "grit/chromium_strings.h"
 #include "grit/generated_resources.h"
diff --git a/chrome/browser/diagnostics/recon_diagnostics.cc b/chrome/browser/diagnostics/recon_diagnostics.cc
index c32900c..0faef4b 100644
--- a/chrome/browser/diagnostics/recon_diagnostics.cc
+++ b/chrome/browser/diagnostics/recon_diagnostics.cc
@@ -14,8 +14,8 @@
 #include "base/path_service.h"
 #include "chrome/app/chrome_version_info.h"
 #include "chrome/browser/diagnostics/diagnostics_test.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/common/chrome_paths.h"
-#include "chrome/common/platform_util.h"
 #include "chrome/common/json_value_serializer.h"
 
 #if defined(OS_WIN)
diff --git a/chrome/browser/download/download_file.cc b/chrome/browser/download/download_file.cc
index 4c5f42d1..6a9215f0 100644
--- a/chrome/browser/download/download_file.cc
+++ b/chrome/browser/download/download_file.cc
@@ -15,12 +15,12 @@
 #include "chrome/browser/download/download_manager.h"
 #include "chrome/browser/download/download_util.h"
 #include "chrome/browser/net/chrome_url_request_context.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/browser/profile.h"
 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
 #include "chrome/browser/tab_contents/tab_util.h"
 #include "chrome/browser/tab_contents/tab_contents.h"
 #include "chrome/common/chrome_paths.h"
-#include "chrome/common/platform_util.h"
 #include "googleurl/src/gurl.h"
 #include "net/base/io_buffer.h"
 #include "net/base/net_util.h"
diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc
index 00eff14..5b804d7 100644
--- a/chrome/browser/download/download_manager.cc
+++ b/chrome/browser/download/download_manager.cc
@@ -28,6 +28,7 @@
 #include "chrome/browser/extensions/extension_install_ui.h"
 #include "chrome/browser/extensions/extensions_service.h"
 #include "chrome/browser/net/chrome_url_request_context.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/browser/pref_service.h"
 #include "chrome/browser/profile.h"
 #include "chrome/browser/renderer_host/render_process_host.h"
@@ -42,7 +43,6 @@
 #include "chrome/common/extensions/user_script.h"
 #include "chrome/common/notification_service.h"
 #include "chrome/common/notification_type.h"
-#include "chrome/common/platform_util.h"
 #include "chrome/common/pref_names.h"
 #include "googleurl/src/gurl.h"
 #include "grit/chromium_strings.h"
diff --git a/chrome/browser/download/save_file_manager.cc b/chrome/browser/download/save_file_manager.cc
index 5d9ad43..9bbd9b0 100644
--- a/chrome/browser/download/save_file_manager.cc
+++ b/chrome/browser/download/save_file_manager.cc
@@ -16,11 +16,11 @@
 #include "chrome/browser/download/save_file.h"
 #include "chrome/browser/download/save_package.h"
 #include "chrome/browser/net/url_request_context_getter.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
 #include "chrome/browser/tab_contents/tab_contents.h"
 #include "chrome/browser/tab_contents/tab_util.h"
 #include "chrome/common/chrome_paths.h"
-#include "chrome/common/platform_util.h"
 #include "googleurl/src/gurl.h"
 #include "net/base/net_util.h"
 #include "net/base/io_buffer.h"
diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc
index c276517e..58689cc 100644
--- a/chrome/browser/download/save_package.cc
+++ b/chrome/browser/download/save_package.cc
@@ -24,6 +24,7 @@
 #include "chrome/browser/download/save_file_manager.h"
 #include "chrome/browser/download/save_item.h"
 #include "chrome/browser/net/url_request_context_getter.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/browser/pref_service.h"
 #include "chrome/browser/profile.h"
 #include "chrome/browser/renderer_host/render_process_host.h"
@@ -35,7 +36,6 @@
 #include "chrome/common/chrome_paths.h"
 #include "chrome/common/notification_service.h"
 #include "chrome/common/notification_type.h"
-#include "chrome/common/platform_util.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/common/url_constants.h"
 #include "grit/generated_resources.h"
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc
index e10c534..feb57539 100644
--- a/chrome/browser/extensions/crx_installer.cc
+++ b/chrome/browser/extensions/crx_installer.cc
@@ -13,10 +13,10 @@
 #include "chrome/browser/browser_process.h"
 #include "chrome/browser/chrome_thread.h"
 #include "chrome/browser/extensions/convert_user_script.h"
+#include "chrome/browser/extensions/extension_error_reporter.h"
 #include "chrome/browser/profile.h"
 #include "chrome/browser/shell_integration.h"
 #include "chrome/browser/web_applications/web_app.h"
-#include "chrome/common/extensions/extension_error_reporter.h"
 #include "chrome/common/extensions/extension_file_util.h"
 #include "chrome/common/notification_service.h"
 #include "chrome/common/notification_type.h"
diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc
index e941260..44318aa2 100644
--- a/chrome/browser/extensions/extension_browsertest.cc
+++ b/chrome/browser/extensions/extension_browsertest.cc
@@ -13,13 +13,13 @@
 #include "chrome/browser/browser_window.h"
 #include "chrome/browser/location_bar.h"
 #include "chrome/browser/extensions/crx_installer.h"
+#include "chrome/browser/extensions/extension_error_reporter.h"
 #include "chrome/browser/extensions/extension_host.h"
 #include "chrome/browser/extensions/extension_install_ui.h"
 #include "chrome/browser/extensions/extensions_service.h"
 #include "chrome/browser/profile.h"
 #include "chrome/common/chrome_switches.h"
 #include "chrome/common/chrome_paths.h"
-#include "chrome/common/extensions/extension_error_reporter.h"
 #include "chrome/common/notification_registrar.h"
 #include "chrome/common/notification_service.h"
 #include "chrome/common/notification_type.h"
diff --git a/chrome/browser/extensions/extension_browsertests_misc.cc b/chrome/browser/extensions/extension_browsertests_misc.cc
index 24e90f31d..2789569 100644
--- a/chrome/browser/extensions/extension_browsertests_misc.cc
+++ b/chrome/browser/extensions/extension_browsertests_misc.cc
@@ -8,6 +8,7 @@
 #include "chrome/browser/renderer_host/render_view_host.h"
 #include "chrome/browser/extensions/autoupdate_interceptor.h"
 #include "chrome/browser/extensions/extension_browsertest.h"
+#include "chrome/browser/extensions/extension_error_reporter.h"
 #include "chrome/browser/extensions/extension_host.h"
 #include "chrome/browser/extensions/extension_process_manager.h"
 #include "chrome/browser/extensions/extension_tabs_module.h"
@@ -22,7 +23,6 @@
 #endif
 
 #include "chrome/common/chrome_paths.h"
-#include "chrome/common/extensions/extension_error_reporter.h"
 #include "chrome/common/notification_service.h"
 #include "chrome/common/url_constants.h"
 #include "chrome/test/ui_test_utils.h"
diff --git a/chrome/browser/extensions/extension_devtools_browsertests.cc b/chrome/browser/extensions/extension_devtools_browsertests.cc
index 6422f5f..a8e28ab 100644
--- a/chrome/browser/extensions/extension_devtools_browsertests.cc
+++ b/chrome/browser/extensions/extension_devtools_browsertests.cc
@@ -9,6 +9,7 @@
 #include "chrome/browser/debugger/devtools_manager.h"
 #include "chrome/browser/debugger/devtools_client_host.h"
 #include "chrome/browser/extensions/extension_devtools_browsertest.h"
+#include "chrome/browser/extensions/extension_error_reporter.h"
 #include "chrome/browser/extensions/extension_host.h"
 #include "chrome/browser/extensions/extension_process_manager.h"
 #include "chrome/browser/extensions/extensions_service.h"
@@ -18,7 +19,6 @@
 #include "chrome/browser/tab_contents/tab_contents.h"
 #include "chrome/common/chrome_paths.h"
 #include "chrome/common/devtools_messages.h"
-#include "chrome/common/extensions/extension_error_reporter.h"
 #include "chrome/common/notification_service.h"
 #include "chrome/common/url_constants.h"
 #include "chrome/test/ui_test_utils.h"
diff --git a/chrome/browser/extensions/extension_error_reporter.cc b/chrome/browser/extensions/extension_error_reporter.cc
new file mode 100644
index 0000000..92f854e9
--- /dev/null
+++ b/chrome/browser/extensions/extension_error_reporter.cc
@@ -0,0 +1,71 @@
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/extension_error_reporter.h"
+
+#include "build/build_config.h"
+
+#include "base/logging.h"
+#include "base/message_loop.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/platform_util.h"
+
+// No AddRef required when using ExtensionErrorReporter with RunnableMethod.
+// This is okay since the ExtensionErrorReporter is a singleton that lives until
+// the end of the process.
+template <> struct RunnableMethodTraits<ExtensionErrorReporter> {
+  void RetainCallee(ExtensionErrorReporter*) {}
+  void ReleaseCallee(ExtensionErrorReporter*) {}
+};
+
+ExtensionErrorReporter* ExtensionErrorReporter::instance_ = NULL;
+
+// static
+void ExtensionErrorReporter::Init(bool enable_noisy_errors) {
+  if (!instance_) {
+    instance_ = new ExtensionErrorReporter(enable_noisy_errors);
+  }
+}
+
+// static
+ExtensionErrorReporter* ExtensionErrorReporter::GetInstance() {
+  CHECK(instance_) << "Init() was never called";
+  return instance_;
+}
+
+ExtensionErrorReporter::ExtensionErrorReporter(bool enable_noisy_errors)
+    : ui_loop_(MessageLoop::current()),
+      enable_noisy_errors_(enable_noisy_errors) {
+}
+
+void ExtensionErrorReporter::ReportError(const std::string& message,
+                                         bool be_noisy) {
+  // NOTE: There won't be a ui_loop_ in the unit test environment.
+  if (ui_loop_ && MessageLoop::current() != ui_loop_) {
+    ui_loop_->PostTask(FROM_HERE,
+        NewRunnableMethod(this, &ExtensionErrorReporter::ReportError, message,
+                          be_noisy));
+    return;
+  }
+
+  errors_.push_back(message);
+
+  // TODO(aa): Print the error message out somewhere better. I think we are
+  // going to need some sort of 'extension inspector'.
+  LOG(ERROR) << "Extension error: " << message;
+
+  if (enable_noisy_errors_ && be_noisy) {
+    platform_util::SimpleErrorBox(NULL,
+                                  UTF8ToUTF16("Extension error"),
+                                  UTF8ToUTF16(message));
+  }
+}
+
+const std::vector<std::string>* ExtensionErrorReporter::GetErrors() {
+  return &errors_;
+}
+
+void ExtensionErrorReporter::ClearErrors() {
+  errors_.clear();
+}
diff --git a/chrome/browser/extensions/extension_error_reporter.h b/chrome/browser/extensions/extension_error_reporter.h
new file mode 100644
index 0000000..f4205e9
--- /dev/null
+++ b/chrome/browser/extensions/extension_error_reporter.h
@@ -0,0 +1,50 @@
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_REPORTER_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_REPORTER_H_
+
+#include <string>
+#include <vector>
+
+class MessageLoop;
+
+// Exposes an easy way for the various components of the extension system to
+// report errors. This is a singleton that lives on the UI thread, with the
+// exception of ReportError() which may be called from any thread.
+// TODO(aa): Hook this up to about:extensions, when we have about:extensions.
+// TODO(aa): Consider exposing directly, or via a helper, to the renderer
+// process and plumbing the errors out to the browser.
+// TODO(aa): Add ReportError(extension_id, message, be_noisy), so that we can
+// report errors that are specific to a particular extension.
+class ExtensionErrorReporter {
+ public:
+  // Initializes the error reporter. Must be called before any other methods
+  // and on the UI thread.
+  static void Init(bool enable_noisy_errors);
+
+  // Get the singleton instance.
+  static ExtensionErrorReporter* GetInstance();
+
+  // Report an error. Errors always go to LOG(INFO). Optionally, they can also
+  // cause a noisy alert box. This method can be called from any thread.
+  void ReportError(const std::string& message, bool be_noisy);
+
+  // Get the errors that have been reported so far.
+  const std::vector<std::string>* GetErrors();
+
+  // Clear the list of errors reported so far.
+  void ClearErrors();
+
+ private:
+  static ExtensionErrorReporter* instance_;
+
+  explicit ExtensionErrorReporter(bool enable_noisy_errors);
+
+  MessageLoop* ui_loop_;
+  std::vector<std::string> errors_;
+  bool enable_noisy_errors_;
+};
+
+#endif  // CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_REPORTER_H_
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index 1d7de596..67af709 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -12,7 +12,6 @@
 #include "base/message_loop.h"
 #include "base/singleton.h"
 #include "base/string_util.h"
-#include "chrome/common/platform_util.h"
 #include "chrome/browser/browser.h"
 #include "chrome/browser/browser_list.h"
 #include "chrome/browser/browser_shutdown.h"
@@ -26,6 +25,7 @@
 #include "chrome/browser/in_process_webkit/dom_storage_context.h"
 #include "chrome/browser/in_process_webkit/webkit_context.h"
 #include "chrome/browser/message_box_handler.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/browser/pref_service.h"
 #include "chrome/browser/profile.h"
 #include "chrome/browser/renderer_host/render_view_host.h"
diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc
index 801dee0..fa43635c 100644
--- a/chrome/browser/extensions/extension_install_ui.cc
+++ b/chrome/browser/extensions/extension_install_ui.cc
@@ -15,6 +15,7 @@
 #include "chrome/browser/browser_list.h"
 #include "chrome/browser/browser_window.h"
 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/browser/profile.h"
 #include "chrome/browser/tab_contents/tab_contents.h"
 #if defined(TOOLKIT_VIEWS)  // TODO(port)
@@ -24,7 +25,6 @@
 #endif
 #include "chrome/common/extensions/extension.h"
 #include "chrome/common/notification_service.h"
-#include "chrome/common/platform_util.h"
 #include "chrome/common/url_constants.h"
 #include "grit/browser_resources.h"
 #include "grit/chromium_strings.h"
diff --git a/chrome/browser/extensions/extension_process_manager_unittest.cc b/chrome/browser/extensions/extension_process_manager_unittest.cc
index ae9eefe..8ab9517 100644
--- a/chrome/browser/extensions/extension_process_manager_unittest.cc
+++ b/chrome/browser/extensions/extension_process_manager_unittest.cc
@@ -3,8 +3,8 @@
 // found in the LICENSE file.
 
 #include "chrome/browser/extensions/extension_process_manager.h"
+#include "chrome/browser/extensions/extension_error_reporter.h"
 #include "chrome/browser/renderer_host/site_instance.h"
-#include "chrome/common/extensions/extension_error_reporter.h"
 #include "chrome/test/testing_profile.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "testing/platform_test.h"
diff --git a/chrome/browser/extensions/extension_shelf_model_browsertest.cc b/chrome/browser/extensions/extension_shelf_model_browsertest.cc
index 59cf318..abb2a93 100644
--- a/chrome/browser/extensions/extension_shelf_model_browsertest.cc
+++ b/chrome/browser/extensions/extension_shelf_model_browsertest.cc
@@ -4,6 +4,7 @@
 
 #include "chrome/browser/browser.h"
 #include "chrome/browser/extensions/extension_browsertest.h"
+#include "chrome/browser/extensions/extension_error_reporter.h"
 #include "chrome/browser/extensions/extension_host.h"
 #include "chrome/browser/extensions/extension_shelf_model.h"
 #include "chrome/browser/extensions/extensions_service.h"
@@ -12,7 +13,6 @@
 #include "chrome/browser/views/frame/browser_view.h"
 #include "chrome/common/chrome_paths.h"
 #include "chrome/common/chrome_switches.h"
-#include "chrome/common/extensions/extension_error_reporter.h"
 #include "chrome/test/in_process_browser_test.h"
 
 namespace {
diff --git a/chrome/browser/extensions/extension_updater.cc b/chrome/browser/extensions/extension_updater.cc
index 3d9ecea3..505796e 100644
--- a/chrome/browser/extensions/extension_updater.cc
+++ b/chrome/browser/extensions/extension_updater.cc
@@ -19,13 +19,13 @@
 #include "base/version.h"
 #include "chrome/app/chrome_version_info.h"
 #include "chrome/browser/browser_process.h"
+#include "chrome/browser/extensions/extension_error_reporter.h"
 #include "chrome/browser/extensions/extensions_service.h"
 #include "chrome/browser/pref_service.h"
 #include "chrome/browser/profile.h"
 #include "chrome/browser/utility_process_host.h"
 #include "chrome/common/chrome_switches.h"
 #include "chrome/common/extensions/extension.h"
-#include "chrome/common/extensions/extension_error_reporter.h"
 #include "chrome/common/pref_names.h"
 #include "googleurl/src/gurl.h"
 #include "net/base/escape.h"
diff --git a/chrome/browser/extensions/extension_updater_unittest.cc b/chrome/browser/extensions/extension_updater_unittest.cc
index 9c54d7a..b783517 100644
--- a/chrome/browser/extensions/extension_updater_unittest.cc
+++ b/chrome/browser/extensions/extension_updater_unittest.cc
@@ -12,6 +12,7 @@
 #include "base/thread.h"
 #include "base/version.h"
 #include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/extensions/extension_error_reporter.h"
 #include "chrome/browser/extensions/extension_updater.h"
 #include "chrome/browser/extensions/extensions_service.h"
 #include "chrome/browser/extensions/test_extension_prefs.h"
@@ -19,7 +20,6 @@
 #include "chrome/browser/pref_service.h"
 #include "chrome/common/extensions/extension.h"
 #include "chrome/common/extensions/extension_constants.h"
-#include "chrome/common/extensions/extension_error_reporter.h"
 #include "chrome/common/pref_names.h"
 #include "net/base/escape.h"
 #include "net/base/load_flags.h"
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 42c41ca..67218a5c 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -22,6 +22,7 @@
 #include "chrome/browser/extensions/extension_browser_event_router.h"
 #include "chrome/browser/extensions/extension_data_deleter.h"
 #include "chrome/browser/extensions/extension_dom_ui.h"
+#include "chrome/browser/extensions/extension_error_reporter.h"
 #include "chrome/browser/extensions/extension_history_api.h"
 #include "chrome/browser/extensions/extension_host.h"
 #include "chrome/browser/extensions/extension_process_manager.h"
@@ -35,7 +36,6 @@
 #include "chrome/common/chrome_switches.h"
 #include "chrome/common/extensions/extension.h"
 #include "chrome/common/extensions/extension_constants.h"
-#include "chrome/common/extensions/extension_error_reporter.h"
 #include "chrome/common/extensions/extension_file_util.h"
 #include "chrome/common/extensions/extension_l10n_util.h"
 #include "chrome/common/notification_service.h"
diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc
index 9d3e2425..5ed80c9f 100644
--- a/chrome/browser/extensions/extensions_service_unittest.cc
+++ b/chrome/browser/extensions/extensions_service_unittest.cc
@@ -20,6 +20,7 @@
 #include "base/version.h"
 #include "chrome/browser/extensions/crx_installer.h"
 #include "chrome/browser/extensions/extension_creator.h"
+#include "chrome/browser/extensions/extension_error_reporter.h"
 #include "chrome/browser/extensions/extensions_service.h"
 #include "chrome/browser/extensions/external_extension_provider.h"
 #include "chrome/browser/extensions/external_pref_extension_provider.h"
@@ -28,7 +29,6 @@
 #include "chrome/common/extensions/url_pattern.h"
 #include "chrome/common/chrome_paths.h"
 #include "chrome/common/chrome_switches.h"
-#include "chrome/common/extensions/extension_error_reporter.h"
 #include "chrome/common/json_value_serializer.h"
 #include "chrome/common/notification_registrar.h"
 #include "chrome/common/notification_service.h"
diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc
index 9565d69..48cc7e1f 100644
--- a/chrome/browser/extensions/extensions_ui.cc
+++ b/chrome/browser/extensions/extensions_ui.cc
@@ -16,6 +16,7 @@
 #include "chrome/browser/debugger/devtools_manager.h"
 #include "chrome/browser/extensions/crx_installer.h"
 #include "chrome/browser/extensions/extension_disabled_infobar_delegate.h"
+#include "chrome/browser/extensions/extension_error_reporter.h"
 #include "chrome/browser/extensions/extension_function_dispatcher.h"
 #include "chrome/browser/extensions/extension_host.h"
 #include "chrome/browser/extensions/extension_message_service.h"
@@ -32,7 +33,6 @@
 #include "chrome/common/chrome_switches.h"
 #include "chrome/common/extensions/extension.h"
 #include "chrome/common/extensions/extension_constants.h"
-#include "chrome/common/extensions/extension_error_reporter.h"
 #include "chrome/common/extensions/user_script.h"
 #include "chrome/common/extensions/url_pattern.h"
 #include "chrome/common/jstemplate_builder.h"
diff --git a/chrome/browser/external_protocol_handler.cc b/chrome/browser/external_protocol_handler.cc
index 80b60e27..d8bb81d 100644
--- a/chrome/browser/external_protocol_handler.cc
+++ b/chrome/browser/external_protocol_handler.cc
@@ -14,8 +14,8 @@
 #include "base/thread.h"
 #include "chrome/browser/browser.h"
 #include "chrome/browser/browser_process_impl.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/browser/pref_service.h"
-#include "chrome/common/platform_util.h"
 #include "chrome/common/pref_names.h"
 #include "googleurl/src/gurl.h"
 #include "net/base/escape.h"
diff --git a/chrome/browser/gtk/about_chrome_dialog.cc b/chrome/browser/gtk/about_chrome_dialog.cc
index 0299d52..ebe6d21 100644
--- a/chrome/browser/gtk/about_chrome_dialog.cc
+++ b/chrome/browser/gtk/about_chrome_dialog.cc
@@ -15,9 +15,9 @@
 #include "chrome/browser/gtk/gtk_chrome_link_button.h"
 #include "chrome/browser/gtk/gtk_theme_provider.h"
 #include "chrome/browser/gtk/gtk_util.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/browser/profile.h"
 #include "chrome/common/chrome_constants.h"
-#include "chrome/common/platform_util.h"
 #include "chrome/common/url_constants.h"
 #include "gfx/gtk_util.h"
 #include "grit/chromium_strings.h"
diff --git a/chrome/browser/gtk/first_run_dialog.cc b/chrome/browser/gtk/first_run_dialog.cc
index 6613957c..6f3e3d70 100644
--- a/chrome/browser/gtk/first_run_dialog.cc
+++ b/chrome/browser/gtk/first_run_dialog.cc
@@ -11,9 +11,9 @@
 #include "chrome/browser/gtk/gtk_chrome_link_button.h"
 #include "chrome/browser/gtk/gtk_util.h"
 #include "chrome/browser/importer/importer_data_types.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/browser/process_singleton.h"
 #include "chrome/browser/shell_integration.h"
-#include "chrome/common/platform_util.h"
 #include "chrome/installer/util/google_update_settings.h"
 #include "grit/chromium_strings.h"
 #include "grit/generated_resources.h"
diff --git a/chrome/browser/gtk/focus_store_gtk.cc b/chrome/browser/gtk/focus_store_gtk.cc
index 061e8a9..f61b2ba5 100644
--- a/chrome/browser/gtk/focus_store_gtk.cc
+++ b/chrome/browser/gtk/focus_store_gtk.cc
@@ -7,7 +7,7 @@
 #include <gtk/gtk.h>
 
 #include "base/logging.h"
-#include "chrome/common/platform_util.h"
+#include "chrome/browser/platform_util.h"
 
 FocusStoreGtk::FocusStoreGtk() : widget_(NULL) {
 }
diff --git a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
index 98b5ace..5ba1d37 100644
--- a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
+++ b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
@@ -12,10 +12,10 @@
 #include "chrome/browser/gtk/gtk_util.h"
 #include "chrome/browser/gtk/tabs/dragged_tab_gtk.h"
 #include "chrome/browser/gtk/tabs/tab_strip_gtk.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/browser/tab_contents/tab_contents.h"
 #include "chrome/browser/tabs/tab_strip_model.h"
 #include "chrome/common/notification_service.h"
-#include "chrome/common/platform_util.h"
 
 namespace {
 
diff --git a/chrome/browser/platform_util.h b/chrome/browser/platform_util.h
new file mode 100644
index 0000000..1f148f4
--- /dev/null
+++ b/chrome/browser/platform_util.h
@@ -0,0 +1,51 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_PLATFORM_UTIL_H_
+#define CHROME_BROWSER_PLATFORM_UTIL_H_
+
+#include "base/string16.h"
+#include "gfx/native_widget_types.h"
+
+class FilePath;
+class GURL;
+
+namespace platform_util {
+
+// Show the given file in a file manager. If possible, select the file.
+void ShowItemInFolder(const FilePath& full_path);
+
+// Open the given file in the desktop's default manner.
+void OpenItem(const FilePath& full_path);
+
+// Open the given external protocol URL in the desktop's default manner.
+// (For example, mailto: URLs in the default mail user agent.)
+void OpenExternal(const GURL& url);
+
+// Get the top level window for the native view. This can return NULL.
+gfx::NativeWindow GetTopLevel(gfx::NativeView view);
+
+// Returns true if |window| is the foreground top level window.
+bool IsWindowActive(gfx::NativeWindow window);
+
+// Returns true if the view is visible. The exact definition of this is
+// platform-specific, but it is generally not "visible to the user", rather
+// whether the view has the visible attribute set.
+bool IsVisible(gfx::NativeView view);
+
+// Pops up an error box with an OK button. If |parent| is non-null, the box
+// will be modal on it. (On Mac, it is always app-modal.) Generally speaking,
+// this class should not be used for much. Infobars are preferred.
+void SimpleErrorBox(gfx::NativeWindow parent,
+                    const string16& title,
+                    const string16& message);
+
+// Return a human readable modifier for the version string.  For a
+// branded Chrome (not Chromium), this modifier is the channel (dev,
+// beta, stable).
+string16 GetVersionStringModifier();
+
+}
+
+#endif  // CHROME_BROWSER_PLATFORM_UTIL_H_
diff --git a/chrome/browser/platform_util_chromeos.cc b/chrome/browser/platform_util_chromeos.cc
new file mode 100644
index 0000000..a19d3ac
--- /dev/null
+++ b/chrome/browser/platform_util_chromeos.cc
@@ -0,0 +1,86 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/platform_util.h"
+
+#include <gtk/gtk.h>
+
+#include "app/gtk_util.h"
+#include "base/file_util.h"
+#include "base/process_util.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/common/process_watcher.h"
+#include "googleurl/src/gurl.h"
+
+#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/browser_list.h"
+#include "chrome/browser/dom_ui/filebrowse_ui.h"
+#include "chrome/browser/dom_ui/mediaplayer_ui.h"
+
+class Profile;
+
+namespace platform_util {
+
+// TODO(estade): It would be nice to be able to select the file in the file
+// manager, but that probably requires extending xdg-open. For now just
+// show the folder.
+void ShowItemInFolder(const FilePath& full_path) {
+  FilePath dir = full_path.DirName();
+  if (!file_util::DirectoryExists(dir))
+    return;
+
+  Profile* profile;
+  profile = BrowserList::GetLastActive()->profile();
+
+  FileBrowseUI::OpenPopup(profile,
+                          dir.value(),
+                          FileBrowseUI::kPopupWidth,
+                          FileBrowseUI::kPopupHeight);
+}
+
+void OpenItem(const FilePath& full_path) {
+  std::string ext = full_path.Extension();
+  // For things supported natively by the browser, we should open it
+  // in a tab.
+  if (ext == ".jpg" ||
+      ext == ".jpeg" ||
+      ext == ".png" ||
+      ext == ".gif" ||
+      ext == ".html" ||
+      ext == ".htm") {
+    std::string path;
+    path = "file://";
+    path += full_path.value();
+    if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) {
+      bool result = ChromeThread::PostTask(
+          ChromeThread::UI, FROM_HERE,
+          NewRunnableFunction(&OpenItem, full_path));
+      DCHECK(result);
+      return;
+    }
+    Browser* browser = BrowserList::GetLastActive();
+    browser->AddTabWithURL(
+        GURL(path), GURL(), PageTransition::LINK,
+        true, -1, false, NULL);
+    return;
+  }
+  if (ext == ".avi" ||
+      ext == ".mp4" ||
+      ext == ".mp3" ||
+      ext == ".mkv" ||
+      ext == ".ogg") {
+    MediaPlayer* mediaplayer = MediaPlayer::Get();
+    std::string url = "file://";
+    url += full_path.value();
+    GURL gurl(url);
+    mediaplayer->EnqueueMediaURL(gurl);
+    return;
+  }
+}
+
+void OpenExternal(const GURL& url) {
+
+}
+
+}  // namespace platform_util
diff --git a/chrome/browser/platform_util_common_linux.cc b/chrome/browser/platform_util_common_linux.cc
new file mode 100644
index 0000000..328d26007
--- /dev/null
+++ b/chrome/browser/platform_util_common_linux.cc
@@ -0,0 +1,83 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/platform_util.h"
+
+#include <gtk/gtk.h>
+
+#include "app/gtk_util.h"
+#include "base/file_util.h"
+#include "base/process_util.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/common/process_watcher.h"
+#include "gfx/native_widget_types.h"
+#include "googleurl/src/gurl.h"
+
+namespace platform_util {
+
+gfx::NativeWindow GetTopLevel(gfx::NativeView view) {
+  // A detached widget won't have a toplevel window as an ancestor, so we can't
+  // assume that the query for toplevel will return a window.
+  GtkWidget* toplevel = gtk_widget_get_ancestor(view, GTK_TYPE_WINDOW);
+  return GTK_IS_WINDOW(toplevel) ? GTK_WINDOW(toplevel) : NULL;
+}
+
+bool IsWindowActive(gfx::NativeWindow window) {
+  return gtk_window_is_active(window);
+}
+
+bool IsVisible(gfx::NativeView view) {
+  return GTK_WIDGET_VISIBLE(view);
+}
+
+void SimpleErrorBox(gfx::NativeWindow parent,
+                    const string16& title,
+                    const string16& message) {
+  GtkWidget* dialog = gtk_message_dialog_new(parent, GTK_DIALOG_MODAL,
+      GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", UTF16ToUTF8(message).c_str());
+  gtk_util::ApplyMessageDialogQuirks(dialog);
+  gtk_window_set_title(GTK_WINDOW(dialog), UTF16ToUTF8(title).c_str());
+
+  g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL);
+  gtk_widget_show_all(dialog);
+
+  // Make sure it's big enough to show the title.
+  GtkRequisition req;
+  gtk_widget_size_request(dialog, &req);
+  int width;
+  gtk_util::GetWidgetSizeFromCharacters(dialog, title.length(), 0,
+                                        &width, NULL);
+  // The fudge factor accounts for extra space needed by the frame
+  // decorations as well as width differences between average text and the
+  // actual title text.
+  width = width * 1.2 + 50;
+
+  if (width > req.width)
+    gtk_widget_set_size_request(dialog, width, -1);
+}
+
+/* Warning: this may be either Linux or ChromeOS */
+string16 GetVersionStringModifier() {
+  char* env = getenv("CHROME_VERSION_EXTRA");
+  if (!env)
+    return string16();
+  std::string modifier(env);
+
+#if defined(GOOGLE_CHROME_BUILD)
+  // Only ever return "", "unknown", "dev" or "beta" in a branded build.
+  if (modifier == "unstable")  // linux version of "dev"
+    modifier = "dev";
+  if (modifier == "stable") {
+    modifier = "";
+  } else if ((modifier == "dev") || (modifier == "beta")) {
+    // do nothing.
+  } else {
+    modifier = "unknown";
+  }
+#endif
+
+  return ASCIIToUTF16(modifier);
+}
+
+}  // namespace platform_util
diff --git a/chrome/browser/platform_util_linux.cc b/chrome/browser/platform_util_linux.cc
new file mode 100644
index 0000000..38ffba6
--- /dev/null
+++ b/chrome/browser/platform_util_linux.cc
@@ -0,0 +1,68 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/platform_util.h"
+
+#include <gtk/gtk.h>
+
+#include "app/gtk_util.h"
+#include "base/file_util.h"
+#include "base/process_util.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/common/process_watcher.h"
+#include "googleurl/src/gurl.h"
+
+namespace {
+
+void XDGOpen(const std::string& path) {
+  std::vector<std::string> argv;
+  argv.push_back("xdg-open");
+  argv.push_back(path);
+
+  base::environment_vector env;
+  // xdg-open can fall back on mailcap which eventually might plumb through
+  // to a command that needs a terminal.  Set the environment variable telling
+  // it that we definitely don't have a terminal available and that it should
+  // bring up a new terminal if necessary.  See "man mailcap".
+  env.push_back(std::make_pair("MM_NOTTTY", "1"));
+
+  // In Google Chrome, we do not let GNOME's bug-buddy intercept our crashes.
+  // However, we do not want this environment variable to propagate to external
+  // applications. See http://crbug.com/24120
+  char* disable_gnome_bug_buddy = getenv("GNOME_DISABLE_CRASH_DIALOG");
+  if (disable_gnome_bug_buddy &&
+      disable_gnome_bug_buddy == std::string("SET_BY_GOOGLE_CHROME")) {
+    env.push_back(std::make_pair("GNOME_DISABLE_CRASH_DIALOG", ""));
+  }
+
+  base::file_handle_mapping_vector no_files;
+  base::ProcessHandle handle;
+  if (base::LaunchApp(argv, env, no_files, false, &handle))
+    ProcessWatcher::EnsureProcessGetsReaped(handle);
+}
+
+}  // namespace
+
+namespace platform_util {
+
+// TODO(estade): It would be nice to be able to select the file in the file
+// manager, but that probably requires extending xdg-open. For now just
+// show the folder.
+void ShowItemInFolder(const FilePath& full_path) {
+  FilePath dir = full_path.DirName();
+  if (!file_util::DirectoryExists(dir))
+    return;
+
+  XDGOpen(dir.value());
+}
+
+void OpenItem(const FilePath& full_path) {
+  XDGOpen(full_path.value());
+}
+
+void OpenExternal(const GURL& url) {
+  XDGOpen(url.spec());
+}
+
+}  // namespace platform_util
diff --git a/chrome/browser/platform_util_mac.mm b/chrome/browser/platform_util_mac.mm
new file mode 100644
index 0000000..43d9582
--- /dev/null
+++ b/chrome/browser/platform_util_mac.mm
@@ -0,0 +1,89 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/platform_util.h"
+
+#import <Cocoa/Cocoa.h>
+
+#include "app/l10n_util.h"
+#include "app/l10n_util_mac.h"
+#include "base/file_path.h"
+#include "base/logging.h"
+#include "base/mac_util.h"
+#include "base/sys_string_conversions.h"
+#include "googleurl/src/gurl.h"
+#include "grit/generated_resources.h"
+
+namespace platform_util {
+
+void ShowItemInFolder(const FilePath& full_path) {
+  DCHECK_EQ([NSThread currentThread], [NSThread mainThread]);
+  NSString* path_string = base::SysUTF8ToNSString(full_path.value());
+  if (!path_string || ![[NSWorkspace sharedWorkspace] selectFile:path_string
+                                        inFileViewerRootedAtPath:nil])
+    LOG(WARNING) << "NSWorkspace failed to select file " << full_path.value();
+}
+
+void OpenItem(const FilePath& full_path) {
+  DCHECK_EQ([NSThread currentThread], [NSThread mainThread]);
+  NSString* path_string = base::SysUTF8ToNSString(full_path.value());
+  if (!path_string || ![[NSWorkspace sharedWorkspace] openFile:path_string])
+    LOG(WARNING) << "NSWorkspace failed to open file " << full_path.value();
+}
+
+void OpenExternal(const GURL& url) {
+  DCHECK_EQ([NSThread currentThread], [NSThread mainThread]);
+  NSString* url_string = base::SysUTF8ToNSString(url.spec());
+  NSURL* ns_url = [NSURL URLWithString:url_string];
+  if (!ns_url || ![[NSWorkspace sharedWorkspace] openURL:ns_url])
+    LOG(WARNING) << "NSWorkspace failed to open URL " << url;
+}
+
+gfx::NativeWindow GetTopLevel(gfx::NativeView view) {
+  return [view window];
+}
+
+bool IsWindowActive(gfx::NativeWindow window) {
+  return [window isKeyWindow] || [window isMainWindow];
+}
+
+bool IsVisible(gfx::NativeView view) {
+  // A reasonable approximation of how you'd expect this to behave.
+  return (view &&
+          ![view isHiddenOrHasHiddenAncestor] &&
+          [view window] &&
+          [[view window] isVisible]);
+}
+
+void SimpleErrorBox(gfx::NativeWindow parent,
+                    const string16& title,
+                    const string16& message) {
+  NSAlert* alert = [[[NSAlert alloc] init] autorelease];
+  [alert addButtonWithTitle:l10n_util::GetNSString(IDS_OK)];
+  [alert setMessageText:base::SysUTF16ToNSString(title)];
+  [alert setInformativeText:base::SysUTF16ToNSString(message)];
+  [alert setAlertStyle:NSWarningAlertStyle];
+  [alert runModal];
+}
+
+string16 GetVersionStringModifier() {
+#if defined(GOOGLE_CHROME_BUILD)
+  NSBundle* bundle = mac_util::MainAppBundle();
+  NSString* channel = [bundle objectForInfoDictionaryKey:@"KSChannelID"];
+  // Only ever return "", "unknown", "beta" or "dev" in a branded build.
+  if ([channel isEqual:@"stable"]) {
+    channel = @"";
+  } else if ([channel isEqual:@"beta"] || [channel isEqual:@"dev"]) {
+    // do nothing.
+  } else {
+    channel = @"unknown";
+  }
+
+  return base::SysNSStringToUTF16(channel);
+#else
+  return string16();
+#endif
+}
+
+}  // namespace platform_util
diff --git a/chrome/browser/platform_util_win.cc b/chrome/browser/platform_util_win.cc
new file mode 100644
index 0000000..7738fe3
--- /dev/null
+++ b/chrome/browser/platform_util_win.cc
@@ -0,0 +1,173 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/platform_util.h"
+
+#include <commdlg.h>
+#include <dwmapi.h>
+#include <shellapi.h>
+#include <shlobj.h>
+
+#include "app/win_util.h"
+#include "base/file_path.h"
+#include "base/file_util.h"
+#include "base/path_service.h"
+#include "base/logging.h"
+#include "base/registry.h"
+#include "base/scoped_comptr_win.h"
+#include "base/string_util.h"
+#include "chrome/installer/util/google_update_settings.h"
+#include "chrome/installer/util/google_update_constants.h"
+#include "chrome/installer/util/install_util.h"
+#include "gfx/native_widget_types.h"
+#include "googleurl/src/gurl.h"
+
+namespace platform_util {
+
+void ShowItemInFolder(const FilePath& full_path) {
+  FilePath dir = full_path.DirName();
+  // ParseDisplayName will fail if the directory is "C:", it must be "C:\\".
+  if (dir.value() == L"" || !file_util::EnsureEndsWithSeparator(&dir))
+    return;
+
+  typedef HRESULT (WINAPI *SHOpenFolderAndSelectItemsFuncPtr)(
+      PCIDLIST_ABSOLUTE pidl_Folder,
+      UINT cidl,
+      PCUITEMID_CHILD_ARRAY pidls,
+      DWORD flags);
+
+  static SHOpenFolderAndSelectItemsFuncPtr open_folder_and_select_itemsPtr =
+    NULL;
+  static bool initialize_open_folder_proc = true;
+  if (initialize_open_folder_proc) {
+    initialize_open_folder_proc = false;
+    // The SHOpenFolderAndSelectItems API is exposed by shell32 version 6
+    // and does not exist in Win2K. We attempt to retrieve this function export
+    // from shell32 and if it does not exist, we just invoke ShellExecute to
+    // open the folder thus losing the functionality to select the item in
+    // the process.
+    HMODULE shell32_base = GetModuleHandle(L"shell32.dll");
+    if (!shell32_base) {
+      NOTREACHED();
+      return;
+    }
+    open_folder_and_select_itemsPtr =
+        reinterpret_cast<SHOpenFolderAndSelectItemsFuncPtr>
+            (GetProcAddress(shell32_base, "SHOpenFolderAndSelectItems"));
+  }
+  if (!open_folder_and_select_itemsPtr) {
+    ShellExecute(NULL, _T("open"), dir.value().c_str(), NULL, NULL, SW_SHOW);
+    return;
+  }
+
+  ScopedComPtr<IShellFolder> desktop;
+  HRESULT hr = SHGetDesktopFolder(desktop.Receive());
+  if (FAILED(hr))
+    return;
+
+  win_util::CoMemReleaser<ITEMIDLIST> dir_item;
+  hr = desktop->ParseDisplayName(NULL, NULL,
+                                 const_cast<wchar_t *>(dir.value().c_str()),
+                                 NULL, &dir_item, NULL);
+  if (FAILED(hr))
+    return;
+
+  win_util::CoMemReleaser<ITEMIDLIST> file_item;
+  hr = desktop->ParseDisplayName(NULL, NULL,
+      const_cast<wchar_t *>(full_path.value().c_str()),
+      NULL, &file_item, NULL);
+  if (FAILED(hr))
+    return;
+
+  const ITEMIDLIST* highlight[] = {
+    {file_item},
+  };
+  (*open_folder_and_select_itemsPtr)(dir_item, arraysize(highlight),
+                                     highlight, NULL);
+}
+
+void OpenItem(const FilePath& full_path) {
+  win_util::OpenItemViaShell(full_path);
+}
+
+void OpenExternal(const GURL& url) {
+  // Quote the input scheme to be sure that the command does not have
+  // parameters unexpected by the external program. This url should already
+  // have been escaped.
+  std::string escaped_url = url.spec();
+  escaped_url.insert(0, "\"");
+  escaped_url += "\"";
+
+  // According to Mozilla in uriloader/exthandler/win/nsOSHelperAppService.cpp:
+  // "Some versions of windows (Win2k before SP3, Win XP before SP1) crash in
+  // ShellExecute on long URLs (bug 161357 on bugzilla.mozilla.org). IE 5 and 6
+  // support URLS of 2083 chars in length, 2K is safe."
+  const size_t kMaxUrlLength = 2048;
+  if (escaped_url.length() > kMaxUrlLength) {
+    NOTREACHED();
+    return;
+  }
+
+  RegKey key;
+  std::wstring registry_path = ASCIIToWide(url.scheme()) +
+                               L"\\shell\\open\\command";
+  key.Open(HKEY_CLASSES_ROOT, registry_path.c_str());
+  if (key.Valid()) {
+    DWORD size = 0;
+    key.ReadValue(NULL, NULL, &size);
+    if (size <= 2) {
+      // ShellExecute crashes the process when the command is empty.
+      // We check for "2" because it always returns the trailing NULL.
+      // TODO(nsylvain): we should also add a dialog to warn on errors. See
+      // bug 1136923.
+      return;
+    }
+  }
+
+  if (reinterpret_cast<ULONG_PTR>(ShellExecuteA(NULL, "open",
+                                                escaped_url.c_str(), NULL, NULL,
+                                                SW_SHOWNORMAL)) <= 32) {
+    // We fail to execute the call. We could display a message to the user.
+    // TODO(nsylvain): we should also add a dialog to warn on errors. See
+    // bug 1136923.
+    return;
+  }
+}
+
+gfx::NativeWindow GetTopLevel(gfx::NativeView view) {
+  return GetAncestor(view, GA_ROOT);
+}
+
+bool IsWindowActive(gfx::NativeWindow window) {
+  return ::GetForegroundWindow() == window;
+}
+
+bool IsVisible(gfx::NativeView view) {
+  // MSVC complains if we don't include != 0.
+  return ::IsWindowVisible(view) != 0;
+}
+
+void SimpleErrorBox(gfx::NativeWindow parent,
+                    const string16& title,
+                    const string16& message) {
+  win_util::MessageBox(parent, message, title, MB_OK | MB_SETFOREGROUND);
+}
+
+string16 GetVersionStringModifier() {
+#if defined(GOOGLE_CHROME_BUILD)
+  FilePath module;
+  string16 channel;
+  if (PathService::Get(base::FILE_MODULE, &module)) {
+    bool is_system_install =
+        !InstallUtil::IsPerUserInstall(module.value().c_str());
+
+    GoogleUpdateSettings::GetChromeChannel(is_system_install, &channel);
+  }
+  return channel;
+#else
+  return string16();
+#endif
+}
+
+}  // namespace platform_util
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index fd82db14..4332a35e 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -25,6 +25,7 @@
 #include "chrome/browser/dom_ui/ntp_resource_cache.h"
 #include "chrome/browser/download/download_manager.h"
 #include "chrome/browser/extensions/extension_devtools_manager.h"
+#include "chrome/browser/extensions/extension_error_reporter.h"
 #include "chrome/browser/extensions/extension_message_service.h"
 #include "chrome/browser/extensions/extension_process_manager.h"
 #include "chrome/browser/extensions/extensions_service.h"
@@ -65,7 +66,6 @@
 #include "chrome/common/chrome_constants.h"
 #include "chrome/common/chrome_paths.h"
 #include "chrome/common/chrome_switches.h"
-#include "chrome/common/extensions/extension_error_reporter.h"
 #include "chrome/common/notification_service.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/common/render_messages.h"
@@ -1494,4 +1494,3 @@
   cloud_print_proxy_service_.reset(new CloudPrintProxyService(this));
   cloud_print_proxy_service_->Initialize();
 }
-
diff --git a/chrome/browser/renderer_host/test/render_view_host_manager_browsertest.cc b/chrome/browser/renderer_host/test/render_view_host_manager_browsertest.cc
index dd6546c..fb6e16c 100644
--- a/chrome/browser/renderer_host/test/render_view_host_manager_browsertest.cc
+++ b/chrome/browser/renderer_host/test/render_view_host_manager_browsertest.cc
@@ -4,6 +4,7 @@
 
 #include "chrome/browser/browser.h"
 #include "chrome/browser/download/download_manager.h"
+#include "chrome/browser/extensions/extension_error_reporter.h"
 #include "chrome/browser/profile.h"
 #include "chrome/browser/renderer_host/site_instance.h"
 #include "chrome/browser/tab_contents/tab_contents.h"
@@ -14,7 +15,6 @@
 #include "chrome/common/notification_registrar.h"
 #include "chrome/common/notification_service.h"
 #include "chrome/common/notification_type.h"
-#include "chrome/common/extensions/extension_error_reporter.h"
 #include "chrome/test/in_process_browser_test.h"
 #include "chrome/test/ui_test_utils.h"
 #include "net/base/net_util.h"
diff --git a/chrome/browser/ssl/ssl_add_cert_handler.cc b/chrome/browser/ssl/ssl_add_cert_handler.cc
index 8c75d7d..dafc78f 100644
--- a/chrome/browser/ssl/ssl_add_cert_handler.cc
+++ b/chrome/browser/ssl/ssl_add_cert_handler.cc
@@ -9,7 +9,7 @@
 #include "chrome/browser/browser.h"
 #include "chrome/browser/browser_window.h"
 #include "chrome/browser/chrome_thread.h"
-#include "chrome/common/platform_util.h"
+#include "chrome/browser/platform_util.h"
 #include "grit/generated_resources.h"
 #include "net/base/cert_database.h"
 #include "net/base/net_errors.h"
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index 471d2b80..1f208dc 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -25,6 +25,7 @@
 #include "chrome/browser/metrics/user_metrics.h"
 #include "chrome/browser/net/browser_url_util.h"
 #include "chrome/browser/page_info_window.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/browser/pref_service.h"
 #include "chrome/browser/profile.h"
 #include "chrome/browser/renderer_host/render_view_host.h"
@@ -35,7 +36,6 @@
 #include "chrome/browser/tab_contents/tab_contents.h"
 #include "chrome/browser/translate/translate_manager.h"
 #include "chrome/common/chrome_switches.h"
-#include "chrome/common/platform_util.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/common/url_constants.h"
 #include "grit/generated_resources.h"
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index d23e537..f3fe7d7 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -44,6 +44,7 @@
 #include "chrome/browser/modal_html_dialog_delegate.h"
 #include "chrome/browser/omnibox_search_hint.h"
 #include "chrome/browser/password_manager/password_manager.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/browser/plugin_installer.h"
 #include "chrome/browser/pref_service.h"
 #include "chrome/browser/profile.h"
@@ -71,7 +72,6 @@
 #include "chrome/common/extensions/extension.h"
 #include "chrome/common/extensions/extension_action.h"
 #include "chrome/common/notification_service.h"
-#include "chrome/common/platform_util.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/common/render_messages.h"
 #include "chrome/common/renderer_preferences.h"
@@ -3154,4 +3154,3 @@
 bool TabContents::DidLastPageLoadEncounterSSLErrors() {
   return controller().ssl_manager()->ProcessedSSLErrorFromRequest();
 }
-
diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc
index 96e284d..3630b304 100644
--- a/chrome/browser/views/about_chrome_view.cc
+++ b/chrome/browser/views/about_chrome_view.cc
@@ -13,9 +13,9 @@
 #include "chrome/app/chrome_version_info.h"
 #include "chrome/browser/browser_list.h"
 #include "chrome/browser/metrics/user_metrics.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/browser/views/accessible_view_helper.h"
 #include "chrome/common/chrome_constants.h"
-#include "chrome/common/platform_util.h"
 #include "chrome/common/url_constants.h"
 #include "gfx/canvas.h"
 #include "grit/chromium_strings.h"
diff --git a/chrome/browser/views/infobars/extension_infobar.cc b/chrome/browser/views/infobars/extension_infobar.cc
index bbfc4ac..55565930 100644
--- a/chrome/browser/views/infobars/extension_infobar.cc
+++ b/chrome/browser/views/infobars/extension_infobar.cc
@@ -9,9 +9,9 @@
 #include "chrome/browser/extensions/extension_context_menu_model.h"
 #include "chrome/browser/extensions/extension_infobar_delegate.h"
 #include "chrome/browser/extensions/extension_host.h"
+#include "chrome/browser/platform_util.h"
 #include "chrome/browser/views/frame/browser_view.h"
 #include "chrome/common/extensions/extension.h"
-#include "chrome/common/platform_util.h"
 #include "gfx/canvas.h"
 #include "grit/theme_resources.h"
 #include "views/controls/button/menu_button.h"
diff --git a/chrome/browser/views/location_bar/page_action_image_view.cc b/chrome/browser/views/location_bar/page_action_image_view.cc
index 6ee90a3..635d678 100644
--- a/chrome/browser/views/location_bar/page_action_image_view.cc
+++ b/chrome/browser/views/location_bar/page_action_image_view.cc
@@ -10,7 +10,7 @@
 #include "chrome/browser/profile.h"
 #include "chrome/browser/views/frame/browser_view.h"
 #include "chrome/browser/views/location_bar/location_bar_view.h"
-#include "chrome/common/platform_util.h"
+#include "chrome/browser/platform_util.h"
 #include "views/controls/menu/menu_2.h"
 
 PageActionImageView::PageActionImageView(LocationBarView* owner,
@@ -217,5 +217,3 @@
   if (popup_)
     popup_->Close();
 }
-
-