summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpmonette <pmonette@chromium.org>2016-02-09 16:12:19 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-10 00:13:46 +0000
commit9fa59e8809740d5364b46e81f5503d1c7c90dd57 (patch)
treed759b3796e15c92bb03d91d4447a6f9d37dcdd1d
parent3497c50c52256d5f397579faf9c983d835c38d1d (diff)
downloadchromium_src-9fa59e8809740d5364b46e81f5503d1c7c90dd57.zip
chromium_src-9fa59e8809740d5364b46e81f5503d1c7c90dd57.tar.gz
chromium_src-9fa59e8809740d5364b46e81f5503d1c7c90dd57.tar.bz2
ShellIntegration is now a proper namespace.
This will make it easier to add code to the unnamed namespace in shell_integration.cc without prefixing everything with ShellIntegration::. Review URL: https://codereview.chromium.org/1682613002 Cr-Commit-Position: refs/heads/master@{#374541}
-rw-r--r--chrome/browser/browser_process.h2
-rw-r--r--chrome/browser/browser_process_impl.cc12
-rw-r--r--chrome/browser/browser_process_impl.h4
-rw-r--r--chrome/browser/chrome_browser_main.cc12
-rw-r--r--chrome/browser/chrome_browser_main_win.cc3
-rw-r--r--chrome/browser/custom_handlers/protocol_handler_registry.cc20
-rw-r--r--chrome/browser/custom_handlers/protocol_handler_registry.h12
-rw-r--r--chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc31
-rw-r--r--chrome/browser/external_protocol/external_protocol_handler.cc30
-rw-r--r--chrome/browser/external_protocol/external_protocol_handler.h4
-rw-r--r--chrome/browser/external_protocol/external_protocol_handler_unittest.cc67
-rw-r--r--chrome/browser/first_run/first_run.cc8
-rw-r--r--chrome/browser/importer/importer_list.cc4
-rw-r--r--chrome/browser/jumplist_win.cc3
-rw-r--r--chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc6
-rw-r--r--chrome/browser/prerender/prerender_browsertest.cc4
-rw-r--r--chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc2
-rw-r--r--chrome/browser/profiles/profile_shortcut_manager_win.cc2
-rw-r--r--chrome/browser/shell_integration.cc119
-rw-r--r--chrome/browser/shell_integration.h701
-rw-r--r--chrome/browser/shell_integration_android.cc24
-rw-r--r--chrome/browser/shell_integration_chromeos.cc24
-rw-r--r--chrome/browser/shell_integration_linux.cc359
-rw-r--r--chrome/browser/shell_integration_mac.mm22
-rw-r--r--chrome/browser/shell_integration_win.cc74
-rw-r--r--chrome/browser/shell_integration_win_unittest.cc52
-rw-r--r--chrome/browser/ui/apps/chrome_app_delegate.cc16
-rw-r--r--chrome/browser/ui/cocoa/external_protocol_dialog.mm2
-rw-r--r--chrome/browser/ui/cocoa/first_run_dialog.mm8
-rw-r--r--chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc4
-rw-r--r--chrome/browser/ui/external_protocol_dialog_delegate.cc3
-rw-r--r--chrome/browser/ui/startup/default_browser_prompt.cc26
-rw-r--r--chrome/browser/ui/startup/default_browser_prompt_win.cc8
-rw-r--r--chrome/browser/ui/startup/startup_browser_creator_impl.cc4
-rw-r--r--chrome/browser/ui/views/app_list/win/app_list_service_win.cc5
-rw-r--r--chrome/browser/ui/views/apps/chrome_native_app_window_views_win.cc5
-rw-r--r--chrome/browser/ui/views/first_run_dialog.cc2
-rw-r--r--chrome/browser/ui/views/frame/browser_window_property_manager_win.cc10
-rw-r--r--chrome/browser/ui/views/hung_renderer_view.cc2
-rw-r--r--chrome/browser/ui/views/new_task_manager_view.cc2
-rw-r--r--chrome/browser/ui/views/panels/panel_stack_view.cc2
-rw-r--r--chrome/browser/ui/views/panels/panel_view.cc2
-rw-r--r--chrome/browser/ui/views/profiles/user_manager_view.cc7
-rw-r--r--chrome/browser/ui/views/task_manager_view.cc7
-rw-r--r--chrome/browser/ui/views/uninstall_view.cc10
-rw-r--r--chrome/browser/ui/webui/options/browser_options_handler.cc20
-rw-r--r--chrome/browser/ui/webui/options/browser_options_handler.h11
-rw-r--r--chrome/browser/ui/webui/set_as_default_browser_ui.cc24
-rw-r--r--chrome/browser/ui/webui/settings/settings_default_browser_handler.cc18
-rw-r--r--chrome/browser/ui/webui/settings/settings_default_browser_handler.h9
-rw-r--r--chrome/browser/web_applications/update_shortcut_worker_win.cc2
-rw-r--r--chrome/browser/web_applications/web_app_mac.mm3
-rw-r--r--chrome/browser/web_applications/web_app_win.cc14
-rw-r--r--chrome/installer/util/shell_util.h2
-rw-r--r--chrome/test/base/testing_browser_process.cc4
-rw-r--r--chrome/test/base/testing_browser_process.h2
56 files changed, 888 insertions, 947 deletions
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h
index a93fabf..cd3a87e 100644
--- a/chrome/browser/browser_process.h
+++ b/chrome/browser/browser_process.h
@@ -266,7 +266,7 @@ class BrowserProcess {
// Returns the default web client state of Chrome (i.e., was it the user's
// default browser) at the time a previous check was made sometime between
// process startup and now.
- virtual ShellIntegration::DefaultWebClientState
+ virtual shell_integration::DefaultWebClientState
CachedDefaultWebClientState() = 0;
private:
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 005f950..d8b9bc6 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -197,7 +197,7 @@ BrowserProcessImpl::BrowserProcessImpl(
tearing_down_(false),
download_status_updater_(new DownloadStatusUpdater),
local_state_task_runner_(local_state_task_runner),
- cached_default_web_client_state_(ShellIntegration::UNKNOWN_DEFAULT) {
+ cached_default_web_client_state_(shell_integration::UNKNOWN_DEFAULT) {
g_browser_process = this;
platform_part_.reset(new BrowserProcessPlatformPart());
@@ -803,7 +803,7 @@ memory::TabManager* BrowserProcessImpl::GetTabManager() {
#endif
}
-ShellIntegration::DefaultWebClientState
+shell_integration::DefaultWebClientState
BrowserProcessImpl::CachedDefaultWebClientState() {
return cached_default_web_client_state_;
}
@@ -1196,8 +1196,8 @@ void BrowserProcessImpl::CreateGCMDriver() {
void BrowserProcessImpl::ApplyDefaultBrowserPolicy() {
if (local_state()->GetBoolean(prefs::kDefaultBrowserSettingEnabled)) {
- scoped_refptr<ShellIntegration::DefaultWebClientWorker>
- set_browser_worker = new ShellIntegration::DefaultBrowserWorker(NULL);
+ scoped_refptr<shell_integration::DefaultWebClientWorker>
+ set_browser_worker = new shell_integration::DefaultBrowserWorker(NULL);
set_browser_worker->StartSetAsDefault();
}
}
@@ -1219,9 +1219,9 @@ void BrowserProcessImpl::ApplyMetricsReportingPolicy() {
void BrowserProcessImpl::CacheDefaultWebClientState() {
#if defined(OS_CHROMEOS)
- cached_default_web_client_state_ = ShellIntegration::IS_DEFAULT;
+ cached_default_web_client_state_ = shell_integration::IS_DEFAULT;
#elif !defined(OS_ANDROID) && !defined(OS_IOS)
- cached_default_web_client_state_ = ShellIntegration::GetDefaultBrowser();
+ cached_default_web_client_state_ = shell_integration::GetDefaultBrowser();
#endif
}
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index 2d4e388..32dd155 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -152,7 +152,7 @@ class BrowserProcessImpl : public BrowserProcess,
network_time::NetworkTimeTracker* network_time_tracker() override;
gcm::GCMDriver* gcm_driver() override;
memory::TabManager* GetTabManager() override;
- ShellIntegration::DefaultWebClientState CachedDefaultWebClientState()
+ shell_integration::DefaultWebClientState CachedDefaultWebClientState()
override;
static void RegisterPrefs(PrefRegistrySimple* registry);
@@ -332,7 +332,7 @@ class BrowserProcessImpl : public BrowserProcess,
scoped_ptr<memory::TabManager> tab_manager_;
#endif
- ShellIntegration::DefaultWebClientState cached_default_web_client_state_;
+ shell_integration::DefaultWebClientState cached_default_web_client_state_;
DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl);
};
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 75c02f4..9833ff0 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -1317,9 +1317,9 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
return static_cast<int>(chrome::RESULT_CODE_ACTION_DISALLOWED_BY_POLICY);
}
- return ShellIntegration::SetAsDefaultBrowser() ?
- static_cast<int>(content::RESULT_CODE_NORMAL_EXIT) :
- static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED);
+ return shell_integration::SetAsDefaultBrowser()
+ ? static_cast<int>(content::RESULT_CODE_NORMAL_EXIT)
+ : static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED);
}
#if defined(USE_AURA)
@@ -1403,9 +1403,9 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
// At this point the user is willing to try chrome again.
if (answer == TryChromeDialogView::TRY_CHROME_AS_DEFAULT) {
// Only set in the unattended case, the interactive case is Windows 8.
- if (ShellIntegration::CanSetAsDefaultBrowser() ==
- ShellIntegration::SET_DEFAULT_UNATTENDED)
- ShellIntegration::SetAsDefaultBrowser();
+ if (shell_integration::CanSetAsDefaultBrowser() ==
+ shell_integration::SET_DEFAULT_UNATTENDED)
+ shell_integration::SetAsDefaultBrowser();
}
#else
// We don't support retention experiments on Mac or Linux.
diff --git a/chrome/browser/chrome_browser_main_win.cc b/chrome/browser/chrome_browser_main_win.cc
index fdf297b..e6726bf 100644
--- a/chrome/browser/chrome_browser_main_win.cc
+++ b/chrome/browser/chrome_browser_main_win.cc
@@ -220,7 +220,8 @@ void DetectFaultTolerantHeap() {
void ShowCloseBrowserFirstMessageBox() {
int message_id = IDS_UNINSTALL_CLOSE_APP;
if (base::win::GetVersion() >= base::win::VERSION_WIN8 &&
- (ShellIntegration::GetDefaultBrowser() == ShellIntegration::IS_DEFAULT)) {
+ (shell_integration::GetDefaultBrowser() ==
+ shell_integration::IS_DEFAULT)) {
message_id = IDS_UNINSTALL_CLOSE_APP_IMMERSIVE;
}
chrome::ShowMessageBox(NULL,
diff --git a/chrome/browser/custom_handlers/protocol_handler_registry.cc b/chrome/browser/custom_handlers/protocol_handler_registry.cc
index edd2b48..a98610f 100644
--- a/chrome/browser/custom_handlers/protocol_handler_registry.cc
+++ b/chrome/browser/custom_handlers/protocol_handler_registry.cc
@@ -53,8 +53,8 @@ bool ShouldRemoveHandlersNotInOS() {
// difference (http://crbug.com/88255).
return false;
#else
- return ShellIntegration::CanSetAsDefaultProtocolClient() !=
- ShellIntegration::SET_DEFAULT_NOT_ALLOWED;
+ return shell_integration::CanSetAsDefaultProtocolClient() !=
+ shell_integration::SET_DEFAULT_NOT_ALLOWED;
#endif
}
@@ -250,10 +250,10 @@ ProtocolHandlerRegistry::DefaultClientObserver::~DefaultClientObserver() {
}
void ProtocolHandlerRegistry::DefaultClientObserver::SetDefaultWebClientUIState(
- ShellIntegration::DefaultWebClientUIState state) {
+ shell_integration::DefaultWebClientUIState state) {
if (worker_) {
if (ShouldRemoveHandlersNotInOS() &&
- (state == ShellIntegration::STATE_NOT_DEFAULT)) {
+ (state == shell_integration::STATE_NOT_DEFAULT)) {
registry_->ClearDefault(worker_->protocol());
}
} else {
@@ -267,7 +267,7 @@ bool ProtocolHandlerRegistry::DefaultClientObserver::
}
void ProtocolHandlerRegistry::DefaultClientObserver::SetWorker(
- ShellIntegration::DefaultProtocolClientWorker* worker) {
+ shell_integration::DefaultProtocolClientWorker* worker) {
worker_ = worker;
}
@@ -299,11 +299,11 @@ bool ProtocolHandlerRegistry::Delegate::IsExternalHandlerRegistered(
return ProfileIOData::IsHandledProtocol(protocol);
}
-ShellIntegration::DefaultProtocolClientWorker*
+shell_integration::DefaultProtocolClientWorker*
ProtocolHandlerRegistry::Delegate::CreateShellWorker(
- ShellIntegration::DefaultWebClientObserver* observer,
+ shell_integration::DefaultWebClientObserver* observer,
const std::string& protocol) {
- return new ShellIntegration::DefaultProtocolClientWorker(observer, protocol);
+ return new shell_integration::DefaultProtocolClientWorker(observer, protocol);
}
ProtocolHandlerRegistry::DefaultClientObserver*
@@ -318,7 +318,7 @@ void ProtocolHandlerRegistry::Delegate::RegisterWithOSAsDefaultClient(
// The worker pointer is reference counted. While it is running the
// message loops of the FILE and UI thread will hold references to it
// and it will be automatically freed once all its tasks have finished.
- scoped_refptr<ShellIntegration::DefaultProtocolClientWorker> worker;
+ scoped_refptr<shell_integration::DefaultProtocolClientWorker> worker;
worker = CreateShellWorker(observer, protocol);
observer->SetWorker(worker.get());
registry->default_client_observers_.push_back(observer);
@@ -477,7 +477,7 @@ void ProtocolHandlerRegistry::InitProtocolSettings() {
p != default_handlers_.end(); ++p) {
ProtocolHandler handler = p->second;
DefaultClientObserver* observer = delegate_->CreateShellObserver(this);
- scoped_refptr<ShellIntegration::DefaultProtocolClientWorker> worker;
+ scoped_refptr<shell_integration::DefaultProtocolClientWorker> worker;
worker = delegate_->CreateShellWorker(observer, handler.protocol());
observer->SetWorker(worker.get());
default_client_observers_.push_back(observer);
diff --git a/chrome/browser/custom_handlers/protocol_handler_registry.h b/chrome/browser/custom_handlers/protocol_handler_registry.h
index eed9600..3abe0a5 100644
--- a/chrome/browser/custom_handlers/protocol_handler_registry.h
+++ b/chrome/browser/custom_handlers/protocol_handler_registry.h
@@ -43,7 +43,7 @@ class ProtocolHandlerRegistry : public KeyedService {
// Provides notification of when the OS level user agent settings
// are changed.
class DefaultClientObserver
- : public ShellIntegration::DefaultWebClientObserver {
+ : public shell_integration::DefaultWebClientObserver {
public:
explicit DefaultClientObserver(ProtocolHandlerRegistry* registry);
~DefaultClientObserver() override;
@@ -51,16 +51,16 @@ class ProtocolHandlerRegistry : public KeyedService {
// Get response from the worker regarding whether Chrome is the default
// handler for the protocol.
void SetDefaultWebClientUIState(
- ShellIntegration::DefaultWebClientUIState state) override;
+ shell_integration::DefaultWebClientUIState state) override;
bool IsInteractiveSetDefaultPermitted() override;
// Give the observer a handle to the worker, so we can find out the protocol
// when we're called and also tell the worker if we get deleted.
- void SetWorker(ShellIntegration::DefaultProtocolClientWorker* worker);
+ void SetWorker(shell_integration::DefaultProtocolClientWorker* worker);
protected:
- ShellIntegration::DefaultProtocolClientWorker* worker_;
+ shell_integration::DefaultProtocolClientWorker* worker_;
private:
bool IsOwnedByWorker() override;
@@ -82,8 +82,8 @@ class ProtocolHandlerRegistry : public KeyedService {
virtual void RegisterExternalHandler(const std::string& protocol);
virtual void DeregisterExternalHandler(const std::string& protocol);
virtual bool IsExternalHandlerRegistered(const std::string& protocol);
- virtual ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker(
- ShellIntegration::DefaultWebClientObserver* observer,
+ virtual shell_integration::DefaultProtocolClientWorker* CreateShellWorker(
+ shell_integration::DefaultWebClientObserver* observer,
const std::string& protocol);
virtual DefaultClientObserver* CreateShellObserver(
ProtocolHandlerRegistry* registry);
diff --git a/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc b/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc
index 00269d0..0946599 100644
--- a/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc
+++ b/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc
@@ -150,8 +150,8 @@ class FakeDelegate : public ProtocolHandlerRegistry::Delegate {
registered_protocols_.erase(protocol);
}
- ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker(
- ShellIntegration::DefaultWebClientObserver* observer,
+ shell_integration::DefaultProtocolClientWorker* CreateShellWorker(
+ shell_integration::DefaultWebClientObserver* observer,
const std::string& protocol) override;
ProtocolHandlerRegistry::DefaultClientObserver* CreateShellObserver(
@@ -202,13 +202,13 @@ class FakeClientObserver
delegate_(registry_delegate) {}
void SetDefaultWebClientUIState(
- ShellIntegration::DefaultWebClientUIState state) override {
+ shell_integration::DefaultWebClientUIState state) override {
ProtocolHandlerRegistry::DefaultClientObserver::SetDefaultWebClientUIState(
state);
- if (state == ShellIntegration::STATE_IS_DEFAULT) {
+ if (state == shell_integration::STATE_IS_DEFAULT) {
delegate_->FakeRegisterWithOS(worker_->protocol());
}
- if (state != ShellIntegration::STATE_PROCESSING) {
+ if (state != shell_integration::STATE_PROCESSING) {
base::MessageLoop::current()->QuitWhenIdle();
}
}
@@ -218,22 +218,23 @@ class FakeClientObserver
};
class FakeProtocolClientWorker
- : public ShellIntegration::DefaultProtocolClientWorker {
+ : public shell_integration::DefaultProtocolClientWorker {
public:
- FakeProtocolClientWorker(ShellIntegration::DefaultWebClientObserver* observer,
- const std::string& protocol,
- bool force_failure)
- : ShellIntegration::DefaultProtocolClientWorker(observer, protocol),
+ FakeProtocolClientWorker(
+ shell_integration::DefaultWebClientObserver* observer,
+ const std::string& protocol,
+ bool force_failure)
+ : shell_integration::DefaultProtocolClientWorker(observer, protocol),
force_failure_(force_failure) {}
private:
~FakeProtocolClientWorker() override {}
void CheckIsDefault() override {
- ShellIntegration::DefaultWebClientState state =
- ShellIntegration::IS_DEFAULT;
+ shell_integration::DefaultWebClientState state =
+ shell_integration::IS_DEFAULT;
if (force_failure_)
- state = ShellIntegration::NOT_DEFAULT;
+ state = shell_integration::NOT_DEFAULT;
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
@@ -257,8 +258,8 @@ ProtocolHandlerRegistry::DefaultClientObserver*
return new FakeClientObserver(registry, this);
}
-ShellIntegration::DefaultProtocolClientWorker* FakeDelegate::CreateShellWorker(
- ShellIntegration::DefaultWebClientObserver* observer,
+shell_integration::DefaultProtocolClientWorker* FakeDelegate::CreateShellWorker(
+ shell_integration::DefaultWebClientObserver* observer,
const std::string& protocol) {
return new FakeProtocolClientWorker(observer, protocol, force_os_failure_);
}
diff --git a/chrome/browser/external_protocol/external_protocol_handler.cc b/chrome/browser/external_protocol/external_protocol_handler.cc
index faaec1d..657709c 100644
--- a/chrome/browser/external_protocol/external_protocol_handler.cc
+++ b/chrome/browser/external_protocol/external_protocol_handler.cc
@@ -39,13 +39,13 @@ namespace {
// Functions enabling unit testing. Using a NULL delegate will use the default
// behavior; if a delegate is provided it will be used instead.
-ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker(
- ShellIntegration::DefaultWebClientObserver* observer,
+shell_integration::DefaultProtocolClientWorker* CreateShellWorker(
+ shell_integration::DefaultWebClientObserver* observer,
const std::string& protocol,
ExternalProtocolHandler::Delegate* delegate) {
if (!delegate)
- return new ShellIntegration::DefaultProtocolClientWorker(observer,
- protocol);
+ return new shell_integration::DefaultProtocolClientWorker(observer,
+ protocol);
return delegate->CreateShellWorker(observer, protocol);
}
@@ -94,7 +94,7 @@ void LaunchUrlWithoutSecurityCheckWithDelegate(
// we check if that external application will be us. If it is we just ignore
// the request.
class ExternalDefaultProtocolObserver
- : public ShellIntegration::DefaultWebClientObserver {
+ : public shell_integration::DefaultWebClientObserver {
public:
ExternalDefaultProtocolObserver(const GURL& escaped_url,
int render_process_host_id,
@@ -112,19 +112,19 @@ class ExternalDefaultProtocolObserver
has_user_gesture_(has_user_gesture) {}
void SetDefaultWebClientUIState(
- ShellIntegration::DefaultWebClientUIState state) override {
+ shell_integration::DefaultWebClientUIState state) override {
DCHECK(base::MessageLoopForUI::IsCurrent());
// If we are still working out if we're the default, or we've found
// out we definately are the default, we end here.
- if (state == ShellIntegration::STATE_PROCESSING) {
+ if (state == shell_integration::STATE_PROCESSING) {
return;
}
if (delegate_)
delegate_->FinishedProcessingCheck();
- if (state == ShellIntegration::STATE_IS_DEFAULT) {
+ if (state == shell_integration::STATE_IS_DEFAULT) {
if (delegate_)
delegate_->BlockRequest();
return;
@@ -291,15 +291,11 @@ void ExternalProtocolHandler::LaunchUrlWithDelegate(
// The worker creates tasks with references to itself and puts them into
// message loops. When no tasks are left it will delete the observer and
// eventually be deleted itself.
- ShellIntegration::DefaultWebClientObserver* observer =
- new ExternalDefaultProtocolObserver(url,
- render_process_host_id,
- tab_contents_id,
- block_state == UNKNOWN,
- page_transition,
- has_user_gesture,
- delegate);
- scoped_refptr<ShellIntegration::DefaultProtocolClientWorker> worker =
+ shell_integration::DefaultWebClientObserver* observer =
+ new ExternalDefaultProtocolObserver(
+ url, render_process_host_id, tab_contents_id, block_state == UNKNOWN,
+ page_transition, has_user_gesture, delegate);
+ scoped_refptr<shell_integration::DefaultProtocolClientWorker> worker =
CreateShellWorker(observer, escaped_url.scheme(), delegate);
// Start the check process running. This will send tasks to the FILE thread
diff --git a/chrome/browser/external_protocol/external_protocol_handler.h b/chrome/browser/external_protocol/external_protocol_handler.h
index 0dcef53..4759805 100644
--- a/chrome/browser/external_protocol/external_protocol_handler.h
+++ b/chrome/browser/external_protocol/external_protocol_handler.h
@@ -29,8 +29,8 @@ class ExternalProtocolHandler {
// Delegate to allow unit testing to provide different behavior.
class Delegate {
public:
- virtual ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker(
- ShellIntegration::DefaultWebClientObserver* observer,
+ virtual shell_integration::DefaultProtocolClientWorker* CreateShellWorker(
+ shell_integration::DefaultWebClientObserver* observer,
const std::string& protocol) = 0;
virtual BlockState GetBlockState(const std::string& scheme) = 0;
virtual void BlockRequest() = 0;
diff --git a/chrome/browser/external_protocol/external_protocol_handler_unittest.cc b/chrome/browser/external_protocol/external_protocol_handler_unittest.cc
index b247a6d..c717652 100644
--- a/chrome/browser/external_protocol/external_protocol_handler_unittest.cc
+++ b/chrome/browser/external_protocol/external_protocol_handler_unittest.cc
@@ -11,13 +11,13 @@
using content::BrowserThread;
class FakeExternalProtocolHandlerWorker
- : public ShellIntegration::DefaultProtocolClientWorker {
+ : public shell_integration::DefaultProtocolClientWorker {
public:
FakeExternalProtocolHandlerWorker(
- ShellIntegration::DefaultWebClientObserver* observer,
+ shell_integration::DefaultWebClientObserver* observer,
const std::string& protocol,
- ShellIntegration::DefaultWebClientState os_state)
- : ShellIntegration::DefaultProtocolClientWorker(observer, protocol),
+ shell_integration::DefaultWebClientState os_state)
+ : shell_integration::DefaultProtocolClientWorker(observer, protocol),
os_state_(os_state) {}
private:
@@ -38,7 +38,7 @@ class FakeExternalProtocolHandlerWorker
this, AttemptResult::SUCCESS));
}
- ShellIntegration::DefaultWebClientState os_state_;
+ shell_integration::DefaultWebClientState os_state_;
};
class FakeExternalProtocolHandlerDelegate
@@ -46,13 +46,13 @@ class FakeExternalProtocolHandlerDelegate
public:
FakeExternalProtocolHandlerDelegate()
: block_state_(ExternalProtocolHandler::BLOCK),
- os_state_(ShellIntegration::UNKNOWN_DEFAULT),
+ os_state_(shell_integration::UNKNOWN_DEFAULT),
has_launched_(false),
has_prompted_(false),
has_blocked_(false) {}
- ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker(
- ShellIntegration::DefaultWebClientObserver* observer,
+ shell_integration::DefaultProtocolClientWorker* CreateShellWorker(
+ shell_integration::DefaultWebClientObserver* observer,
const std::string& protocol) override {
return new FakeExternalProtocolHandlerWorker(observer, protocol, os_state_);
}
@@ -64,7 +64,7 @@ class FakeExternalProtocolHandlerDelegate
void BlockRequest() override {
ASSERT_TRUE(block_state_ == ExternalProtocolHandler::BLOCK ||
- os_state_ == ShellIntegration::IS_DEFAULT);
+ os_state_ == shell_integration::IS_DEFAULT);
has_blocked_ = true;
}
@@ -74,13 +74,13 @@ class FakeExternalProtocolHandlerDelegate
ui::PageTransition page_transition,
bool has_user_gesture) override {
ASSERT_EQ(block_state_, ExternalProtocolHandler::UNKNOWN);
- ASSERT_NE(os_state_, ShellIntegration::IS_DEFAULT);
+ ASSERT_NE(os_state_, shell_integration::IS_DEFAULT);
has_prompted_ = true;
}
void LaunchUrlWithoutSecurityCheck(const GURL& url) override {
ASSERT_EQ(block_state_, ExternalProtocolHandler::DONT_BLOCK);
- ASSERT_NE(os_state_, ShellIntegration::IS_DEFAULT);
+ ASSERT_NE(os_state_, shell_integration::IS_DEFAULT);
has_launched_ = true;
}
@@ -88,7 +88,7 @@ class FakeExternalProtocolHandlerDelegate
base::MessageLoop::current()->QuitWhenIdle();
}
- void set_os_state(ShellIntegration::DefaultWebClientState value) {
+ void set_os_state(shell_integration::DefaultWebClientState value) {
os_state_ = value;
}
@@ -102,7 +102,7 @@ class FakeExternalProtocolHandlerDelegate
private:
ExternalProtocolHandler::BlockState block_state_;
- ShellIntegration::DefaultWebClientState os_state_;
+ shell_integration::DefaultWebClientState os_state_;
bool has_launched_;
bool has_prompted_;
bool has_blocked_;
@@ -122,8 +122,10 @@ class ExternalProtocolHandlerTest : public testing::Test {
}
void DoTest(ExternalProtocolHandler::BlockState block_state,
- ShellIntegration::DefaultWebClientState os_state,
- bool should_prompt, bool should_launch, bool should_block) {
+ shell_integration::DefaultWebClientState os_state,
+ bool should_prompt,
+ bool should_launch,
+ bool should_block) {
GURL url("mailto:test@test.com");
ASSERT_FALSE(delegate_.has_prompted());
ASSERT_FALSE(delegate_.has_launched());
@@ -149,55 +151,46 @@ class ExternalProtocolHandlerTest : public testing::Test {
};
TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeBlockedChromeDefault) {
- DoTest(ExternalProtocolHandler::BLOCK,
- ShellIntegration::IS_DEFAULT,
- false, false, true);
+ DoTest(ExternalProtocolHandler::BLOCK, shell_integration::IS_DEFAULT, false,
+ false, true);
}
TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeBlockedChromeNotDefault) {
- DoTest(ExternalProtocolHandler::BLOCK,
- ShellIntegration::NOT_DEFAULT,
- false, false, true);
+ DoTest(ExternalProtocolHandler::BLOCK, shell_integration::NOT_DEFAULT, false,
+ false, true);
}
TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeBlockedChromeUnknown) {
- DoTest(ExternalProtocolHandler::BLOCK,
- ShellIntegration::UNKNOWN_DEFAULT,
+ DoTest(ExternalProtocolHandler::BLOCK, shell_integration::UNKNOWN_DEFAULT,
false, false, true);
}
TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnBlockedChromeDefault) {
- DoTest(ExternalProtocolHandler::DONT_BLOCK,
- ShellIntegration::IS_DEFAULT,
+ DoTest(ExternalProtocolHandler::DONT_BLOCK, shell_integration::IS_DEFAULT,
false, false, true);
}
TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnBlockedChromeNotDefault) {
- DoTest(ExternalProtocolHandler::DONT_BLOCK,
- ShellIntegration::NOT_DEFAULT,
+ DoTest(ExternalProtocolHandler::DONT_BLOCK, shell_integration::NOT_DEFAULT,
false, true, false);
}
TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnBlockedChromeUnknown) {
DoTest(ExternalProtocolHandler::DONT_BLOCK,
- ShellIntegration::UNKNOWN_DEFAULT,
- false, true, false);
+ shell_integration::UNKNOWN_DEFAULT, false, true, false);
}
TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnknownChromeDefault) {
- DoTest(ExternalProtocolHandler::UNKNOWN,
- ShellIntegration::IS_DEFAULT,
- false, false, true);
+ DoTest(ExternalProtocolHandler::UNKNOWN, shell_integration::IS_DEFAULT, false,
+ false, true);
}
TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnknownChromeNotDefault) {
- DoTest(ExternalProtocolHandler::UNKNOWN,
- ShellIntegration::NOT_DEFAULT,
- true, false, false);
+ DoTest(ExternalProtocolHandler::UNKNOWN, shell_integration::NOT_DEFAULT, true,
+ false, false);
}
TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnknownChromeUnknown) {
- DoTest(ExternalProtocolHandler::UNKNOWN,
- ShellIntegration::UNKNOWN_DEFAULT,
+ DoTest(ExternalProtocolHandler::UNKNOWN, shell_integration::UNKNOWN_DEFAULT,
true, false, false);
}
diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc
index 04d8ef4..3004d38 100644
--- a/chrome/browser/first_run/first_run.cc
+++ b/chrome/browser/first_run/first_run.cc
@@ -462,17 +462,17 @@ installer::MasterPreferences* LoadMasterPrefs() {
void ProcessDefaultBrowserPolicy(bool make_chrome_default_for_user) {
// Only proceed if chrome can be made default unattended. The interactive case
// (Windows 8+) is handled by the first run default browser prompt.
- if (ShellIntegration::CanSetAsDefaultBrowser() ==
- ShellIntegration::SET_DEFAULT_UNATTENDED) {
+ if (shell_integration::CanSetAsDefaultBrowser() ==
+ shell_integration::SET_DEFAULT_UNATTENDED) {
// The policy has precedence over the user's choice.
if (g_browser_process->local_state()->IsManagedPreference(
prefs::kDefaultBrowserSettingEnabled)) {
if (g_browser_process->local_state()->GetBoolean(
prefs::kDefaultBrowserSettingEnabled)) {
- ShellIntegration::SetAsDefaultBrowser();
+ shell_integration::SetAsDefaultBrowser();
}
} else if (make_chrome_default_for_user) {
- ShellIntegration::SetAsDefaultBrowser();
+ shell_integration::SetAsDefaultBrowser();
}
}
}
diff --git a/chrome/browser/importer/importer_list.cc b/chrome/browser/importer/importer_list.cc
index 1524cac..6ebebcc 100644
--- a/chrome/browser/importer/importer_list.cc
+++ b/chrome/browser/importer/importer_list.cc
@@ -131,7 +131,7 @@ std::vector<importer::SourceProfile> DetectSourceProfilesWorker(
// The first run import will automatically take settings from the first
// profile detected, which should be the user's current default.
#if defined(OS_WIN)
- if (ShellIntegration::IsFirefoxDefaultBrowser()) {
+ if (shell_integration::IsFirefoxDefaultBrowser()) {
DetectFirefoxProfiles(locale, &profiles);
DetectBuiltinWindowsProfiles(&profiles);
} else {
@@ -139,7 +139,7 @@ std::vector<importer::SourceProfile> DetectSourceProfilesWorker(
DetectFirefoxProfiles(locale, &profiles);
}
#elif defined(OS_MACOSX)
- if (ShellIntegration::IsFirefoxDefaultBrowser()) {
+ if (shell_integration::IsFirefoxDefaultBrowser()) {
DetectFirefoxProfiles(locale, &profiles);
DetectSafariProfiles(&profiles);
} else {
diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc
index 50b1095..bbc97f5 100644
--- a/chrome/browser/jumplist_win.cc
+++ b/chrome/browser/jumplist_win.cc
@@ -210,7 +210,8 @@ JumpList::JumpList(Profile* profile)
if (!tab_restore_service)
return;
- app_id_ = ShellIntegration::GetChromiumModelIdForProfile(profile_->GetPath());
+ app_id_ =
+ shell_integration::GetChromiumModelIdForProfile(profile_->GetPath());
icon_dir_ = profile_->GetPath().Append(chrome::kJumpListIconDirname);
scoped_refptr<history::TopSites> top_sites =
diff --git a/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc b/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc
index 180d838..11b1c17 100644
--- a/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc
+++ b/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc
@@ -151,10 +151,10 @@ void RecordStartupMetricsOnBlockingPool() {
#endif // defined(OS_MACOSX)
// Record whether Chrome is the default browser or not.
- ShellIntegration::DefaultWebClientState default_state =
- ShellIntegration::GetDefaultBrowser();
+ shell_integration::DefaultWebClientState default_state =
+ shell_integration::GetDefaultBrowser();
UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.State", default_state,
- ShellIntegration::NUM_DEFAULT_STATES);
+ shell_integration::NUM_DEFAULT_STATES);
}
void RecordLinuxGlibcVersion() {
diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc
index 8f92c8d..bdfebfd 100644
--- a/chrome/browser/prerender/prerender_browsertest.cc
+++ b/chrome/browser/prerender/prerender_browsertest.cc
@@ -1068,8 +1068,8 @@ class NeverRunsExternalProtocolHandlerDelegate
: public ExternalProtocolHandler::Delegate {
public:
// ExternalProtocolHandler::Delegate implementation.
- ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker(
- ShellIntegration::DefaultWebClientObserver* observer,
+ shell_integration::DefaultProtocolClientWorker* CreateShellWorker(
+ shell_integration::DefaultWebClientObserver* observer,
const std::string& protocol) override {
NOTREACHED();
// This will crash, but it shouldn't get this far with BlockState::BLOCK
diff --git a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
index b891a61..873e83c 100644
--- a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
+++ b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
@@ -143,7 +143,7 @@ class ProfileShortcutManagerTest : public testing::Test {
base::win::ShortcutProperties expected_properties;
expected_properties.set_app_id(
- ShellIntegration::GetChromiumModelIdForProfile(profile_path));
+ shell_integration::GetChromiumModelIdForProfile(profile_path));
expected_properties.set_target(GetExePath());
expected_properties.set_description(GetDistribution()->GetAppDescription());
expected_properties.set_dual_mode(false);
diff --git a/chrome/browser/profiles/profile_shortcut_manager_win.cc b/chrome/browser/profiles/profile_shortcut_manager_win.cc
index 45e2437..df21756 100644
--- a/chrome/browser/profiles/profile_shortcut_manager_win.cc
+++ b/chrome/browser/profiles/profile_shortcut_manager_win.cc
@@ -462,7 +462,7 @@ void CreateOrUpdateDesktopShortcutsAndIconForProfile(
}
properties.set_app_id(
- ShellIntegration::GetChromiumModelIdForProfile(params.profile_path));
+ shell_integration::GetChromiumModelIdForProfile(params.profile_path));
ShellUtil::ShortcutOperation operation =
ShellUtil::SHELL_SHORTCUT_REPLACE_EXISTING;
diff --git a/chrome/browser/shell_integration.cc b/chrome/browser/shell_integration.cc
index 1f621e3..1ed340b 100644
--- a/chrome/browser/shell_integration.cc
+++ b/chrome/browser/shell_integration.cc
@@ -33,33 +33,29 @@
using content::BrowserThread;
+namespace shell_integration {
+
namespace {
-const struct ShellIntegration::AppModeInfo* gAppModeInfo = nullptr;
+const struct AppModeInfo* gAppModeInfo = nullptr;
} // namespace
#if !defined(OS_WIN)
-// static
-bool ShellIntegration::SetAsDefaultBrowserInteractive() {
+bool SetAsDefaultBrowserInteractive() {
return false;
}
-// static
-bool ShellIntegration::IsSetAsDefaultAsynchronous() {
+bool IsSetAsDefaultAsynchronous() {
return false;
}
-// static
-bool ShellIntegration::SetAsDefaultProtocolClientInteractive(
- const std::string& protocol) {
+bool SetAsDefaultProtocolClientInteractive(const std::string& protocol) {
return false;
}
#endif // !defined(OS_WIN)
-// static
-ShellIntegration::DefaultWebClientSetPermission
- ShellIntegration::CanSetAsDefaultProtocolClient() {
+DefaultWebClientSetPermission CanSetAsDefaultProtocolClient() {
// Allowed as long as the browser can become the operating system default
// browser.
DefaultWebClientSetPermission permission = CanSetAsDefaultBrowser();
@@ -70,29 +66,24 @@ ShellIntegration::DefaultWebClientSetPermission
}
#if !defined(OS_WIN)
-// static
-bool ShellIntegration::IsElevationNeededForSettingDefaultProtocolClient() {
+bool IsElevationNeededForSettingDefaultProtocolClient() {
return false;
}
#endif // !defined(OS_WIN)
-// static
-void ShellIntegration::SetAppModeInfo(const struct AppModeInfo* info) {
+void SetAppModeInfo(const struct AppModeInfo* info) {
gAppModeInfo = info;
}
-// static
-const struct ShellIntegration::AppModeInfo* ShellIntegration::AppModeInfo() {
+const struct AppModeInfo* AppModeInfo() {
return gAppModeInfo;
}
-// static
-bool ShellIntegration::IsRunningInAppMode() {
+bool IsRunningInAppMode() {
return gAppModeInfo != NULL;
}
-// static
-base::CommandLine ShellIntegration::CommandLineArgsForLauncher(
+base::CommandLine CommandLineArgsForLauncher(
const GURL& url,
const std::string& extension_app_id,
const base::FilePath& profile_path) {
@@ -117,9 +108,8 @@ base::CommandLine ShellIntegration::CommandLineArgsForLauncher(
return new_cmd_line;
}
-// static
-void ShellIntegration::AppendProfileArgs(const base::FilePath& profile_path,
- base::CommandLine* command_line) {
+void AppendProfileArgs(const base::FilePath& profile_path,
+ base::CommandLine* command_line) {
DCHECK(command_line);
const base::CommandLine& cmd_line = *base::CommandLine::ForCurrentProcess();
@@ -149,7 +139,7 @@ void ShellIntegration::AppendProfileArgs(const base::FilePath& profile_path,
}
#if !defined(OS_WIN)
-base::string16 ShellIntegration::GetAppShortcutsSubdirName() {
+base::string16 GetAppShortcutsSubdirName() {
if (chrome::GetChannel() == version_info::Channel::CANARY)
return l10n_util::GetStringUTF16(IDS_APP_SHORTCUTS_SUBDIR_NAME_CANARY);
return l10n_util::GetStringUTF16(IDS_APP_SHORTCUTS_SUBDIR_NAME);
@@ -157,27 +147,26 @@ base::string16 ShellIntegration::GetAppShortcutsSubdirName() {
#endif // !defined(OS_WIN)
///////////////////////////////////////////////////////////////////////////////
-// ShellIntegration::DefaultWebClientObserver
+// DefaultWebClientObserver
//
-bool ShellIntegration::DefaultWebClientObserver::IsOwnedByWorker() {
+bool DefaultWebClientObserver::IsOwnedByWorker() {
return false;
}
-bool ShellIntegration::DefaultWebClientObserver::
- IsInteractiveSetDefaultPermitted() {
+bool DefaultWebClientObserver::IsInteractiveSetDefaultPermitted() {
return false;
}
///////////////////////////////////////////////////////////////////////////////
-// ShellIntegration::DefaultWebClientWorker
+// DefaultWebClientWorker
//
-ShellIntegration::DefaultWebClientWorker::DefaultWebClientWorker(
+DefaultWebClientWorker::DefaultWebClientWorker(
DefaultWebClientObserver* observer)
: observer_(observer) {}
-void ShellIntegration::DefaultWebClientWorker::StartCheckIsDefault() {
+void DefaultWebClientWorker::StartCheckIsDefault() {
if (observer_)
observer_->SetDefaultWebClientUIState(STATE_PROCESSING);
@@ -186,7 +175,7 @@ void ShellIntegration::DefaultWebClientWorker::StartCheckIsDefault() {
base::Bind(&DefaultWebClientWorker::CheckIsDefault, this));
}
-void ShellIntegration::DefaultWebClientWorker::StartSetAsDefault() {
+void DefaultWebClientWorker::StartSetAsDefault() {
// Cancel the already running process if another start is requested.
if (set_as_default_in_progress_) {
if (set_as_default_initialized_) {
@@ -214,7 +203,7 @@ void ShellIntegration::DefaultWebClientWorker::StartSetAsDefault() {
this, interactive_permitted));
}
-void ShellIntegration::DefaultWebClientWorker::ObserverDestroyed() {
+void DefaultWebClientWorker::ObserverDestroyed() {
// Our associated view has gone away, so we shouldn't call back to it if
// our worker thread returns after the view is dead.
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -232,9 +221,9 @@ void ShellIntegration::DefaultWebClientWorker::ObserverDestroyed() {
///////////////////////////////////////////////////////////////////////////////
// DefaultWebClientWorker, private:
-ShellIntegration::DefaultWebClientWorker::~DefaultWebClientWorker() {}
+DefaultWebClientWorker::~DefaultWebClientWorker() {}
-void ShellIntegration::DefaultWebClientWorker::OnCheckIsDefaultComplete(
+void DefaultWebClientWorker::OnCheckIsDefaultComplete(
DefaultWebClientState state) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
UpdateUI(state);
@@ -255,7 +244,7 @@ void ShellIntegration::DefaultWebClientWorker::OnCheckIsDefaultComplete(
}
}
-void ShellIntegration::DefaultWebClientWorker::OnSetAsDefaultAttemptComplete(
+void DefaultWebClientWorker::OnSetAsDefaultAttemptComplete(
AttemptResult result) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
// Hold on to a reference because if this was called via the default browser
@@ -292,8 +281,7 @@ void ShellIntegration::DefaultWebClientWorker::OnSetAsDefaultAttemptComplete(
}
}
-void ShellIntegration::DefaultWebClientWorker::ReportAttemptResult(
- AttemptResult result) {
+void DefaultWebClientWorker::ReportAttemptResult(AttemptResult result) {
const char* histogram_prefix = GetHistogramPrefix();
// Report result.
@@ -315,14 +303,13 @@ void ShellIntegration::DefaultWebClientWorker::ReportAttemptResult(
}
}
-bool ShellIntegration::DefaultWebClientWorker::InitializeSetAsDefault() {
+bool DefaultWebClientWorker::InitializeSetAsDefault() {
return true;
}
-void ShellIntegration::DefaultWebClientWorker::FinalizeSetAsDefault() {}
+void DefaultWebClientWorker::FinalizeSetAsDefault() {}
-void ShellIntegration::DefaultWebClientWorker::UpdateUI(
- DefaultWebClientState state) {
+void DefaultWebClientWorker::UpdateUI(DefaultWebClientState state) {
if (observer_) {
switch (state) {
case NOT_DEFAULT:
@@ -340,15 +327,13 @@ void ShellIntegration::DefaultWebClientWorker::UpdateUI(
}
}
-// static
-bool ShellIntegration::DefaultWebClientWorker::ShouldReportDurationForResult(
+bool DefaultWebClientWorker::ShouldReportDurationForResult(
AttemptResult result) {
return result == SUCCESS || result == FAILURE || result == ABANDONED ||
result == RETRY;
}
-// static
-const char* ShellIntegration::DefaultWebClientWorker::AttemptResultToString(
+const char* DefaultWebClientWorker::AttemptResultToString(
AttemptResult result) {
switch (result) {
case SUCCESS:
@@ -375,28 +360,25 @@ const char* ShellIntegration::DefaultWebClientWorker::AttemptResultToString(
}
///////////////////////////////////////////////////////////////////////////////
-// ShellIntegration::DefaultBrowserWorker
+// DefaultBrowserWorker
//
-ShellIntegration::DefaultBrowserWorker::DefaultBrowserWorker(
- DefaultWebClientObserver* observer)
- : DefaultWebClientWorker(observer) {
-}
+DefaultBrowserWorker::DefaultBrowserWorker(DefaultWebClientObserver* observer)
+ : DefaultWebClientWorker(observer) {}
-ShellIntegration::DefaultBrowserWorker::~DefaultBrowserWorker() {}
+DefaultBrowserWorker::~DefaultBrowserWorker() {}
///////////////////////////////////////////////////////////////////////////////
// DefaultBrowserWorker, private:
-void ShellIntegration::DefaultBrowserWorker::CheckIsDefault() {
+void DefaultBrowserWorker::CheckIsDefault() {
DefaultWebClientState state = GetDefaultBrowser();
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&DefaultBrowserWorker::OnCheckIsDefaultComplete, this, state));
}
-void ShellIntegration::DefaultBrowserWorker::SetAsDefault(
- bool interactive_permitted) {
+void DefaultBrowserWorker::SetAsDefault(bool interactive_permitted) {
AttemptResult result = AttemptResult::FAILURE;
switch (CanSetAsDefaultBrowser()) {
case SET_DEFAULT_NOT_ALLOWED:
@@ -438,26 +420,25 @@ void ShellIntegration::DefaultBrowserWorker::SetAsDefault(
result));
}
-const char* ShellIntegration::DefaultBrowserWorker::GetHistogramPrefix() {
+const char* DefaultBrowserWorker::GetHistogramPrefix() {
return "DefaultBrowser";
}
///////////////////////////////////////////////////////////////////////////////
-// ShellIntegration::DefaultProtocolClientWorker
+// DefaultProtocolClientWorker
//
-ShellIntegration::DefaultProtocolClientWorker::DefaultProtocolClientWorker(
- DefaultWebClientObserver* observer, const std::string& protocol)
- : DefaultWebClientWorker(observer),
- protocol_(protocol) {
-}
+DefaultProtocolClientWorker::DefaultProtocolClientWorker(
+ DefaultWebClientObserver* observer,
+ const std::string& protocol)
+ : DefaultWebClientWorker(observer), protocol_(protocol) {}
///////////////////////////////////////////////////////////////////////////////
// DefaultProtocolClientWorker, private:
-ShellIntegration::DefaultProtocolClientWorker::~DefaultProtocolClientWorker() {}
+DefaultProtocolClientWorker::~DefaultProtocolClientWorker() {}
-void ShellIntegration::DefaultProtocolClientWorker::CheckIsDefault() {
+void DefaultProtocolClientWorker::CheckIsDefault() {
DefaultWebClientState state = IsDefaultProtocolClient(protocol_);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
@@ -465,8 +446,7 @@ void ShellIntegration::DefaultProtocolClientWorker::CheckIsDefault() {
state));
}
-void ShellIntegration::DefaultProtocolClientWorker::SetAsDefault(
- bool interactive_permitted) {
+void DefaultProtocolClientWorker::SetAsDefault(bool interactive_permitted) {
AttemptResult result = AttemptResult::FAILURE;
switch (CanSetAsDefaultProtocolClient()) {
case SET_DEFAULT_NOT_ALLOWED:
@@ -492,7 +472,8 @@ void ShellIntegration::DefaultProtocolClientWorker::SetAsDefault(
this, result));
}
-const char*
-ShellIntegration::DefaultProtocolClientWorker::GetHistogramPrefix() {
+const char* DefaultProtocolClientWorker::GetHistogramPrefix() {
return "DefaultProtocolClient";
}
+
+} // namespace shell_integration
diff --git a/chrome/browser/shell_integration.h b/chrome/browser/shell_integration.h
index f2c629a..a39635a 100644
--- a/chrome/browser/shell_integration.h
+++ b/chrome/browser/shell_integration.h
@@ -21,390 +21,387 @@ class CommandLine;
class OneShotTimer;
}
-class ShellIntegration {
- public:
- // Sets Chrome as the default browser (only for the current user). Returns
- // false if this operation fails.
- static bool SetAsDefaultBrowser();
-
- // Initiates an OS shell flow which (if followed by the user) should set
- // Chrome as the default browser. Returns false if the flow cannot be
- // initialized, if it is not supported (introduced for Windows 8) or if the
- // user cancels the operation. This is a blocking call and requires a FILE
- // thread. If Chrome is already default browser, no interactive dialog will be
- // shown and this method returns true.
- static bool SetAsDefaultBrowserInteractive();
-
- // Returns true if setting the default browser is an asynchronous operation.
- // In practice, this is only true on Windows 10+.
- static bool IsSetAsDefaultAsynchronous();
-
- // Sets Chrome as the default client application for the given protocol
- // (only for the current user). Returns false if this operation fails.
- static bool SetAsDefaultProtocolClient(const std::string& protocol);
-
- // Initiates an OS shell flow which (if followed by the user) should set
- // Chrome as the default handler for |protocol|. Returns false if the flow
- // cannot be initialized, if it is not supported (introduced for Windows 8)
- // or if the user cancels the operation. This is a blocking call and requires
- // a FILE thread. If Chrome is already default for |protocol|, no interactive
- // dialog will be shown and this method returns true.
- static bool SetAsDefaultProtocolClientInteractive(
- const std::string& protocol);
-
- // Windows 8 and Windows 10 introduced different ways to set the default
- // browser.
- enum DefaultWebClientSetPermission {
- // The browser distribution is not permitted to be made default.
- SET_DEFAULT_NOT_ALLOWED,
- // No special permission or interaction is required to set the default
- // browser. This is used in Linux, Mac and Windows 7 and under.
- SET_DEFAULT_UNATTENDED,
- // On Windows 8, a browser can be made default only in an interactive flow.
- SET_DEFAULT_INTERACTIVE,
- // On Windows 10+, the set default browser flow is both interactive and
- // asynchronous.
- SET_DEFAULT_ASYNCHRONOUS,
- };
-
- // Returns requirements for making the running browser the user's default.
- static DefaultWebClientSetPermission CanSetAsDefaultBrowser();
-
- // Returns requirements for making the running browser the user's default
- // client application for specific protocols.
- static DefaultWebClientSetPermission CanSetAsDefaultProtocolClient();
-
- // Returns true if making the running browser the default client for any
- // protocol requires elevated privileges.
- static bool IsElevationNeededForSettingDefaultProtocolClient();
-
- // Returns a string representing the application to be launched given the
- // protocol of the requested url. This string may be a name or a path, but
- // neither is guaranteed and it should only be used as a display string.
- // Returns an empty string on failure.
- static base::string16 GetApplicationNameForProtocol(const GURL& url);
-
- // On Linux, it may not be possible to determine or set the default browser
- // on some desktop environments or configurations. So, we use this enum and
- // not a plain bool.
- enum DefaultWebClientState {
- NOT_DEFAULT,
- IS_DEFAULT,
- UNKNOWN_DEFAULT,
- NUM_DEFAULT_STATES
- };
-
- // Attempt to determine if this instance of Chrome is the default browser and
- // return the appropriate state. (Defined as being the handler for HTTP/HTTPS
- // protocols; we don't want to report "no" here if the user has simply chosen
- // to open HTML files in a text editor and FTP links with an FTP client.)
- static DefaultWebClientState GetDefaultBrowser();
-
- // Returns true if Firefox is likely to be the default browser for the current
- // user. This method is very fast so it can be invoked in the UI thread.
- static bool IsFirefoxDefaultBrowser();
+namespace shell_integration {
+
+// Sets Chrome as the default browser (only for the current user). Returns
+// false if this operation fails.
+bool SetAsDefaultBrowser();
+
+// Initiates an OS shell flow which (if followed by the user) should set
+// Chrome as the default browser. Returns false if the flow cannot be
+// initialized, if it is not supported (introduced for Windows 8) or if the
+// user cancels the operation. This is a blocking call and requires a FILE
+// thread. If Chrome is already default browser, no interactive dialog will be
+// shown and this method returns true.
+bool SetAsDefaultBrowserInteractive();
+
+// Returns true if setting the default browser is an asynchronous operation.
+// In practice, this is only true on Windows 10+.
+bool IsSetAsDefaultAsynchronous();
+
+// Sets Chrome as the default client application for the given protocol
+// (only for the current user). Returns false if this operation fails.
+bool SetAsDefaultProtocolClient(const std::string& protocol);
+
+// Initiates an OS shell flow which (if followed by the user) should set
+// Chrome as the default handler for |protocol|. Returns false if the flow
+// cannot be initialized, if it is not supported (introduced for Windows 8)
+// or if the user cancels the operation. This is a blocking call and requires
+// a FILE thread. If Chrome is already default for |protocol|, no interactive
+// dialog will be shown and this method returns true.
+bool SetAsDefaultProtocolClientInteractive(const std::string& protocol);
+
+// Windows 8 and Windows 10 introduced different ways to set the default
+// browser.
+enum DefaultWebClientSetPermission {
+ // The browser distribution is not permitted to be made default.
+ SET_DEFAULT_NOT_ALLOWED,
+ // No special permission or interaction is required to set the default
+ // browser. This is used in Linux, Mac and Windows 7 and under.
+ SET_DEFAULT_UNATTENDED,
+ // On Windows 8, a browser can be made default only in an interactive flow.
+ SET_DEFAULT_INTERACTIVE,
+ // On Windows 10+, the set default browser flow is both interactive and
+ // asynchronous.
+ SET_DEFAULT_ASYNCHRONOUS,
+};
- // Attempt to determine if this instance of Chrome is the default client
- // application for the given protocol and return the appropriate state.
- static DefaultWebClientState
- IsDefaultProtocolClient(const std::string& protocol);
+// Returns requirements for making the running browser the user's default.
+DefaultWebClientSetPermission CanSetAsDefaultBrowser();
+
+// Returns requirements for making the running browser the user's default
+// client application for specific protocols.
+DefaultWebClientSetPermission CanSetAsDefaultProtocolClient();
+
+// Returns true if making the running browser the default client for any
+// protocol requires elevated privileges.
+bool IsElevationNeededForSettingDefaultProtocolClient();
+
+// Returns a string representing the application to be launched given the
+// protocol of the requested url. This string may be a name or a path, but
+// neither is guaranteed and it should only be used as a display string.
+// Returns an empty string on failure.
+base::string16 GetApplicationNameForProtocol(const GURL& url);
+
+// On Linux, it may not be possible to determine or set the default browser
+// on some desktop environments or configurations. So, we use this enum and
+// not a plain bool.
+enum DefaultWebClientState {
+ NOT_DEFAULT,
+ IS_DEFAULT,
+ UNKNOWN_DEFAULT,
+ NUM_DEFAULT_STATES
+};
- // Data that needs to be passed between the app launcher stub and Chrome.
- struct AppModeInfo {
- };
- static void SetAppModeInfo(const AppModeInfo* info);
- static const AppModeInfo* AppModeInfo();
-
- // Is the current instance of Chrome running in App mode.
- bool IsRunningInAppMode();
-
- // Set up command line arguments for launching a URL or an app.
- // The new command line reuses the current process's user data directory (and
- // login profile, for ChromeOS).
- // If |extension_app_id| is non-empty, the arguments use kAppId=<id>.
- // Otherwise, kApp=<url> is used.
- static base::CommandLine CommandLineArgsForLauncher(
- const GURL& url,
- const std::string& extension_app_id,
- const base::FilePath& profile_path);
-
- // Append command line arguments for launching a new chrome.exe process
- // based on the current process.
- // The new command line reuses the current process's user data directory and
- // profile.
- static void AppendProfileArgs(const base::FilePath& profile_path,
- base::CommandLine* command_line);
+// Attempt to determine if this instance of Chrome is the default browser and
+// return the appropriate state. (Defined as being the handler for HTTP/HTTPS
+// protocols; we don't want to report "no" here if the user has simply chosen
+// to open HTML files in a text editor and FTP links with an FTP client.)
+DefaultWebClientState GetDefaultBrowser();
+
+// Returns true if Firefox is likely to be the default browser for the current
+// user. This method is very fast so it can be invoked in the UI thread.
+bool IsFirefoxDefaultBrowser();
+
+// Attempt to determine if this instance of Chrome is the default client
+// application for the given protocol and return the appropriate state.
+DefaultWebClientState IsDefaultProtocolClient(const std::string& protocol);
+
+// Data that needs to be passed between the app launcher stub and Chrome.
+struct AppModeInfo {};
+void SetAppModeInfo(const AppModeInfo* info);
+const AppModeInfo* AppModeInfo();
+
+// Is the current instance of Chrome running in App mode.
+bool IsRunningInAppMode();
+
+// Set up command line arguments for launching a URL or an app.
+// The new command line reuses the current process's user data directory (and
+// login profile, for ChromeOS).
+// If |extension_app_id| is non-empty, the arguments use kAppId=<id>.
+// Otherwise, kApp=<url> is used.
+base::CommandLine CommandLineArgsForLauncher(
+ const GURL& url,
+ const std::string& extension_app_id,
+ const base::FilePath& profile_path);
+
+// Append command line arguments for launching a new chrome.exe process
+// based on the current process.
+// The new command line reuses the current process's user data directory and
+// profile.
+void AppendProfileArgs(const base::FilePath& profile_path,
+ base::CommandLine* command_line);
#if defined(OS_WIN)
- // Generates an application user model ID (AppUserModelId) for a given app
- // name and profile path. The returned app id is in the format of
- // "|app_name|[.<profile_id>]". "profile_id" is appended when user override
- // the default value.
- // Note: If the app has an installation specific suffix (e.g. on user-level
- // Chrome installs), |app_name| should already be suffixed, this method will
- // then further suffix it with the profile id as described above.
- static base::string16 GetAppModelIdForProfile(const base::string16& app_name,
- const base::FilePath& profile_path);
-
- // Generates an application user model ID (AppUserModelId) for Chromium by
- // calling GetAppModelIdForProfile() with ShellUtil::GetAppId() as app_name.
- static base::string16 GetChromiumModelIdForProfile(
- const base::FilePath& profile_path);
-
- // Get the AppUserModelId for the App List, for the profile in |profile_path|.
- static base::string16 GetAppListAppModelIdForProfile(
- const base::FilePath& profile_path);
-
- // Migrates existing chrome taskbar pins by tagging them with correct app id.
- // see http://crbug.com/28104
- static void MigrateTaskbarPins();
-
- // Migrates all shortcuts in |path| which point to |chrome_exe| such that they
- // have the appropriate AppUserModelId. Also clears the legacy dual_mode
- // property from shortcuts with the default chrome app id.
- // Returns the number of shortcuts migrated.
- // This method should not be called prior to Windows 7.
- // This method is only public for the sake of tests and shouldn't be called
- // externally otherwise.
- static int MigrateShortcutsInPathInternal(const base::FilePath& chrome_exe,
- const base::FilePath& path);
-
- // Returns the path to the Start Menu shortcut for the given Chrome.
- static base::FilePath GetStartMenuShortcut(const base::FilePath& chrome_exe);
+// Generates an application user model ID (AppUserModelId) for a given app
+// name and profile path. The returned app id is in the format of
+// "|app_name|[.<profile_id>]". "profile_id" is appended when user override
+// the default value.
+// Note: If the app has an installation specific suffix (e.g. on user-level
+// Chrome installs), |app_name| should already be suffixed, this method will
+// then further suffix it with the profile id as described above.
+base::string16 GetAppModelIdForProfile(const base::string16& app_name,
+ const base::FilePath& profile_path);
+
+// Generates an application user model ID (AppUserModelId) for Chromium by
+// calling GetAppModelIdForProfile() with ShellUtil::GetAppId() as app_name.
+base::string16 GetChromiumModelIdForProfile(const base::FilePath& profile_path);
+
+// Get the AppUserModelId for the App List, for the profile in |profile_path|.
+base::string16 GetAppListAppModelIdForProfile(
+ const base::FilePath& profile_path);
+
+// Migrates existing chrome taskbar pins by tagging them with correct app id.
+// see http://crbug.com/28104
+void MigrateTaskbarPins();
+
+// Migrates all shortcuts in |path| which point to |chrome_exe| such that they
+// have the appropriate AppUserModelId. Also clears the legacy dual_mode
+// property from shortcuts with the default chrome app id.
+// Returns the number of shortcuts migrated.
+// This method should not be called prior to Windows 7.
+// This method is only public for the sake of tests and shouldn't be called
+// externally otherwise.
+int MigrateShortcutsInPathInternal(const base::FilePath& chrome_exe,
+ const base::FilePath& path);
+
+// Returns the path to the Start Menu shortcut for the given Chrome.
+base::FilePath GetStartMenuShortcut(const base::FilePath& chrome_exe);
#endif // defined(OS_WIN)
#if !defined(OS_WIN)
- // TODO(calamity): replace with
- // BrowserDistribution::GetStartMenuShortcutSubfolder() once
- // BrowserDistribution is cross-platform.
- // Gets the name of the Chrome Apps menu folder in which to place app
- // shortcuts. This is needed for Mac and Linux.
- static base::string16 GetAppShortcutsSubdirName();
+// TODO(calamity): replace with
+// BrowserDistribution::GetStartMenuShortcutSubfolder() once
+// BrowserDistribution is cross-platform.
+// Gets the name of the Chrome Apps menu folder in which to place app
+// shortcuts. This is needed for Mac and Linux.
+base::string16 GetAppShortcutsSubdirName();
#endif
- // The current default web client application UI state. This is used when
- // querying if Chrome is the default browser or the default handler
- // application for a url protocol, and communicates the state and result of
- // a request.
- enum DefaultWebClientUIState {
- STATE_PROCESSING,
- STATE_NOT_DEFAULT,
- STATE_IS_DEFAULT,
- STATE_UNKNOWN
- };
+// The current default web client application UI state. This is used when
+// querying if Chrome is the default browser or the default handler
+// application for a url protocol, and communicates the state and result of
+// a request.
+enum DefaultWebClientUIState {
+ STATE_PROCESSING,
+ STATE_NOT_DEFAULT,
+ STATE_IS_DEFAULT,
+ STATE_UNKNOWN
+};
- class DefaultWebClientObserver {
- public:
- virtual ~DefaultWebClientObserver() {}
- // Updates the UI state to reflect the current default browser state.
- virtual void SetDefaultWebClientUIState(DefaultWebClientUIState state) = 0;
- // Called to notify the UI of the immediate result of invoking
- // SetAsDefault.
- virtual void OnSetAsDefaultConcluded(bool succeeded) {}
- // Observer classes that return true to OwnedByWorker are automatically
- // freed by the worker when they are no longer needed. False by default.
- virtual bool IsOwnedByWorker();
- // An observer can permit or decline set-as-default operation if it
- // requires triggering user interaction. By default not allowed.
- virtual bool IsInteractiveSetDefaultPermitted();
- };
+class DefaultWebClientObserver {
+ public:
+ virtual ~DefaultWebClientObserver() {}
+ // Updates the UI state to reflect the current default browser state.
+ virtual void SetDefaultWebClientUIState(DefaultWebClientUIState state) = 0;
+ // Called to notify the UI of the immediate result of invoking
+ // SetAsDefault.
+ virtual void OnSetAsDefaultConcluded(bool succeeded) {}
+ // Observer classes that return true to OwnedByWorker are automatically
+ // freed by the worker when they are no longer needed. False by default.
+ virtual bool IsOwnedByWorker();
+ // An observer can permit or decline set-as-default operation if it
+ // requires triggering user interaction. By default not allowed.
+ virtual bool IsInteractiveSetDefaultPermitted();
+};
- // Helper objects that handle checking if Chrome is the default browser
- // or application for a url protocol on Windows and Linux, and also setting
- // it as the default. These operations are performed asynchronously on the
- // file thread since registry access (on Windows) or the preference database
- // (on Linux) are involved and this can be slow.
- class DefaultWebClientWorker
- : public base::RefCountedThreadSafe<DefaultWebClientWorker> {
- public:
- explicit DefaultWebClientWorker(DefaultWebClientObserver* observer);
-
- // Checks to see if Chrome is the default web client application. The result
- // will be passed back to the observer via the SetDefaultWebClientUIState
- // function. If there is no observer, this function does not do anything.
- void StartCheckIsDefault();
-
- // Sets Chrome as the default web client application. If there is an
- // observer, once the operation has completed the new default will be
- // queried and the current status reported via SetDefaultWebClientUIState.
- void StartSetAsDefault();
-
- // Called to notify the worker that the view is gone.
- void ObserverDestroyed();
-
- protected:
- friend class base::RefCountedThreadSafe<DefaultWebClientWorker>;
-
- // Possible result codes for a set-as-default operation.
- // Do not modify the ordering as it is important for UMA.
- enum AttemptResult {
- // Chrome was set as the default web client.
- SUCCESS,
- // Chrome was already the default web client. This counts as a successful
- // attempt.
- ALREADY_DEFAULT,
- // Chrome was not set as the default web client.
- FAILURE,
- // The attempt was abandoned because the observer was destroyed.
- ABANDONED,
- // Failed to launch the process to set Chrome as the default web client
- // asynchronously.
- LAUNCH_FAILURE,
- // Another worker is already in progress to make Chrome the default web
- // client.
- OTHER_WORKER,
- // The user initiated another attempt while the asynchronous operation was
- // already in progress.
- RETRY,
- // No errors were encountered yet Chrome is still not the default web
- // client.
- NO_ERRORS_NOT_DEFAULT,
- NUM_ATTEMPT_RESULT_TYPES
- };
-
- virtual ~DefaultWebClientWorker();
-
- // Communicates the result to the observer. In contrast to
- // OnSetAsDefaultAttemptComplete(), this should not be called multiple
- // times.
- void OnCheckIsDefaultComplete(DefaultWebClientState state);
-
- // Called when the set as default operation is completed. This then invokes
- // FinalizeSetAsDefault() and, if an observer is present, starts the check
- // is default process.
- // It is safe to call this multiple times. Only the first call is processed
- // after StartSetAsDefault() is invoked.
- void OnSetAsDefaultAttemptComplete(AttemptResult result);
-
- // Returns true if FinalizeSetAsDefault() will be called.
- bool set_as_default_initialized() const {
- return set_as_default_initialized_;
- }
-
- // Flag that indicates if the set-as-default operation is in progess to
- // prevent multiple notifications to the observer.
- bool set_as_default_in_progress_ = false;
-
- private:
- // Checks whether Chrome is the default web client. Always called on the
- // FILE thread. Subclasses are responsible for calling
- // OnCheckIsDefaultComplete() on the UI thread.
- virtual void CheckIsDefault() = 0;
-
- // Sets Chrome as the default web client. Always called on the FILE thread.
- // |interactive_permitted| will make SetAsDefault() fail if it requires
- // interaction with the user. Subclasses are responsible for calling
- // OnSetAsDefaultAttemptComplete() on the UI thread.
- virtual void SetAsDefault(bool interactive_permitted) = 0;
-
- // Returns the prefix used for metrics to differentiate UMA metrics for
- // setting the default browser and setting the default protocol client.
- virtual const char* GetHistogramPrefix() = 0;
-
- // Invoked on the UI thread prior to starting a set-as-default operation.
- // Returns true if the initialization succeeded and a subsequent call to
- // FinalizeSetAsDefault() is required.
- virtual bool InitializeSetAsDefault();
-
- // Invoked on the UI thread following a set-as-default operation.
- virtual void FinalizeSetAsDefault();
-
- // Reports the result and duration for one set-as-default attempt.
- void ReportAttemptResult(AttemptResult result);
-
- // Updates the UI in our associated view with the current default web
- // client state.
- void UpdateUI(DefaultWebClientState state);
-
- // Returns true if the duration of an attempt to set the default web client
- // should be reported to UMA for |result|.
- static bool ShouldReportDurationForResult(AttemptResult result);
-
- // Returns a string based on |result|. This is used for UMA reports.
- static const char* AttemptResultToString(AttemptResult result);
-
- DefaultWebClientObserver* observer_;
-
- // Flag that indicates the return value of InitializeSetAsDefault(). If
- // true, FinalizeSetAsDefault() will be called to clear what was
- // initialized.
- bool set_as_default_initialized_ = false;
-
- // Records the time it takes to set the default browser.
- base::TimeTicks start_time_;
-
- // Wait until Chrome has been confirmed as the default browser before
- // reporting a successful attempt.
- bool check_default_should_report_success_ = false;
-
- DISALLOW_COPY_AND_ASSIGN(DefaultWebClientWorker);
+// Helper objects that handle checking if Chrome is the default browser
+// or application for a url protocol on Windows and Linux, and also setting
+// it as the default. These operations are performed asynchronously on the
+// file thread since registry access (on Windows) or the preference database
+// (on Linux) are involved and this can be slow.
+class DefaultWebClientWorker
+ : public base::RefCountedThreadSafe<DefaultWebClientWorker> {
+ public:
+ explicit DefaultWebClientWorker(DefaultWebClientObserver* observer);
+
+ // Checks to see if Chrome is the default web client application. The result
+ // will be passed back to the observer via the SetDefaultWebClientUIState
+ // function. If there is no observer, this function does not do anything.
+ void StartCheckIsDefault();
+
+ // Sets Chrome as the default web client application. If there is an
+ // observer, once the operation has completed the new default will be
+ // queried and the current status reported via SetDefaultWebClientUIState.
+ void StartSetAsDefault();
+
+ // Called to notify the worker that the view is gone.
+ void ObserverDestroyed();
+
+ protected:
+ friend class base::RefCountedThreadSafe<DefaultWebClientWorker>;
+
+ // Possible result codes for a set-as-default operation.
+ // Do not modify the ordering as it is important for UMA.
+ enum AttemptResult {
+ // Chrome was set as the default web client.
+ SUCCESS,
+ // Chrome was already the default web client. This counts as a successful
+ // attempt.
+ ALREADY_DEFAULT,
+ // Chrome was not set as the default web client.
+ FAILURE,
+ // The attempt was abandoned because the observer was destroyed.
+ ABANDONED,
+ // Failed to launch the process to set Chrome as the default web client
+ // asynchronously.
+ LAUNCH_FAILURE,
+ // Another worker is already in progress to make Chrome the default web
+ // client.
+ OTHER_WORKER,
+ // The user initiated another attempt while the asynchronous operation was
+ // already in progress.
+ RETRY,
+ // No errors were encountered yet Chrome is still not the default web
+ // client.
+ NO_ERRORS_NOT_DEFAULT,
+ NUM_ATTEMPT_RESULT_TYPES
};
- // Worker for checking and setting the default browser.
- class DefaultBrowserWorker : public DefaultWebClientWorker {
- public:
- explicit DefaultBrowserWorker(DefaultWebClientObserver* observer);
+ virtual ~DefaultWebClientWorker();
+
+ // Communicates the result to the observer. In contrast to
+ // OnSetAsDefaultAttemptComplete(), this should not be called multiple
+ // times.
+ void OnCheckIsDefaultComplete(DefaultWebClientState state);
+
+ // Called when the set as default operation is completed. This then invokes
+ // FinalizeSetAsDefault() and, if an observer is present, starts the check
+ // is default process.
+ // It is safe to call this multiple times. Only the first call is processed
+ // after StartSetAsDefault() is invoked.
+ void OnSetAsDefaultAttemptComplete(AttemptResult result);
+
+ // Returns true if FinalizeSetAsDefault() will be called.
+ bool set_as_default_initialized() const {
+ return set_as_default_initialized_;
+ }
+
+ // Flag that indicates if the set-as-default operation is in progess to
+ // prevent multiple notifications to the observer.
+ bool set_as_default_in_progress_ = false;
+
+ private:
+ // Checks whether Chrome is the default web client. Always called on the
+ // FILE thread. Subclasses are responsible for calling
+ // OnCheckIsDefaultComplete() on the UI thread.
+ virtual void CheckIsDefault() = 0;
+
+ // Sets Chrome as the default web client. Always called on the FILE thread.
+ // |interactive_permitted| will make SetAsDefault() fail if it requires
+ // interaction with the user. Subclasses are responsible for calling
+ // OnSetAsDefaultAttemptComplete() on the UI thread.
+ virtual void SetAsDefault(bool interactive_permitted) = 0;
- private:
- ~DefaultBrowserWorker() override;
+ // Returns the prefix used for metrics to differentiate UMA metrics for
+ // setting the default browser and setting the default protocol client.
+ virtual const char* GetHistogramPrefix() = 0;
- // Check if Chrome is the default browser.
- void CheckIsDefault() override;
+ // Invoked on the UI thread prior to starting a set-as-default operation.
+ // Returns true if the initialization succeeded and a subsequent call to
+ // FinalizeSetAsDefault() is required.
+ virtual bool InitializeSetAsDefault();
- // Set Chrome as the default browser.
- void SetAsDefault(bool interactive_permitted) override;
+ // Invoked on the UI thread following a set-as-default operation.
+ virtual void FinalizeSetAsDefault();
- // Returns the histogram prefix for DefaultBrowserWorker.
- const char* GetHistogramPrefix() override;
+ // Reports the result and duration for one set-as-default attempt.
+ void ReportAttemptResult(AttemptResult result);
+
+ // Updates the UI in our associated view with the current default web
+ // client state.
+ void UpdateUI(DefaultWebClientState state);
+
+ // Returns true if the duration of an attempt to set the default web client
+ // should be reported to UMA for |result|.
+ static bool ShouldReportDurationForResult(AttemptResult result);
+
+ // Returns a string based on |result|. This is used for UMA reports.
+ static const char* AttemptResultToString(AttemptResult result);
+
+ DefaultWebClientObserver* observer_;
+
+ // Flag that indicates the return value of InitializeSetAsDefault(). If
+ // true, FinalizeSetAsDefault() will be called to clear what was
+ // initialized.
+ bool set_as_default_initialized_ = false;
+
+ // Records the time it takes to set the default browser.
+ base::TimeTicks start_time_;
+
+ // Wait until Chrome has been confirmed as the default browser before
+ // reporting a successful attempt.
+ bool check_default_should_report_success_ = false;
+
+ DISALLOW_COPY_AND_ASSIGN(DefaultWebClientWorker);
+};
+
+// Worker for checking and setting the default browser.
+class DefaultBrowserWorker : public DefaultWebClientWorker {
+ public:
+ explicit DefaultBrowserWorker(DefaultWebClientObserver* observer);
+
+ private:
+ ~DefaultBrowserWorker() override;
+
+ // Check if Chrome is the default browser.
+ void CheckIsDefault() override;
+
+ // Set Chrome as the default browser.
+ void SetAsDefault(bool interactive_permitted) override;
+
+ // Returns the histogram prefix for DefaultBrowserWorker.
+ const char* GetHistogramPrefix() override;
#if defined(OS_WIN)
- // On Windows 10+, adds the default browser callback and starts the timer
- // that determines if the operation was successful or not.
- bool InitializeSetAsDefault() override;
+ // On Windows 10+, adds the default browser callback and starts the timer
+ // that determines if the operation was successful or not.
+ bool InitializeSetAsDefault() override;
- // On Windows 10+, removes the default browser callback and stops the timer.
- void FinalizeSetAsDefault() override;
+ // On Windows 10+, removes the default browser callback and stops the timer.
+ void FinalizeSetAsDefault() override;
- // Prompts the user to select the default browser by trying to open the help
- // page that explains how to set Chrome as the default browser. Returns
- // false if the process needed to set Chrome default failed to launch.
- static bool SetAsDefaultBrowserAsynchronous();
+ // Prompts the user to select the default browser by trying to open the help
+ // page that explains how to set Chrome as the default browser. Returns
+ // false if the process needed to set Chrome default failed to launch.
+ static bool SetAsDefaultBrowserAsynchronous();
- // Used to determine if setting the default browser was unsuccesful.
- scoped_ptr<base::OneShotTimer> async_timer_;
+ // Used to determine if setting the default browser was unsuccesful.
+ scoped_ptr<base::OneShotTimer> async_timer_;
#endif // defined(OS_WIN)
- DISALLOW_COPY_AND_ASSIGN(DefaultBrowserWorker);
- };
+ DISALLOW_COPY_AND_ASSIGN(DefaultBrowserWorker);
+};
- // Worker for checking and setting the default client application
- // for a given protocol. A different worker instance is needed for each
- // protocol you are interested in, so to check or set the default for
- // multiple protocols you should use multiple worker objects.
- class DefaultProtocolClientWorker : public DefaultWebClientWorker {
- public:
- DefaultProtocolClientWorker(DefaultWebClientObserver* observer,
- const std::string& protocol);
+// Worker for checking and setting the default client application
+// for a given protocol. A different worker instance is needed for each
+// protocol you are interested in, so to check or set the default for
+// multiple protocols you should use multiple worker objects.
+class DefaultProtocolClientWorker : public DefaultWebClientWorker {
+ public:
+ DefaultProtocolClientWorker(DefaultWebClientObserver* observer,
+ const std::string& protocol);
- const std::string& protocol() const { return protocol_; }
+ const std::string& protocol() const { return protocol_; }
- protected:
- ~DefaultProtocolClientWorker() override;
+ protected:
+ ~DefaultProtocolClientWorker() override;
- private:
- // Check is Chrome is the default handler for this protocol.
- void CheckIsDefault() override;
+ private:
+ // Check is Chrome is the default handler for this protocol.
+ void CheckIsDefault() override;
- // Set Chrome as the default handler for this protocol.
- void SetAsDefault(bool interactive_permitted) override;
+ // Set Chrome as the default handler for this protocol.
+ void SetAsDefault(bool interactive_permitted) override;
- // Returns the histogram prefix for DefaultProtocolClientWorker.
- const char* GetHistogramPrefix() override;
+ // Returns the histogram prefix for DefaultProtocolClientWorker.
+ const char* GetHistogramPrefix() override;
- std::string protocol_;
+ std::string protocol_;
- DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker);
- };
+ DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker);
};
+} // namespace shell_integration
+
#endif // CHROME_BROWSER_SHELL_INTEGRATION_H_
diff --git a/chrome/browser/shell_integration_android.cc b/chrome/browser/shell_integration_android.cc
index 14062b0..fcab00d 100644
--- a/chrome/browser/shell_integration_android.cc
+++ b/chrome/browser/shell_integration_android.cc
@@ -5,40 +5,36 @@
#include "base/logging.h"
#include "chrome/browser/shell_integration.h"
+namespace shell_integration {
+
// TODO: crbug/115375 to track implementation for following methods.
-// static
-bool ShellIntegration::SetAsDefaultBrowser() {
+bool SetAsDefaultBrowser() {
NOTIMPLEMENTED();
return false;
}
-// static
-bool ShellIntegration::SetAsDefaultProtocolClient(const std::string& protocol) {
+bool SetAsDefaultProtocolClient(const std::string& protocol) {
NOTIMPLEMENTED();
return false;
}
-// static
-ShellIntegration::DefaultWebClientSetPermission
- ShellIntegration::CanSetAsDefaultBrowser() {
+DefaultWebClientSetPermission CanSetAsDefaultBrowser() {
NOTIMPLEMENTED();
return SET_DEFAULT_NOT_ALLOWED;
}
-// static
-ShellIntegration::DefaultWebClientState ShellIntegration::GetDefaultBrowser() {
+DefaultWebClientState GetDefaultBrowser() {
NOTIMPLEMENTED();
return UNKNOWN_DEFAULT;
}
-// static
-bool ShellIntegration::IsFirefoxDefaultBrowser() {
+bool IsFirefoxDefaultBrowser() {
return false;
}
-// static
-ShellIntegration::DefaultWebClientState
-ShellIntegration::IsDefaultProtocolClient(const std::string& protocol) {
+DefaultWebClientState IsDefaultProtocolClient(const std::string& protocol) {
NOTIMPLEMENTED();
return UNKNOWN_DEFAULT;
}
+
+} // namespace shell_integration
diff --git a/chrome/browser/shell_integration_chromeos.cc b/chrome/browser/shell_integration_chromeos.cc
index b08d1ec..f275554 100644
--- a/chrome/browser/shell_integration_chromeos.cc
+++ b/chrome/browser/shell_integration_chromeos.cc
@@ -4,34 +4,30 @@
#include "chrome/browser/shell_integration.h"
-// static
-bool ShellIntegration::SetAsDefaultBrowser() {
+namespace shell_integration {
+
+bool SetAsDefaultBrowser() {
return false;
}
-// static
-bool ShellIntegration::SetAsDefaultProtocolClient(const std::string& protocol) {
+bool SetAsDefaultProtocolClient(const std::string& protocol) {
return false;
}
-// static
-ShellIntegration::DefaultWebClientSetPermission
- ShellIntegration::CanSetAsDefaultBrowser() {
+DefaultWebClientSetPermission CanSetAsDefaultBrowser() {
return SET_DEFAULT_NOT_ALLOWED;
}
-// static
-ShellIntegration::DefaultWebClientState ShellIntegration::GetDefaultBrowser() {
+DefaultWebClientState GetDefaultBrowser() {
return UNKNOWN_DEFAULT;
}
-// static
-bool ShellIntegration::IsFirefoxDefaultBrowser() {
+bool IsFirefoxDefaultBrowser() {
return false;
}
-// static
-ShellIntegration::DefaultWebClientState
-ShellIntegration::IsDefaultProtocolClient(const std::string& protocol) {
+DefaultWebClientState IsDefaultProtocolClient(const std::string& protocol) {
return UNKNOWN_DEFAULT;
}
+
+} // namespace shell_integration
diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc
index c521d292..4e540b2 100644
--- a/chrome/browser/shell_integration_linux.cc
+++ b/chrome/browser/shell_integration_linux.cc
@@ -55,11 +55,9 @@
using content::BrowserThread;
-namespace {
+namespace shell_integration {
-// The Categories for the App Launcher desktop shortcut. Should be the same as
-// the Chrome desktop shortcut, so they are in the same sub-menu.
-const char kAppListCategories[] = "Network;WebBrowser;";
+namespace {
// Helper to launch xdg scripts. We don't want them to ask any questions on the
// terminal etc. The function returns true if the utility launches and exits
@@ -87,6 +85,174 @@ bool LaunchXdgUtility(const std::vector<std::string>& argv, int* exit_code) {
return process.WaitForExit(exit_code);
}
+const char kXdgSettings[] = "xdg-settings";
+const char kXdgSettingsDefaultBrowser[] = "default-web-browser";
+const char kXdgSettingsDefaultSchemeHandler[] = "default-url-scheme-handler";
+
+// Utility function to get the path to the version of a script shipped with
+// Chrome. |script| gives the name of the script. |chrome_version| returns the
+// path to the Chrome version of the script, and the return value of the
+// function is true if the function is successful and the Chrome version is
+// not the script found on the PATH.
+bool GetChromeVersionOfScript(const std::string& script,
+ std::string* chrome_version) {
+ // Get the path to the Chrome version.
+ base::FilePath chrome_dir;
+ if (!PathService::Get(base::DIR_EXE, &chrome_dir))
+ return false;
+
+ base::FilePath chrome_version_path = chrome_dir.Append(script);
+ *chrome_version = chrome_version_path.value();
+
+ // Check if this is different to the one on path.
+ std::vector<std::string> argv;
+ argv.push_back("which");
+ argv.push_back(script);
+ std::string path_version;
+ if (base::GetAppOutput(base::CommandLine(argv), &path_version)) {
+ // Remove trailing newline
+ path_version.erase(path_version.length() - 1, 1);
+ base::FilePath path_version_path(path_version);
+ return (chrome_version_path != path_version_path);
+ }
+ return false;
+}
+
+// Value returned by xdg-settings if it can't understand our request.
+const int EXIT_XDG_SETTINGS_SYNTAX_ERROR = 1;
+
+// We delegate the difficulty of setting the default browser and default url
+// scheme handler in Linux desktop environments to an xdg utility, xdg-settings.
+
+// When calling this script we first try to use the script on PATH. If that
+// fails we then try to use the script that we have included. This gives
+// scripts on the system priority over ours, as distribution vendors may have
+// tweaked the script, but still allows our copy to be used if the script on the
+// system fails, as the system copy may be missing capabilities of the Chrome
+// copy.
+
+// If |protocol| is empty this function sets Chrome as the default browser,
+// otherwise it sets Chrome as the default handler application for |protocol|.
+bool SetDefaultWebClient(const std::string& protocol) {
+#if defined(OS_CHROMEOS)
+ return true;
+#else
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+
+ std::vector<std::string> argv;
+ argv.push_back(kXdgSettings);
+ argv.push_back("set");
+ if (protocol.empty()) {
+ argv.push_back(kXdgSettingsDefaultBrowser);
+ } else {
+ argv.push_back(kXdgSettingsDefaultSchemeHandler);
+ argv.push_back(protocol);
+ }
+ argv.push_back(shell_integration_linux::GetDesktopName(env.get()));
+
+ int exit_code;
+ bool ran_ok = LaunchXdgUtility(argv, &exit_code);
+ if (ran_ok && exit_code == EXIT_XDG_SETTINGS_SYNTAX_ERROR) {
+ if (GetChromeVersionOfScript(kXdgSettings, &argv[0])) {
+ ran_ok = LaunchXdgUtility(argv, &exit_code);
+ }
+ }
+
+ return ran_ok && exit_code == EXIT_SUCCESS;
+#endif
+}
+
+// If |protocol| is empty this function checks if Chrome is the default browser,
+// otherwise it checks if Chrome is the default handler application for
+// |protocol|.
+DefaultWebClientState GetIsDefaultWebClient(const std::string& protocol) {
+#if defined(OS_CHROMEOS)
+ return UNKNOWN_DEFAULT;
+#else
+ base::ThreadRestrictions::AssertIOAllowed();
+
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+
+ std::vector<std::string> argv;
+ argv.push_back(kXdgSettings);
+ argv.push_back("check");
+ if (protocol.empty()) {
+ argv.push_back(kXdgSettingsDefaultBrowser);
+ } else {
+ argv.push_back(kXdgSettingsDefaultSchemeHandler);
+ argv.push_back(protocol);
+ }
+ argv.push_back(shell_integration_linux::GetDesktopName(env.get()));
+
+ std::string reply;
+ int success_code;
+ bool ran_ok = base::GetAppOutputWithExitCode(base::CommandLine(argv), &reply,
+ &success_code);
+ if (ran_ok && success_code == EXIT_XDG_SETTINGS_SYNTAX_ERROR) {
+ if (GetChromeVersionOfScript(kXdgSettings, &argv[0])) {
+ ran_ok = base::GetAppOutputWithExitCode(base::CommandLine(argv), &reply,
+ &success_code);
+ }
+ }
+
+ if (!ran_ok || success_code != EXIT_SUCCESS) {
+ // xdg-settings failed: we can't determine or set the default browser.
+ return UNKNOWN_DEFAULT;
+ }
+
+ // Allow any reply that starts with "yes".
+ return (reply.find("yes") == 0) ? IS_DEFAULT : NOT_DEFAULT;
+#endif
+}
+
+} // namespace
+
+bool SetAsDefaultBrowser() {
+ return SetDefaultWebClient(std::string());
+}
+
+bool SetAsDefaultProtocolClient(const std::string& protocol) {
+ return SetDefaultWebClient(protocol);
+}
+
+DefaultWebClientSetPermission CanSetAsDefaultBrowser() {
+ return SET_DEFAULT_UNATTENDED;
+}
+
+base::string16 GetApplicationNameForProtocol(const GURL& url) {
+ return base::ASCIIToUTF16("xdg-open");
+}
+
+DefaultWebClientState GetDefaultBrowser() {
+ return GetIsDefaultWebClient(std::string());
+}
+
+bool IsFirefoxDefaultBrowser() {
+ std::vector<std::string> argv;
+ argv.push_back(kXdgSettings);
+ argv.push_back("get");
+ argv.push_back(kXdgSettingsDefaultBrowser);
+
+ std::string browser;
+ // We don't care about the return value here.
+ base::GetAppOutput(base::CommandLine(argv), &browser);
+ return browser.find("irefox") != std::string::npos;
+}
+
+DefaultWebClientState IsDefaultProtocolClient(const std::string& protocol) {
+ return GetIsDefaultWebClient(protocol);
+}
+
+} // namespace shell_integration
+
+namespace shell_integration_linux {
+
+namespace {
+
+// The Categories for the App Launcher desktop shortcut. Should be the same as
+// the Chrome desktop shortcut, so they are in the same sub-menu.
+const char kAppListCategories[] = "Network;WebBrowser;";
+
std::string CreateShortcutIcon(const gfx::ImageFamily& icon_images,
const base::FilePath& shortcut_filename) {
if (icon_images.empty())
@@ -133,7 +299,7 @@ std::string CreateShortcutIcon(const gfx::ImageFamily& icon_images,
argv.push_back(temp_file_path.value());
argv.push_back(icon_name);
int exit_code;
- if (!LaunchXdgUtility(argv, &exit_code) || exit_code) {
+ if (!shell_integration::LaunchXdgUtility(argv, &exit_code) || exit_code) {
LOG(WARNING) << "Could not install icon " << icon_name << ".png at size "
<< width << ".";
}
@@ -232,7 +398,7 @@ bool CreateShortcutInApplicationsMenu(const base::FilePath& shortcut_filename,
argv.push_back(temp_directory_path.value());
argv.push_back(temp_file_path.value());
int exit_code;
- LaunchXdgUtility(argv, &exit_code);
+ shell_integration::LaunchXdgUtility(argv, &exit_code);
return exit_code == 0;
}
@@ -255,7 +421,7 @@ void DeleteShortcutInApplicationsMenu(
argv.push_back(directory_filename.value());
argv.push_back(shortcut_filename.value());
int exit_code;
- LaunchXdgUtility(argv, &exit_code);
+ shell_integration::LaunchXdgUtility(argv, &exit_code);
}
#if defined(USE_GLIB)
@@ -311,10 +477,6 @@ const char kDesktopEntry[] = "Desktop Entry";
const char kXdgOpenShebang[] = "#!/usr/bin/env xdg-open";
#endif
-const char kXdgSettings[] = "xdg-settings";
-const char kXdgSettingsDefaultBrowser[] = "default-web-browser";
-const char kXdgSettingsDefaultSchemeHandler[] = "default-url-scheme-handler";
-
const char kDirectoryFilename[] = "chrome-apps.directory";
#if defined(GOOGLE_CHROME_BUILD)
@@ -323,124 +485,6 @@ const char kAppListDesktopName[] = "chrome-app-list";
const char kAppListDesktopName[] = "chromium-app-list";
#endif
-// Utility function to get the path to the version of a script shipped with
-// Chrome. |script| gives the name of the script. |chrome_version| returns the
-// path to the Chrome version of the script, and the return value of the
-// function is true if the function is successful and the Chrome version is
-// not the script found on the PATH.
-bool GetChromeVersionOfScript(const std::string& script,
- std::string* chrome_version) {
- // Get the path to the Chrome version.
- base::FilePath chrome_dir;
- if (!PathService::Get(base::DIR_EXE, &chrome_dir))
- return false;
-
- base::FilePath chrome_version_path = chrome_dir.Append(script);
- *chrome_version = chrome_version_path.value();
-
- // Check if this is different to the one on path.
- std::vector<std::string> argv;
- argv.push_back("which");
- argv.push_back(script);
- std::string path_version;
- if (base::GetAppOutput(base::CommandLine(argv), &path_version)) {
- // Remove trailing newline
- path_version.erase(path_version.length() - 1, 1);
- base::FilePath path_version_path(path_version);
- return (chrome_version_path != path_version_path);
- }
- return false;
-}
-
-// Value returned by xdg-settings if it can't understand our request.
-const int EXIT_XDG_SETTINGS_SYNTAX_ERROR = 1;
-
-// We delegate the difficulty of setting the default browser and default url
-// scheme handler in Linux desktop environments to an xdg utility, xdg-settings.
-
-// When calling this script we first try to use the script on PATH. If that
-// fails we then try to use the script that we have included. This gives
-// scripts on the system priority over ours, as distribution vendors may have
-// tweaked the script, but still allows our copy to be used if the script on the
-// system fails, as the system copy may be missing capabilities of the Chrome
-// copy.
-
-// If |protocol| is empty this function sets Chrome as the default browser,
-// otherwise it sets Chrome as the default handler application for |protocol|.
-bool SetDefaultWebClient(const std::string& protocol) {
-#if defined(OS_CHROMEOS)
- return true;
-#else
- scoped_ptr<base::Environment> env(base::Environment::Create());
-
- std::vector<std::string> argv;
- argv.push_back(kXdgSettings);
- argv.push_back("set");
- if (protocol.empty()) {
- argv.push_back(kXdgSettingsDefaultBrowser);
- } else {
- argv.push_back(kXdgSettingsDefaultSchemeHandler);
- argv.push_back(protocol);
- }
- argv.push_back(shell_integration_linux::GetDesktopName(env.get()));
-
- int exit_code;
- bool ran_ok = LaunchXdgUtility(argv, &exit_code);
- if (ran_ok && exit_code == EXIT_XDG_SETTINGS_SYNTAX_ERROR) {
- if (GetChromeVersionOfScript(kXdgSettings, &argv[0])) {
- ran_ok = LaunchXdgUtility(argv, &exit_code);
- }
- }
-
- return ran_ok && exit_code == EXIT_SUCCESS;
-#endif
-}
-
-// If |protocol| is empty this function checks if Chrome is the default browser,
-// otherwise it checks if Chrome is the default handler application for
-// |protocol|.
-ShellIntegration::DefaultWebClientState GetIsDefaultWebClient(
- const std::string& protocol) {
-#if defined(OS_CHROMEOS)
- return ShellIntegration::UNKNOWN_DEFAULT;
-#else
- base::ThreadRestrictions::AssertIOAllowed();
-
- scoped_ptr<base::Environment> env(base::Environment::Create());
-
- std::vector<std::string> argv;
- argv.push_back(kXdgSettings);
- argv.push_back("check");
- if (protocol.empty()) {
- argv.push_back(kXdgSettingsDefaultBrowser);
- } else {
- argv.push_back(kXdgSettingsDefaultSchemeHandler);
- argv.push_back(protocol);
- }
- argv.push_back(shell_integration_linux::GetDesktopName(env.get()));
-
- std::string reply;
- int success_code;
- bool ran_ok = base::GetAppOutputWithExitCode(base::CommandLine(argv), &reply,
- &success_code);
- if (ran_ok && success_code == EXIT_XDG_SETTINGS_SYNTAX_ERROR) {
- if (GetChromeVersionOfScript(kXdgSettings, &argv[0])) {
- ran_ok = base::GetAppOutputWithExitCode(base::CommandLine(argv), &reply,
- &success_code);
- }
- }
-
- if (!ran_ok || success_code != EXIT_SUCCESS) {
- // xdg-settings failed: we can't determine or set the default browser.
- return ShellIntegration::UNKNOWN_DEFAULT;
- }
-
- // Allow any reply that starts with "yes".
- return (reply.find("yes") == 0) ? ShellIntegration::IS_DEFAULT :
- ShellIntegration::NOT_DEFAULT;
-#endif
-}
-
// Get the value of NoDisplay from the [Desktop Entry] section of a .desktop
// file, given in |shortcut_contents|. If the key is not found, returns false.
bool GetNoDisplayFromDesktopFile(const std::string& shortcut_contents) {
@@ -497,56 +541,6 @@ base::FilePath GetChromeExePath() {
} // namespace
-// static
-bool ShellIntegration::SetAsDefaultBrowser() {
- return SetDefaultWebClient(std::string());
-}
-
-// static
-bool ShellIntegration::SetAsDefaultProtocolClient(
- const std::string& protocol) {
- return SetDefaultWebClient(protocol);
-}
-
-// static
-ShellIntegration::DefaultWebClientSetPermission
-ShellIntegration::CanSetAsDefaultBrowser() {
- return SET_DEFAULT_UNATTENDED;
-}
-
-// static
-base::string16 ShellIntegration::GetApplicationNameForProtocol(
- const GURL& url) {
- return base::ASCIIToUTF16("xdg-open");
-}
-
-// static
-ShellIntegration::DefaultWebClientState
-ShellIntegration::GetDefaultBrowser() {
- return GetIsDefaultWebClient(std::string());
-}
-
-// static
-bool ShellIntegration::IsFirefoxDefaultBrowser() {
- std::vector<std::string> argv;
- argv.push_back(kXdgSettings);
- argv.push_back("get");
- argv.push_back(kXdgSettingsDefaultBrowser);
-
- std::string browser;
- // We don't care about the return value here.
- base::GetAppOutput(base::CommandLine(argv), &browser);
- return browser.find("irefox") != std::string::npos;
-}
-
-// static
-ShellIntegration::DefaultWebClientState
-ShellIntegration::IsDefaultProtocolClient(const std::string& protocol) {
- return GetIsDefaultWebClient(protocol);
-}
-
-namespace shell_integration_linux {
-
base::FilePath GetDataWriteLocation(base::Environment* env) {
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
@@ -756,9 +750,8 @@ std::string GetDesktopFileContents(
const base::FilePath& profile_path,
const std::string& categories,
bool no_display) {
- base::CommandLine cmd_line =
- ShellIntegration::CommandLineArgsForLauncher(url, extension_id,
- profile_path);
+ base::CommandLine cmd_line = shell_integration::CommandLineArgsForLauncher(
+ url, extension_id, profile_path);
cmd_line.SetProgram(chrome_exe_path);
return GetDesktopFileContentsForCommand(cmd_line, app_name, url, title,
icon_name, categories, no_display);
@@ -951,7 +944,7 @@ bool CreateDesktopShortcut(
case web_app::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS:
directory_filename = base::FilePath(kDirectoryFilename);
directory_contents = GetDirectoryFileContents(
- ShellIntegration::GetAppShortcutsSubdirName(), "");
+ shell_integration::GetAppShortcutsSubdirName(), "");
break;
default:
NOTREACHED();
diff --git a/chrome/browser/shell_integration_mac.mm b/chrome/browser/shell_integration_mac.mm
index 08b60bd..2ae55e1 100644
--- a/chrome/browser/shell_integration_mac.mm
+++ b/chrome/browser/shell_integration_mac.mm
@@ -11,6 +11,8 @@
#include "components/version_info/version_info.h"
#import "third_party/mozilla/NSWorkspace+Utils.h"
+namespace shell_integration {
+
namespace {
// Returns true if |identifier| is the bundle id of the default browser.
@@ -50,7 +52,7 @@ bool IsIdentifierDefaultProtocolClient(NSString* identifier,
// Sets Chromium as default browser to be used by the operating system. This
// applies only for the current user. Returns false if this cannot be done, or
// if the operation fails.
-bool ShellIntegration::SetAsDefaultBrowser() {
+bool SetAsDefaultBrowser() {
if (CanSetAsDefaultBrowser() != SET_DEFAULT_UNATTENDED)
return false;
@@ -67,7 +69,7 @@ bool ShellIntegration::SetAsDefaultBrowser() {
// Sets Chromium as the default application to be used by the operating system
// for the given protocol. This applies only for the current user. Returns false
// if this cannot be done, or if the operation fails.
-bool ShellIntegration::SetAsDefaultProtocolClient(const std::string& protocol) {
+bool SetAsDefaultProtocolClient(const std::string& protocol) {
if (protocol.empty())
return false;
@@ -87,8 +89,7 @@ bool ShellIntegration::SetAsDefaultProtocolClient(const std::string& protocol) {
return return_code == noErr;
}
-ShellIntegration::DefaultWebClientSetPermission
- ShellIntegration::CanSetAsDefaultBrowser() {
+DefaultWebClientSetPermission CanSetAsDefaultBrowser() {
if (chrome::GetChannel() != version_info::Channel::CANARY) {
return SET_DEFAULT_UNATTENDED;
}
@@ -96,9 +97,7 @@ ShellIntegration::DefaultWebClientSetPermission
return SET_DEFAULT_NOT_ALLOWED;
}
-// static
-base::string16 ShellIntegration::GetApplicationNameForProtocol(
- const GURL& url) {
+base::string16 GetApplicationNameForProtocol(const GURL& url) {
NSURL* ns_url = [NSURL URLWithString:
base::SysUTF8ToNSString(url.possibly_invalid_spec())];
CFURLRef openingApp = NULL;
@@ -121,7 +120,7 @@ base::string16 ShellIntegration::GetApplicationNameForProtocol(
// return the appropriate state. (Defined as being the handler for HTTP/HTTPS
// protocols; we don't want to report "no" here if the user has simply chosen
// to open HTML files in a text editor and FTP links with an FTP client.)
-ShellIntegration::DefaultWebClientState ShellIntegration::GetDefaultBrowser() {
+DefaultWebClientState GetDefaultBrowser() {
// We really do want the outer bundle here, since this we want to know the
// status of the main Chrome bundle and not a shortcut.
NSString* my_identifier = [base::mac::OuterBundle() bundleIdentifier];
@@ -132,14 +131,13 @@ ShellIntegration::DefaultWebClientState ShellIntegration::GetDefaultBrowser() {
}
// Returns true if Firefox is the default browser for the current user.
-bool ShellIntegration::IsFirefoxDefaultBrowser() {
+bool IsFirefoxDefaultBrowser() {
return IsIdentifierDefaultBrowser(@"org.mozilla.firefox");
}
// Attempt to determine if this instance of Chrome is the default client
// application for the given protocol and return the appropriate state.
-ShellIntegration::DefaultWebClientState
- ShellIntegration::IsDefaultProtocolClient(const std::string& protocol) {
+DefaultWebClientState IsDefaultProtocolClient(const std::string& protocol) {
if (protocol.empty())
return UNKNOWN_DEFAULT;
@@ -153,3 +151,5 @@ ShellIntegration::DefaultWebClientState
return IsIdentifierDefaultProtocolClient(my_identifier, protocol_ns) ?
IS_DEFAULT : NOT_DEFAULT;
}
+
+} // namespace shell_integration \ No newline at end of file
diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc
index e18866e..8b95570 100644
--- a/chrome/browser/shell_integration_win.cc
+++ b/chrome/browser/shell_integration_win.cc
@@ -51,6 +51,8 @@
using content::BrowserThread;
+namespace shell_integration {
+
namespace {
const wchar_t kAppListAppNameSuffix[] = L"AppList";
@@ -66,7 +68,7 @@ const char kAsyncSetAsDefaultEnabledBuildNumberParamName[] =
const char kEnableAsyncSetAsDefault[] = "enable-async-set-as-default";
const char kDisableAsyncSetAsDefault[] = "disable-async-set-as-default";
-// Helper function for ShellIntegration::GetAppId to generates profile id
+// Helper function for GetAppId to generates profile id
// from profile path. "profile_id" is composed of sanitized basenames of
// user data dir and profile dir joined by a ".".
base::string16 GetProfileIdFromPath(const base::FilePath& profile_path) {
@@ -149,7 +151,7 @@ base::string16 GetExpectedAppId(const base::CommandLine& command_line,
}
DCHECK(!app_name.empty());
- return ShellIntegration::GetAppModelIdForProfile(app_name, profile_path);
+ return GetAppModelIdForProfile(app_name, profile_path);
}
void MigrateTaskbarPinsCallback() {
@@ -167,7 +169,7 @@ void MigrateTaskbarPinsCallback() {
return;
}
- ShellIntegration::MigrateShortcutsInPathInternal(chrome_exe, pins_path);
+ MigrateShortcutsInPathInternal(chrome_exe, pins_path);
}
// Windows 8 introduced a new protocol->executable binding system which cannot
@@ -217,18 +219,16 @@ base::string16 GetAppForProtocolUsingRegistry(const GURL& url) {
return base::string16();
}
-
-ShellIntegration::DefaultWebClientState
- GetDefaultWebClientStateFromShellUtilDefaultState(
- ShellUtil::DefaultState default_state) {
+DefaultWebClientState GetDefaultWebClientStateFromShellUtilDefaultState(
+ ShellUtil::DefaultState default_state) {
switch (default_state) {
case ShellUtil::NOT_DEFAULT:
- return ShellIntegration::NOT_DEFAULT;
+ return DefaultWebClientState::NOT_DEFAULT;
case ShellUtil::IS_DEFAULT:
- return ShellIntegration::IS_DEFAULT;
+ return DefaultWebClientState::IS_DEFAULT;
default:
DCHECK_EQ(ShellUtil::UNKNOWN_DEFAULT, default_state);
- return ShellIntegration::UNKNOWN_DEFAULT;
+ return DefaultWebClientState::UNKNOWN_DEFAULT;
}
}
@@ -300,13 +300,12 @@ bool RegisterBrowser() {
} // namespace
-// static
-bool ShellIntegration::IsSetAsDefaultAsynchronous() {
+bool IsSetAsDefaultAsynchronous() {
return base::win::GetVersion() >= base::win::VERSION_WIN10 &&
IsAsyncSetAsDefaultEnabled();
}
-bool ShellIntegration::SetAsDefaultBrowser() {
+bool SetAsDefaultBrowser() {
base::FilePath chrome_exe;
if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
LOG(ERROR) << "Error getting app exe path";
@@ -325,7 +324,7 @@ bool ShellIntegration::SetAsDefaultBrowser() {
return true;
}
-bool ShellIntegration::SetAsDefaultBrowserInteractive() {
+bool SetAsDefaultBrowserInteractive() {
base::FilePath chrome_exe;
if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
NOTREACHED() << "Error getting app exe path";
@@ -342,7 +341,7 @@ bool ShellIntegration::SetAsDefaultBrowserInteractive() {
return true;
}
-bool ShellIntegration::SetAsDefaultProtocolClient(const std::string& protocol) {
+bool SetAsDefaultProtocolClient(const std::string& protocol) {
if (protocol.empty())
return false;
@@ -365,8 +364,7 @@ bool ShellIntegration::SetAsDefaultProtocolClient(const std::string& protocol) {
return true;
}
-bool ShellIntegration::SetAsDefaultProtocolClientInteractive(
- const std::string& protocol) {
+bool SetAsDefaultProtocolClientInteractive(const std::string& protocol) {
base::FilePath chrome_exe;
if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
NOTREACHED() << "Error getting app exe path";
@@ -385,8 +383,7 @@ bool ShellIntegration::SetAsDefaultProtocolClientInteractive(
return true;
}
-ShellIntegration::DefaultWebClientSetPermission
- ShellIntegration::CanSetAsDefaultBrowser() {
+DefaultWebClientSetPermission CanSetAsDefaultBrowser() {
BrowserDistribution* distribution = BrowserDistribution::GetDistribution();
if (distribution->GetDefaultBrowserControlPolicy() !=
BrowserDistribution::DEFAULT_BROWSER_FULL_CONTROL)
@@ -398,12 +395,11 @@ ShellIntegration::DefaultWebClientSetPermission
return SET_DEFAULT_INTERACTIVE;
}
-bool ShellIntegration::IsElevationNeededForSettingDefaultProtocolClient() {
+bool IsElevationNeededForSettingDefaultProtocolClient() {
return base::win::GetVersion() < base::win::VERSION_WIN8;
}
-base::string16 ShellIntegration::GetApplicationNameForProtocol(
- const GURL& url) {
+base::string16 GetApplicationNameForProtocol(const GURL& url) {
// Windows 8 or above requires a new protocol association query.
if (base::win::GetVersion() >= base::win::VERSION_WIN8)
return GetAppForProtocolUsingAssocQuery(url);
@@ -411,7 +407,7 @@ base::string16 ShellIntegration::GetApplicationNameForProtocol(
return GetAppForProtocolUsingRegistry(url);
}
-ShellIntegration::DefaultWebClientState ShellIntegration::GetDefaultBrowser() {
+DefaultWebClientState GetDefaultBrowser() {
return GetDefaultWebClientStateFromShellUtilDefaultState(
ShellUtil::GetChromeDefaultState());
}
@@ -427,7 +423,7 @@ ShellIntegration::DefaultWebClientState ShellIntegration::GetDefaultBrowser() {
// locations and returns true if Firefox traces are found there. In case of
// error (or if Firefox is not found)it returns the default value which
// is false.
-bool ShellIntegration::IsFirefoxDefaultBrowser() {
+bool IsFirefoxDefaultBrowser() {
bool ff_default = false;
if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
base::string16 app_cmd;
@@ -449,16 +445,14 @@ bool ShellIntegration::IsFirefoxDefaultBrowser() {
return ff_default;
}
-ShellIntegration::DefaultWebClientState
- ShellIntegration::IsDefaultProtocolClient(const std::string& protocol) {
+DefaultWebClientState IsDefaultProtocolClient(const std::string& protocol) {
return GetDefaultWebClientStateFromShellUtilDefaultState(
ShellUtil::GetChromeDefaultProtocolClientState(
base::UTF8ToUTF16(protocol)));
}
-base::string16 ShellIntegration::GetAppModelIdForProfile(
- const base::string16& app_name,
- const base::FilePath& profile_path) {
+base::string16 GetAppModelIdForProfile(const base::string16& app_name,
+ const base::FilePath& profile_path) {
std::vector<base::string16> components;
components.push_back(app_name);
const base::string16 profile_id(GetProfileIdFromPath(profile_path));
@@ -467,7 +461,7 @@ base::string16 ShellIntegration::GetAppModelIdForProfile(
return ShellUtil::BuildAppModelId(components);
}
-base::string16 ShellIntegration::GetChromiumModelIdForProfile(
+base::string16 GetChromiumModelIdForProfile(
const base::FilePath& profile_path) {
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
base::FilePath chrome_exe;
@@ -481,12 +475,12 @@ base::string16 ShellIntegration::GetChromiumModelIdForProfile(
profile_path);
}
-base::string16 ShellIntegration::GetAppListAppModelIdForProfile(
+base::string16 GetAppListAppModelIdForProfile(
const base::FilePath& profile_path) {
return GetAppModelIdForProfile(GetAppListAppName(), profile_path);
}
-void ShellIntegration::MigrateTaskbarPins() {
+void MigrateTaskbarPins() {
if (base::win::GetVersion() < base::win::VERSION_WIN7)
return;
@@ -500,9 +494,8 @@ void ShellIntegration::MigrateTaskbarPins() {
base::TimeDelta::FromSeconds(kMigrateTaskbarPinsDelaySeconds));
}
-int ShellIntegration::MigrateShortcutsInPathInternal(
- const base::FilePath& chrome_exe,
- const base::FilePath& path) {
+int MigrateShortcutsInPathInternal(const base::FilePath& chrome_exe,
+ const base::FilePath& path) {
DCHECK(base::win::GetVersion() >= base::win::VERSION_WIN7);
// Enumerate all pinned shortcuts in the given path directly.
@@ -609,8 +602,7 @@ int ShellIntegration::MigrateShortcutsInPathInternal(
return shortcuts_migrated;
}
-base::FilePath ShellIntegration::GetStartMenuShortcut(
- const base::FilePath& chrome_exe) {
+base::FilePath GetStartMenuShortcut(const base::FilePath& chrome_exe) {
static const int kFolderIds[] = {
base::DIR_COMMON_START_MENU,
base::DIR_START_MENU,
@@ -639,7 +631,7 @@ base::FilePath ShellIntegration::GetStartMenuShortcut(
return base::FilePath();
}
-bool ShellIntegration::DefaultBrowserWorker::InitializeSetAsDefault() {
+bool DefaultBrowserWorker::InitializeSetAsDefault() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!IsSetAsDefaultAsynchronous())
@@ -687,7 +679,7 @@ bool ShellIntegration::DefaultBrowserWorker::InitializeSetAsDefault() {
return true;
}
-void ShellIntegration::DefaultBrowserWorker::FinalizeSetAsDefault() {
+void DefaultBrowserWorker::FinalizeSetAsDefault() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(set_as_default_initialized());
@@ -696,7 +688,7 @@ void ShellIntegration::DefaultBrowserWorker::FinalizeSetAsDefault() {
}
// static
-bool ShellIntegration::DefaultBrowserWorker::SetAsDefaultBrowserAsynchronous() {
+bool DefaultBrowserWorker::SetAsDefaultBrowserAsynchronous() {
DCHECK(IsSetAsDefaultAsynchronous());
// Registers chrome.exe as a browser on Windows to make sure it will be shown
@@ -711,3 +703,5 @@ bool ShellIntegration::DefaultBrowserWorker::SetAsDefaultBrowserAsynchronous() {
cmdline.AppendArgNative(StartupBrowserCreator::GetDefaultBrowserUrl());
return base::LaunchProcess(cmdline, base::LaunchOptions()).IsValid();
}
+
+} // namespace shell_integration
diff --git a/chrome/browser/shell_integration_win_unittest.cc b/chrome/browser/shell_integration_win_unittest.cc
index 0fc0975..3049449 100644
--- a/chrome/browser/shell_integration_win_unittest.cc
+++ b/chrome/browser/shell_integration_win_unittest.cc
@@ -27,6 +27,8 @@
#include "chrome/installer/util/util_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace shell_integration {
+
namespace {
struct ShortcutTestObject {
@@ -55,33 +57,25 @@ class ShellIntegrationWinMigrateShortcutTest : public testing::Test {
chrome::GetDefaultUserDataDirectory(&default_user_data_dir);
base::FilePath default_profile_path =
default_user_data_dir.AppendASCII(chrome::kInitialProfile);
- app_list_app_id_ =
- ShellIntegration::GetAppListAppModelIdForProfile(default_profile_path);
+ app_list_app_id_ = GetAppListAppModelIdForProfile(default_profile_path);
non_default_user_data_dir_ = base::FilePath(FILE_PATH_LITERAL("root"))
.Append(FILE_PATH_LITERAL("Non Default Data Dir"));
non_default_profile_ = L"NonDefault";
- non_default_profile_chrome_app_id_ =
- ShellIntegration::GetChromiumModelIdForProfile(
+ non_default_profile_chrome_app_id_ = GetChromiumModelIdForProfile(
default_user_data_dir.Append(non_default_profile_));
- non_default_user_data_dir_chrome_app_id_ =
- ShellIntegration::GetChromiumModelIdForProfile(
+ non_default_user_data_dir_chrome_app_id_ = GetChromiumModelIdForProfile(
non_default_user_data_dir_.AppendASCII(chrome::kInitialProfile));
non_default_user_data_dir_and_profile_chrome_app_id_ =
- ShellIntegration::GetChromiumModelIdForProfile(
- non_default_user_data_dir_.Append(non_default_profile_));
-
+ GetChromiumModelIdForProfile(
+ non_default_user_data_dir_.Append(non_default_profile_));
extension_id_ = L"chromiumexampleappidforunittests";
base::string16 app_name =
base::UTF8ToUTF16(web_app::GenerateApplicationNameFromExtensionId(
base::UTF16ToUTF8(extension_id_)));
- extension_app_id_ =
- ShellIntegration::GetAppModelIdForProfile(app_name,
- default_profile_path);
- non_default_profile_extension_app_id_ =
- ShellIntegration::GetAppModelIdForProfile(
- app_name,
- default_user_data_dir.Append(non_default_profile_));
+ extension_app_id_ = GetAppModelIdForProfile(app_name, default_profile_path);
+ non_default_profile_extension_app_id_ = GetAppModelIdForProfile(
+ app_name, default_user_data_dir.Append(non_default_profile_));
CreateShortcuts();
}
@@ -274,8 +268,7 @@ TEST_F(ShellIntegrationWinMigrateShortcutTest, ClearDualModeAndAdjustAppIds) {
// 9 shortcuts should have their app id updated below and shortcut 11 should
// be migrated away from dual_mode for a total of 10 shortcuts migrated.
- EXPECT_EQ(10, ShellIntegration::MigrateShortcutsInPathInternal(
- chrome_exe_, temp_dir_.path()));
+ EXPECT_EQ(10, MigrateShortcutsInPathInternal(chrome_exe_, temp_dir_.path()));
// Shortcut 1, 3, 4, 5, 6, 7, 8, 9, and 10 should have had their app_id fixed.
shortcuts_[1].properties.set_app_id(chrome_app_id_);
@@ -299,8 +292,7 @@ TEST_F(ShellIntegrationWinMigrateShortcutTest, ClearDualModeAndAdjustAppIds) {
}
// Make sure shortcuts are not re-migrated.
- EXPECT_EQ(0, ShellIntegration::MigrateShortcutsInPathInternal(
- chrome_exe_, temp_dir_.path()));
+ EXPECT_EQ(0, MigrateShortcutsInPathInternal(chrome_exe_, temp_dir_.path()));
}
TEST(ShellIntegrationWinTest, GetAppModelIdForProfileTest) {
@@ -309,8 +301,7 @@ TEST(ShellIntegrationWinTest, GetAppModelIdForProfileTest) {
// Empty profile path should get chrome::kBrowserAppID
base::FilePath empty_path;
- EXPECT_EQ(base_app_id,
- ShellIntegration::GetAppModelIdForProfile(base_app_id, empty_path));
+ EXPECT_EQ(base_app_id, GetAppModelIdForProfile(base_app_id, empty_path));
// Default profile path should get chrome::kBrowserAppID
base::FilePath default_user_data_dir;
@@ -318,8 +309,7 @@ TEST(ShellIntegrationWinTest, GetAppModelIdForProfileTest) {
base::FilePath default_profile_path =
default_user_data_dir.AppendASCII(chrome::kInitialProfile);
EXPECT_EQ(base_app_id,
- ShellIntegration::GetAppModelIdForProfile(base_app_id,
- default_profile_path));
+ GetAppModelIdForProfile(base_app_id, default_profile_path));
// Non-default profile path should get chrome::kBrowserAppID joined with
// profile info.
@@ -327,8 +317,7 @@ TEST(ShellIntegrationWinTest, GetAppModelIdForProfileTest) {
profile_path = profile_path.Append(FILE_PATH_LITERAL("udd"));
profile_path = profile_path.Append(FILE_PATH_LITERAL("User Data - Test"));
EXPECT_EQ(base_app_id + L".udd.UserDataTest",
- ShellIntegration::GetAppModelIdForProfile(base_app_id,
- profile_path));
+ GetAppModelIdForProfile(base_app_id, profile_path));
}
TEST(ShellIntegrationWinTest, GetAppListAppModelIdForProfileTest) {
@@ -338,17 +327,14 @@ TEST(ShellIntegrationWinTest, GetAppListAppModelIdForProfileTest) {
// Empty profile path should get chrome::kBrowserAppID + AppList
base::FilePath empty_path;
- EXPECT_EQ(base_app_id,
- ShellIntegration::GetAppListAppModelIdForProfile(empty_path));
+ EXPECT_EQ(base_app_id, GetAppListAppModelIdForProfile(empty_path));
// Default profile path should get chrome::kBrowserAppID + AppList
base::FilePath default_user_data_dir;
chrome::GetDefaultUserDataDirectory(&default_user_data_dir);
base::FilePath default_profile_path =
default_user_data_dir.AppendASCII(chrome::kInitialProfile);
- EXPECT_EQ(base_app_id,
- ShellIntegration::GetAppListAppModelIdForProfile(
- default_profile_path));
+ EXPECT_EQ(base_app_id, GetAppListAppModelIdForProfile(default_profile_path));
// Non-default profile path should get chrome::kBrowserAppID + AppList joined
// with profile info.
@@ -356,5 +342,7 @@ TEST(ShellIntegrationWinTest, GetAppListAppModelIdForProfileTest) {
profile_path = profile_path.Append(FILE_PATH_LITERAL("udd"));
profile_path = profile_path.Append(FILE_PATH_LITERAL("User Data - Test"));
EXPECT_EQ(base_app_id + L".udd.UserDataTest",
- ShellIntegration::GetAppListAppModelIdForProfile(profile_path));
+ GetAppListAppModelIdForProfile(profile_path));
}
+
+} // namespace shell_integration
diff --git a/chrome/browser/ui/apps/chrome_app_delegate.cc b/chrome/browser/ui/apps/chrome_app_delegate.cc
index 018119d..654c17b 100644
--- a/chrome/browser/ui/apps/chrome_app_delegate.cc
+++ b/chrome/browser/ui/apps/chrome_app_delegate.cc
@@ -82,7 +82,7 @@ content::WebContents* OpenURLFromTabInternal(
// default system browser. If it is the default, open the URL directly instead
// of asking the system to open it.
class OpenURLFromTabBasedOnBrowserDefault
- : public ShellIntegration::DefaultWebClientObserver {
+ : public shell_integration::DefaultWebClientObserver {
public:
OpenURLFromTabBasedOnBrowserDefault(scoped_ptr<content::WebContents> source,
const content::OpenURLParams& params)
@@ -91,20 +91,20 @@ class OpenURLFromTabBasedOnBrowserDefault
// Opens a URL when called with the result of if this is the default system
// browser or not.
void SetDefaultWebClientUIState(
- ShellIntegration::DefaultWebClientUIState state) override {
+ shell_integration::DefaultWebClientUIState state) override {
Profile* profile =
Profile::FromBrowserContext(source_->GetBrowserContext());
DCHECK(profile);
if (!profile)
return;
switch (state) {
- case ShellIntegration::STATE_PROCESSING:
+ case shell_integration::STATE_PROCESSING:
break;
- case ShellIntegration::STATE_IS_DEFAULT:
+ case shell_integration::STATE_IS_DEFAULT:
OpenURLFromTabInternal(profile, params_);
break;
- case ShellIntegration::STATE_NOT_DEFAULT:
- case ShellIntegration::STATE_UNKNOWN:
+ case shell_integration::STATE_NOT_DEFAULT:
+ case shell_integration::STATE_UNKNOWN:
platform_util::OpenExternal(profile, params_.url);
break;
}
@@ -154,9 +154,9 @@ ChromeAppDelegate::NewWindowContentsDelegate::OpenURLFromTab(
// NewWindowContentsDelegate actually sees the WebContents.
// Here it is captured for deletion.
scoped_ptr<content::WebContents> owned_source(source);
- scoped_refptr<ShellIntegration::DefaultWebClientWorker>
+ scoped_refptr<shell_integration::DefaultWebClientWorker>
check_if_default_browser_worker =
- new ShellIntegration::DefaultBrowserWorker(
+ new shell_integration::DefaultBrowserWorker(
new OpenURLFromTabBasedOnBrowserDefault(std::move(owned_source),
params));
// Object lifetime notes: The OpenURLFromTabBasedOnBrowserDefault is owned
diff --git a/chrome/browser/ui/cocoa/external_protocol_dialog.mm b/chrome/browser/ui/cocoa/external_protocol_dialog.mm
index 007259f..a3a7e94 100644
--- a/chrome/browser/ui/cocoa/external_protocol_dialog.mm
+++ b/chrome/browser/ui/cocoa/external_protocol_dialog.mm
@@ -51,7 +51,7 @@ void ExternalProtocolHandler::RunExternalProtocolDialog(
creation_time_ = base::Time::Now();
base::string16 appName =
- ShellIntegration::GetApplicationNameForProtocol(url_);
+ shell_integration::GetApplicationNameForProtocol(url_);
if (appName.length() == 0) {
// No registered apps for this protocol; give up and go home.
[self autorelease];
diff --git a/chrome/browser/ui/cocoa/first_run_dialog.mm b/chrome/browser/ui/cocoa/first_run_dialog.mm
index 2da7756..1979bdd 100644
--- a/chrome/browser/ui/cocoa/first_run_dialog.mm
+++ b/chrome/browser/ui/cocoa/first_run_dialog.mm
@@ -91,7 +91,7 @@ bool ShowFirstRun(Profile* profile) {
// If selected set as default browser.
BOOL make_default_browser = [dialog.get() makeDefaultBrowser];
if (make_default_browser) {
- bool success = ShellIntegration::SetAsDefaultBrowser();
+ bool success = shell_integration::SetAsDefaultBrowser();
DCHECK(success);
}
}
@@ -139,8 +139,8 @@ bool ShowFirstRunDialog(Profile* profile) {
ofType:@"nib"];
if ((self = [super initWithWindowNibPath:nibpath owner:self])) {
// Bound to the dialog checkboxes.
- makeDefaultBrowser_ = ShellIntegration::CanSetAsDefaultBrowser() !=
- ShellIntegration::SET_DEFAULT_NOT_ALLOWED;
+ makeDefaultBrowser_ = shell_integration::CanSetAsDefaultBrowser() !=
+ shell_integration::SET_DEFAULT_NOT_ALLOWED;
statsEnabled_ = StatsCheckboxDefault();
}
return self;
@@ -164,7 +164,7 @@ bool ShowFirstRunDialog(Profile* profile) {
- (void)show {
NSWindow* win = [self window];
- if (!ShellIntegration::CanSetAsDefaultBrowser()) {
+ if (!shell_integration::CanSetAsDefaultBrowser()) {
[setAsDefaultCheckbox_ setHidden:YES];
}
diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc
index d4fbcd2..a858f2b 100644
--- a/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc
+++ b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc
@@ -876,8 +876,8 @@ class FakeDelegate : public ProtocolHandlerRegistry::Delegate {
// side effects on other tests.
}
- ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker(
- ShellIntegration::DefaultWebClientObserver* observer,
+ shell_integration::DefaultProtocolClientWorker* CreateShellWorker(
+ shell_integration::DefaultWebClientObserver* observer,
const std::string& protocol) override {
VLOG(1) << "CreateShellWorker";
return NULL;
diff --git a/chrome/browser/ui/external_protocol_dialog_delegate.cc b/chrome/browser/ui/external_protocol_dialog_delegate.cc
index 371117c..104e164 100644
--- a/chrome/browser/ui/external_protocol_dialog_delegate.cc
+++ b/chrome/browser/ui/external_protocol_dialog_delegate.cc
@@ -22,8 +22,7 @@ ExternalProtocolDialogDelegate::ExternalProtocolDialogDelegate(
: ProtocolDialogDelegate(url),
render_process_host_id_(render_process_host_id),
tab_contents_id_(tab_contents_id),
- program_name_(ShellIntegration::GetApplicationNameForProtocol(url)) {
-}
+ program_name_(shell_integration::GetApplicationNameForProtocol(url)) {}
ExternalProtocolDialogDelegate::~ExternalProtocolDialogDelegate() {
}
diff --git a/chrome/browser/ui/startup/default_browser_prompt.cc b/chrome/browser/ui/startup/default_browser_prompt.cc
index 2357af0..09d3cef 100644
--- a/chrome/browser/ui/startup/default_browser_prompt.cc
+++ b/chrome/browser/ui/startup/default_browser_prompt.cc
@@ -166,7 +166,7 @@ base::string16 DefaultBrowserInfoBarDelegate::GetButtonLabel(
// it does require registering it as the protocol handler for "http", so if
// protocol registration in general requires elevation, this does as well.
bool DefaultBrowserInfoBarDelegate::OKButtonTriggersUACPrompt() const {
- return ShellIntegration::IsElevationNeededForSettingDefaultProtocolClient();
+ return shell_integration::IsElevationNeededForSettingDefaultProtocolClient();
}
bool DefaultBrowserInfoBarDelegate::Accept() {
@@ -176,8 +176,8 @@ bool DefaultBrowserInfoBarDelegate::Accept() {
UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction",
InfoBarUserInteraction::START_SET_AS_DEFAULT,
NUM_INFO_BAR_USER_INTERACTION_TYPES);
- scoped_refptr<ShellIntegration::DefaultBrowserWorker>(
- new ShellIntegration::DefaultBrowserWorker(nullptr))
+ scoped_refptr<shell_integration::DefaultBrowserWorker>(
+ new shell_integration::DefaultBrowserWorker(nullptr))
->StartSetAsDefault();
return true;
}
@@ -194,12 +194,12 @@ bool DefaultBrowserInfoBarDelegate::Cancel() {
return true;
}
-// A ShellIntegration::DefaultWebClientObserver that handles the check to
+// A shell_integration::DefaultWebClientObserver that handles the check to
// determine whether or not to show the default browser prompt. If Chrome is the
// default browser, then the kCheckDefaultBrowser pref is reset. Otherwise, the
// prompt is shown.
class CheckDefaultBrowserObserver
- : public ShellIntegration::DefaultWebClientObserver {
+ : public shell_integration::DefaultWebClientObserver {
public:
CheckDefaultBrowserObserver(const base::FilePath& profile_path,
bool show_prompt,
@@ -208,7 +208,7 @@ class CheckDefaultBrowserObserver
private:
void SetDefaultWebClientUIState(
- ShellIntegration::DefaultWebClientUIState state) override;
+ shell_integration::DefaultWebClientUIState state) override;
bool IsOwnedByWorker() override;
void ResetCheckDefaultBrowserPref();
@@ -235,14 +235,14 @@ CheckDefaultBrowserObserver::CheckDefaultBrowserObserver(
CheckDefaultBrowserObserver::~CheckDefaultBrowserObserver() {}
void CheckDefaultBrowserObserver::SetDefaultWebClientUIState(
- ShellIntegration::DefaultWebClientUIState state) {
- if (state == ShellIntegration::STATE_IS_DEFAULT) {
+ shell_integration::DefaultWebClientUIState state) {
+ if (state == shell_integration::STATE_IS_DEFAULT) {
// Notify the user in the future if Chrome ceases to be the user's chosen
// default browser.
ResetCheckDefaultBrowserPref();
- } else if (show_prompt_ && state == ShellIntegration::STATE_NOT_DEFAULT &&
- ShellIntegration::CanSetAsDefaultBrowser() !=
- ShellIntegration::SET_DEFAULT_NOT_ALLOWED) {
+ } else if (show_prompt_ && state == shell_integration::STATE_NOT_DEFAULT &&
+ shell_integration::CanSetAsDefaultBrowser() !=
+ shell_integration::SET_DEFAULT_NOT_ALLOWED) {
ShowPrompt();
}
}
@@ -320,8 +320,8 @@ void ShowDefaultBrowserPrompt(Profile* profile, HostDesktopType desktop_type) {
}
}
- scoped_refptr<ShellIntegration::DefaultBrowserWorker>(
- new ShellIntegration::DefaultBrowserWorker(
+ scoped_refptr<shell_integration::DefaultBrowserWorker>(
+ new shell_integration::DefaultBrowserWorker(
new CheckDefaultBrowserObserver(profile->GetPath(), show_prompt,
desktop_type)))
->StartCheckIsDefault();
diff --git a/chrome/browser/ui/startup/default_browser_prompt_win.cc b/chrome/browser/ui/startup/default_browser_prompt_win.cc
index e1a4d67..0bd2ba2 100644
--- a/chrome/browser/ui/startup/default_browser_prompt_win.cc
+++ b/chrome/browser/ui/startup/default_browser_prompt_win.cc
@@ -80,10 +80,10 @@ bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) {
// If the only available mode of setting the default browser requires
// user interaction, it means this couldn't have been done yet. Therefore,
// we launch the dialog and inform the caller of it.
- bool show_status =
- (ShellIntegration::CanSetAsDefaultBrowser() ==
- ShellIntegration::SET_DEFAULT_INTERACTIVE) &&
- (ShellIntegration::GetDefaultBrowser() == ShellIntegration::NOT_DEFAULT);
+ bool show_status = (shell_integration::CanSetAsDefaultBrowser() ==
+ shell_integration::SET_DEFAULT_INTERACTIVE) &&
+ (shell_integration::GetDefaultBrowser() ==
+ shell_integration::NOT_DEFAULT);
if (show_status) {
startup_metric_utils::SetNonBrowserUIDisplayed();
diff --git a/chrome/browser/ui/startup/startup_browser_creator_impl.cc b/chrome/browser/ui/startup/startup_browser_creator_impl.cc
index c648526..a1f7882 100644
--- a/chrome/browser/ui/startup/startup_browser_creator_impl.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator_impl.cc
@@ -390,7 +390,7 @@ bool StartupBrowserCreatorImpl::Launch(Profile* profile,
// Active Setup versioning and on OS upgrades) instead of every startup.
// http://crbug.com/577697
if (process_startup)
- ShellIntegration::MigrateTaskbarPins();
+ shell_integration::MigrateTaskbarPins();
#endif // defined(OS_WIN)
return true;
@@ -987,7 +987,7 @@ void StartupBrowserCreatorImpl::InitializeWelcomeRunType(
// Do not welcome if Chrome was the default browser at startup.
if (g_browser_process->CachedDefaultWebClientState() ==
- ShellIntegration::IS_DEFAULT) {
+ shell_integration::IS_DEFAULT) {
return;
}
diff --git a/chrome/browser/ui/views/app_list/win/app_list_service_win.cc b/chrome/browser/ui/views/app_list/win/app_list_service_win.cc
index 2891b288..db294f7 100644
--- a/chrome/browser/ui/views/app_list/win/app_list_service_win.cc
+++ b/chrome/browser/ui/views/app_list/win/app_list_service_win.cc
@@ -119,7 +119,8 @@ base::string16 GetAppModelId() {
command_line->GetSwitchValuePath(switches::kUserDataDir).AppendASCII(
chrome::kInitialProfile);
}
- return ShellIntegration::GetAppListAppModelIdForProfile(initial_profile_path);
+ return shell_integration::GetAppListAppModelIdForProfile(
+ initial_profile_path);
}
#if defined(GOOGLE_CHROME_BUILD)
@@ -155,7 +156,7 @@ void SetDidRunForNDayActiveStats() {
// |app_model_id|. This runs on the FILE thread and not in the blocking IO
// thread pool as there are other tasks running (also on the FILE thread)
// which fiddle with shortcut icons
-// (ShellIntegration::MigrateWin7ShortcutsOnPath). Having different threads
+// (shell_integration::MigrateWin7ShortcutsOnPath). Having different threads
// fiddle with the same shortcuts could cause race issues.
void CreateAppListShortcuts(
const base::FilePath& user_data_dir,
diff --git a/chrome/browser/ui/views/apps/chrome_native_app_window_views_win.cc b/chrome/browser/ui/views/apps/chrome_native_app_window_views_win.cc
index e9aa438..2f59274 100644
--- a/chrome/browser/ui/views/apps/chrome_native_app_window_views_win.cc
+++ b/chrome/browser/ui/views/apps/chrome_native_app_window_views_win.cc
@@ -98,9 +98,8 @@ void ChromeNativeAppWindowViewsWin::InitializeDefaultWindow(
HWND hwnd = GetNativeAppWindowHWND();
Profile* profile =
Profile::FromBrowserContext(app_window()->browser_context());
- app_model_id_ =
- ShellIntegration::GetAppModelIdForProfile(app_name_wide,
- profile->GetPath());
+ app_model_id_ = shell_integration::GetAppModelIdForProfile(
+ app_name_wide, profile->GetPath());
ui::win::SetAppIdForWindow(app_model_id_, hwnd);
web_app::UpdateRelaunchDetailsForApp(profile, extension, hwnd);
diff --git a/chrome/browser/ui/views/first_run_dialog.cc b/chrome/browser/ui/views/first_run_dialog.cc
index 64443cb..32050fe 100644
--- a/chrome/browser/ui/views/first_run_dialog.cc
+++ b/chrome/browser/ui/views/first_run_dialog.cc
@@ -127,7 +127,7 @@ bool FirstRunDialog::Accept() {
}
if (make_default_ && make_default_->checked())
- ShellIntegration::SetAsDefaultBrowser();
+ shell_integration::SetAsDefaultBrowser();
Done();
return true;
diff --git a/chrome/browser/ui/views/frame/browser_window_property_manager_win.cc b/chrome/browser/ui/views/frame/browser_window_property_manager_win.cc
index 58b0003..42f7804 100644
--- a/chrome/browser/ui/views/frame/browser_window_property_manager_win.cc
+++ b/chrome/browser/ui/views/frame/browser_window_property_manager_win.cc
@@ -50,11 +50,11 @@ void BrowserWindowPropertyManager::UpdateWindowProperties() {
// Set the app user model id for this application to that of the application
// name. See http://crbug.com/7028.
- base::string16 app_id = browser->is_app() ?
- ShellIntegration::GetAppModelIdForProfile(
- base::UTF8ToWide(browser->app_name()),
- profile->GetPath()) :
- ShellIntegration::GetChromiumModelIdForProfile(profile->GetPath());
+ base::string16 app_id =
+ browser->is_app()
+ ? shell_integration::GetAppModelIdForProfile(
+ base::UTF8ToWide(browser->app_name()), profile->GetPath())
+ : shell_integration::GetChromiumModelIdForProfile(profile->GetPath());
base::string16 icon_path_string;
base::string16 command_line_string;
base::string16 pinned_name;
diff --git a/chrome/browser/ui/views/hung_renderer_view.cc b/chrome/browser/ui/views/hung_renderer_view.cc
index 1b47948..d54d165 100644
--- a/chrome/browser/ui/views/hung_renderer_view.cc
+++ b/chrome/browser/ui/views/hung_renderer_view.cc
@@ -278,7 +278,7 @@ void HungRendererDialogView::ShowForWebContents(WebContents* contents) {
Profile* profile =
Profile::FromBrowserContext(contents->GetBrowserContext());
ui::win::SetAppIdForWindow(
- ShellIntegration::GetChromiumModelIdForProfile(profile->GetPath()),
+ shell_integration::GetChromiumModelIdForProfile(profile->GetPath()),
views::HWNDForWidget(GetWidget()));
#endif
diff --git a/chrome/browser/ui/views/new_task_manager_view.cc b/chrome/browser/ui/views/new_task_manager_view.cc
index e74af06..8d4e19e 100644
--- a/chrome/browser/ui/views/new_task_manager_view.cc
+++ b/chrome/browser/ui/views/new_task_manager_view.cc
@@ -106,7 +106,7 @@ void NewTaskManagerView::Show(Browser* browser) {
// process.
if (browser) {
ui::win::SetAppIdForWindow(
- ShellIntegration::GetChromiumModelIdForProfile(
+ shell_integration::GetChromiumModelIdForProfile(
browser->profile()->GetPath()),
views::HWNDForWidget(g_task_manager_view->GetWidget()));
}
diff --git a/chrome/browser/ui/views/panels/panel_stack_view.cc b/chrome/browser/ui/views/panels/panel_stack_view.cc
index 67c40d1..0c88244 100644
--- a/chrome/browser/ui/views/panels/panel_stack_view.cc
+++ b/chrome/browser/ui/views/panels/panel_stack_view.cc
@@ -505,7 +505,7 @@ views::Widget* PanelStackView::CreateWindowWithBounds(const gfx::Rect& bounds) {
DCHECK(!panels_.empty());
Panel* panel = panels_.front();
ui::win::SetAppIdForWindow(
- ShellIntegration::GetAppModelIdForProfile(
+ shell_integration::GetAppModelIdForProfile(
base::UTF8ToWide(panel->app_name()), panel->profile()->GetPath()),
views::HWNDForWidget(window));
diff --git a/chrome/browser/ui/views/panels/panel_view.cc b/chrome/browser/ui/views/panels/panel_view.cc
index 78bf7d8..9775a2d 100644
--- a/chrome/browser/ui/views/panels/panel_view.cc
+++ b/chrome/browser/ui/views/panels/panel_view.cc
@@ -319,7 +319,7 @@ PanelView::PanelView(Panel* panel, const gfx::Rect& bounds, bool always_on_top)
#if defined(OS_WIN)
ui::win::SetAppIdForWindow(
- ShellIntegration::GetAppModelIdForProfile(
+ shell_integration::GetAppModelIdForProfile(
base::UTF8ToWide(panel->app_name()), panel->profile()->GetPath()),
views::HWNDForWidget(window_));
ui::win::PreventWindowFromPinning(views::HWNDForWidget(window_));
diff --git a/chrome/browser/ui/views/profiles/user_manager_view.cc b/chrome/browser/ui/views/profiles/user_manager_view.cc
index cd9ce66..87d56b9 100644
--- a/chrome/browser/ui/views/profiles/user_manager_view.cc
+++ b/chrome/browser/ui/views/profiles/user_manager_view.cc
@@ -308,10 +308,9 @@ void UserManagerView::Init(Profile* system_profile, const GURL& url) {
#if defined(OS_WIN)
// Set the app id for the task manager to the app id of its parent
- ui::win::SetAppIdForWindow(
- ShellIntegration::GetChromiumModelIdForProfile(
- system_profile->GetPath()),
- views::HWNDForWidget(GetWidget()));
+ ui::win::SetAppIdForWindow(shell_integration::GetChromiumModelIdForProfile(
+ system_profile->GetPath()),
+ views::HWNDForWidget(GetWidget()));
#endif
#if defined(USE_ASH)
diff --git a/chrome/browser/ui/views/task_manager_view.cc b/chrome/browser/ui/views/task_manager_view.cc
index eb0e3c8..9dbc0fd 100644
--- a/chrome/browser/ui/views/task_manager_view.cc
+++ b/chrome/browser/ui/views/task_manager_view.cc
@@ -476,10 +476,9 @@ void TaskManagerView::Show(Browser* browser) {
// no parent is specified, the app id will default to that of the initial
// process.
if (browser) {
- ui::win::SetAppIdForWindow(
- ShellIntegration::GetChromiumModelIdForProfile(
- browser->profile()->GetPath()),
- views::HWNDForWidget(instance_->GetWidget()));
+ ui::win::SetAppIdForWindow(shell_integration::GetChromiumModelIdForProfile(
+ browser->profile()->GetPath()),
+ views::HWNDForWidget(instance_->GetWidget()));
}
#endif
instance_->GetWidget()->Show();
diff --git a/chrome/browser/ui/views/uninstall_view.cc b/chrome/browser/ui/views/uninstall_view.cc
index 5c2bd6a..313cdaf 100644
--- a/chrome/browser/ui/views/uninstall_view.cc
+++ b/chrome/browser/ui/views/uninstall_view.cc
@@ -79,11 +79,11 @@ void UninstallView::SetupControls() {
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
if (dist->GetDefaultBrowserControlPolicy() !=
BrowserDistribution::DEFAULT_BROWSER_UNSUPPORTED &&
- ShellIntegration::GetDefaultBrowser() == ShellIntegration::IS_DEFAULT &&
- (ShellIntegration::CanSetAsDefaultBrowser() ==
- ShellIntegration::SET_DEFAULT_NOT_ALLOWED ||
- ShellIntegration::CanSetAsDefaultBrowser() ==
- ShellIntegration::SET_DEFAULT_UNATTENDED)) {
+ shell_integration::GetDefaultBrowser() == shell_integration::IS_DEFAULT &&
+ (shell_integration::CanSetAsDefaultBrowser() ==
+ shell_integration::SET_DEFAULT_NOT_ALLOWED ||
+ shell_integration::CanSetAsDefaultBrowser() ==
+ shell_integration::SET_DEFAULT_UNATTENDED)) {
browsers_.reset(new BrowsersMap());
ShellUtil::GetRegisteredBrowsers(dist, browsers_.get());
if (!browsers_->empty()) {
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc
index 70df967..ea2eb76 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.cc
+++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
@@ -186,7 +186,7 @@ BrowserOptionsHandler::BrowserOptionsHandler()
#endif // defined(OS_CHROMEOS)
signin_observer_(this),
weak_ptr_factory_(this) {
- default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this);
+ default_browser_worker_ = new shell_integration::DefaultBrowserWorker(this);
#if defined(ENABLE_SERVICE_DISCOVERY)
cloud_print_mdns_ui_enabled_ = true;
@@ -1110,32 +1110,32 @@ void BrowserOptionsHandler::BecomeDefaultBrowser(const base::ListValue* args) {
}
int BrowserOptionsHandler::StatusStringIdForState(
- ShellIntegration::DefaultWebClientState state) {
- if (state == ShellIntegration::IS_DEFAULT)
+ shell_integration::DefaultWebClientState state) {
+ if (state == shell_integration::IS_DEFAULT)
return IDS_OPTIONS_DEFAULTBROWSER_DEFAULT;
- if (state == ShellIntegration::NOT_DEFAULT)
+ if (state == shell_integration::NOT_DEFAULT)
return IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT;
return IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN;
}
void BrowserOptionsHandler::SetDefaultWebClientUIState(
- ShellIntegration::DefaultWebClientUIState state) {
+ shell_integration::DefaultWebClientUIState state) {
int status_string_id;
- if (state == ShellIntegration::STATE_IS_DEFAULT) {
+ if (state == shell_integration::STATE_IS_DEFAULT) {
status_string_id = IDS_OPTIONS_DEFAULTBROWSER_DEFAULT;
// Notify the user in the future if Chrome ceases to be the user's chosen
// default browser.
PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
prefs->SetBoolean(prefs::kCheckDefaultBrowser, true);
- } else if (state == ShellIntegration::STATE_NOT_DEFAULT) {
- if (ShellIntegration::CanSetAsDefaultBrowser() ==
- ShellIntegration::SET_DEFAULT_NOT_ALLOWED) {
+ } else if (state == shell_integration::STATE_NOT_DEFAULT) {
+ if (shell_integration::CanSetAsDefaultBrowser() ==
+ shell_integration::SET_DEFAULT_NOT_ALLOWED) {
status_string_id = IDS_OPTIONS_DEFAULTBROWSER_SXS;
} else {
status_string_id = IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT;
}
- } else if (state == ShellIntegration::STATE_UNKNOWN) {
+ } else if (state == shell_integration::STATE_UNKNOWN) {
status_string_id = IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN;
} else {
return; // Still processing.
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.h b/chrome/browser/ui/webui/options/browser_options_handler.h
index 7da9ff2..1b8eebd 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.h
+++ b/chrome/browser/ui/webui/options/browser_options_handler.h
@@ -60,7 +60,7 @@ class BrowserOptionsHandler
public sync_driver::SyncServiceObserver,
public SigninManagerBase::Observer,
public ui::SelectFileDialog::Listener,
- public ShellIntegration::DefaultWebClientObserver,
+ public shell_integration::DefaultWebClientObserver,
#if defined(OS_CHROMEOS)
public chromeos::system::PointerDeviceObserver::Observer,
public policy::ConsumerManagementService::Observer,
@@ -91,9 +91,9 @@ class BrowserOptionsHandler
void GoogleSignedOut(const std::string& account_id,
const std::string& username) override;
- // ShellIntegration::DefaultWebClientObserver implementation.
+ // shell_integration::DefaultWebClientObserver implementation.
void SetDefaultWebClientUIState(
- ShellIntegration::DefaultWebClientUIState state) override;
+ shell_integration::DefaultWebClientUIState state) override;
bool IsInteractiveSetDefaultPermitted() override;
// TemplateURLServiceObserver implementation.
@@ -166,7 +166,7 @@ class BrowserOptionsHandler
void SetDefaultSearchEngine(const base::ListValue* args);
// Returns the string ID for the given default browser state.
- int StatusStringIdForState(ShellIntegration::DefaultWebClientState state);
+ int StatusStringIdForState(shell_integration::DefaultWebClientState state);
// Returns if the "make Chrome default browser" button should be shown.
bool ShouldShowSetDefaultBrowser();
@@ -380,7 +380,8 @@ class BrowserOptionsHandler
// true on other platforms.
bool IsDeviceOwnerProfile();
- scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_;
+ scoped_refptr<shell_integration::DefaultBrowserWorker>
+ default_browser_worker_;
bool page_initialized_;
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 eac291a..55fed3b 100644
--- a/chrome/browser/ui/webui/set_as_default_browser_ui.cc
+++ b/chrome/browser/ui/webui/set_as_default_browser_ui.cc
@@ -96,7 +96,7 @@ class ResponseDelegate {
class SetAsDefaultBrowserHandler
: public WebUIMessageHandler,
public base::SupportsWeakPtr<SetAsDefaultBrowserHandler>,
- public ShellIntegration::DefaultWebClientObserver {
+ public shell_integration::DefaultWebClientObserver {
public:
explicit SetAsDefaultBrowserHandler(
const base::WeakPtr<ResponseDelegate>& response_delegate);
@@ -105,9 +105,9 @@ class SetAsDefaultBrowserHandler
// WebUIMessageHandler implementation.
void RegisterMessages() override;
- // ShellIntegration::DefaultWebClientObserver implementation.
+ // shell_integration::DefaultWebClientObserver implementation.
void SetDefaultWebClientUIState(
- ShellIntegration::DefaultWebClientUIState state) override;
+ shell_integration::DefaultWebClientUIState state) override;
void OnSetAsDefaultConcluded(bool close_chrome) override;
bool IsInteractiveSetDefaultPermitted() override;
@@ -118,7 +118,8 @@ class SetAsDefaultBrowserHandler
// Close this web ui.
void ConcludeInteraction(MakeChromeDefaultResult interaction_result);
- scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_;
+ scoped_refptr<shell_integration::DefaultBrowserWorker>
+ default_browser_worker_;
bool set_default_returned_;
bool set_default_result_;
base::WeakPtr<ResponseDelegate> response_delegate_;
@@ -128,10 +129,11 @@ class SetAsDefaultBrowserHandler
SetAsDefaultBrowserHandler::SetAsDefaultBrowserHandler(
const base::WeakPtr<ResponseDelegate>& response_delegate)
- : default_browser_worker_(new ShellIntegration::DefaultBrowserWorker(this)),
- set_default_returned_(false), set_default_result_(false),
- response_delegate_(response_delegate) {
-}
+ : default_browser_worker_(
+ new shell_integration::DefaultBrowserWorker(this)),
+ set_default_returned_(false),
+ set_default_result_(false),
+ response_delegate_(response_delegate) {}
SetAsDefaultBrowserHandler::~SetAsDefaultBrowserHandler() {
default_browser_worker_->ObserverDestroyed();
@@ -145,18 +147,18 @@ void SetAsDefaultBrowserHandler::RegisterMessages() {
}
void SetAsDefaultBrowserHandler::SetDefaultWebClientUIState(
- ShellIntegration::DefaultWebClientUIState state) {
+ shell_integration::DefaultWebClientUIState state) {
// The callback is expected to be invoked once the procedure has completed.
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!set_default_returned_)
return;
- if (state == ShellIntegration::STATE_NOT_DEFAULT && set_default_result_) {
+ if (state == shell_integration::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.
ConcludeInteraction(MAKE_CHROME_DEFAULT_REGRETTED);
- } else if (state == ShellIntegration::STATE_IS_DEFAULT) {
+ } else if (state == shell_integration::STATE_IS_DEFAULT) {
ConcludeInteraction(MAKE_CHROME_DEFAULT_ACCEPTED);
}
diff --git a/chrome/browser/ui/webui/settings/settings_default_browser_handler.cc b/chrome/browser/ui/webui/settings/settings_default_browser_handler.cc
index 787a112..c976f61 100644
--- a/chrome/browser/ui/webui/settings/settings_default_browser_handler.cc
+++ b/chrome/browser/ui/webui/settings/settings_default_browser_handler.cc
@@ -14,7 +14,7 @@ namespace settings {
DefaultBrowserHandler::DefaultBrowserHandler(content::WebUI* webui)
: default_browser_worker_(
- new ShellIntegration::DefaultBrowserWorker(this)) {
+ new shell_integration::DefaultBrowserWorker(this)) {
default_browser_policy_.Init(
prefs::kDefaultBrowserSettingEnabled, g_browser_process->local_state(),
base::Bind(&DefaultBrowserHandler::RequestDefaultBrowserState,
@@ -37,24 +37,24 @@ void DefaultBrowserHandler::RegisterMessages() {
}
void DefaultBrowserHandler::SetDefaultWebClientUIState(
- ShellIntegration::DefaultWebClientUIState state) {
- if (state == ShellIntegration::STATE_PROCESSING)
+ shell_integration::DefaultWebClientUIState state) {
+ if (state == shell_integration::STATE_PROCESSING)
return;
- if (state == ShellIntegration::STATE_IS_DEFAULT) {
+ if (state == shell_integration::STATE_IS_DEFAULT) {
// Notify the user in the future if Chrome ceases to be the user's chosen
// default browser.
Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean(
prefs::kCheckDefaultBrowser, true);
}
- base::FundamentalValue is_default(
- state == ShellIntegration::STATE_IS_DEFAULT);
+ base::FundamentalValue is_default(state ==
+ shell_integration::STATE_IS_DEFAULT);
base::FundamentalValue can_be_default(
- state != ShellIntegration::STATE_UNKNOWN &&
+ state != shell_integration::STATE_UNKNOWN &&
!default_browser_policy_.IsManaged() &&
- ShellIntegration::CanSetAsDefaultBrowser() !=
- ShellIntegration::SET_DEFAULT_NOT_ALLOWED);
+ shell_integration::CanSetAsDefaultBrowser() !=
+ shell_integration::SET_DEFAULT_NOT_ALLOWED);
web_ui()->CallJavascriptFunction("Settings.updateDefaultBrowserState",
is_default, can_be_default);
diff --git a/chrome/browser/ui/webui/settings/settings_default_browser_handler.h b/chrome/browser/ui/webui/settings/settings_default_browser_handler.h
index 57354db..e7b8a2d 100644
--- a/chrome/browser/ui/webui/settings/settings_default_browser_handler.h
+++ b/chrome/browser/ui/webui/settings/settings_default_browser_handler.h
@@ -26,7 +26,7 @@ namespace settings {
// settings code to change the default browser settings.
class DefaultBrowserHandler
: public SettingsPageUIHandler,
- public ShellIntegration::DefaultWebClientObserver {
+ public shell_integration::DefaultWebClientObserver {
public:
explicit DefaultBrowserHandler(content::WebUI* webui);
~DefaultBrowserHandler() override;
@@ -34,9 +34,9 @@ class DefaultBrowserHandler
// SettingsPageUIHandler implementation.
void RegisterMessages() override;
- // ShellIntegration::DefaultWebClientObserver implementation.
+ // shell_integration::DefaultWebClientObserver implementation.
void SetDefaultWebClientUIState(
- ShellIntegration::DefaultWebClientUIState state) override;
+ shell_integration::DefaultWebClientUIState state) override;
bool IsInteractiveSetDefaultPermitted() override;
void OnSetAsDefaultConcluded(bool succeeded) override;
@@ -48,7 +48,8 @@ class DefaultBrowserHandler
void SetAsDefaultBrowser(const base::ListValue* args);
// Reference to a background worker that handles default browser settings.
- scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_;
+ scoped_refptr<shell_integration::DefaultBrowserWorker>
+ default_browser_worker_;
// Policy setting to determine if default browser setting is managed.
BooleanPrefMember default_browser_policy_;
diff --git a/chrome/browser/web_applications/update_shortcut_worker_win.cc b/chrome/browser/web_applications/update_shortcut_worker_win.cc
index 6306e83..c2bcdd2 100644
--- a/chrome/browser/web_applications/update_shortcut_worker_win.cc
+++ b/chrome/browser/web_applications/update_shortcut_worker_win.cc
@@ -204,7 +204,7 @@ void UpdateShortcutWorker::UpdateShortcutsOnFileThread() {
CheckExistingShortcuts();
if (!shortcut_files_.empty()) {
// Generates app id from web app url and profile path.
- base::string16 app_id = ShellIntegration::GetAppModelIdForProfile(
+ base::string16 app_id = shell_integration::GetAppModelIdForProfile(
base::UTF8ToWide(
web_app::GenerateApplicationNameFromURL(shortcut_info_->url)),
profile_path_);
diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm
index e8de95e..4951d392 100644
--- a/chrome/browser/web_applications/web_app_mac.mm
+++ b/chrome/browser/web_applications/web_app_mac.mm
@@ -435,7 +435,8 @@ void UpdateAppShortcutsSubdirLocalizedName(
return;
base::FilePath directory_name = apps_directory.BaseName().RemoveExtension();
- base::string16 localized_name = ShellIntegration::GetAppShortcutsSubdirName();
+ base::string16 localized_name =
+ shell_integration::GetAppShortcutsSubdirName();
NSDictionary* strings_dict = @{
base::mac::FilePathToNSString(directory_name) :
base::SysUTF16ToNSString(localized_name)
diff --git a/chrome/browser/web_applications/web_app_win.cc b/chrome/browser/web_applications/web_app_win.cc
index 7ed731b..42c70c7 100644
--- a/chrome/browser/web_applications/web_app_win.cc
+++ b/chrome/browser/web_applications/web_app_win.cc
@@ -196,8 +196,9 @@ bool CreateShortcutsInPaths(
base::FilePath working_dir(chrome_exe.DirName());
base::CommandLine cmd_line(base::CommandLine::NO_PROGRAM);
- cmd_line = ShellIntegration::CommandLineArgsForLauncher(shortcut_info.url,
- shortcut_info.extension_id, shortcut_info.profile_path);
+ cmd_line = shell_integration::CommandLineArgsForLauncher(
+ shortcut_info.url, shortcut_info.extension_id,
+ shortcut_info.profile_path);
// TODO(evan): we rely on the fact that command_line_string() is
// properly quoted for a Windows command line. The method on
@@ -212,7 +213,7 @@ bool CreateShortcutsInPaths(
// Generates app id from web app url and profile path.
std::string app_name(web_app::GenerateApplicationNameFromInfo(shortcut_info));
- base::string16 app_id(ShellIntegration::GetAppModelIdForProfile(
+ base::string16 app_id(shell_integration::GetAppModelIdForProfile(
base::UTF8ToUTF16(app_name), shortcut_info.profile_path));
bool success = true;
@@ -339,9 +340,10 @@ void CreateIconAndSetRelaunchDetails(
HWND hwnd) {
DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
- base::CommandLine command_line = ShellIntegration::CommandLineArgsForLauncher(
- shortcut_info->url, shortcut_info->extension_id,
- shortcut_info->profile_path);
+ base::CommandLine command_line =
+ shell_integration::CommandLineArgsForLauncher(
+ shortcut_info->url, shortcut_info->extension_id,
+ shortcut_info->profile_path);
base::FilePath chrome_exe;
if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
diff --git a/chrome/installer/util/shell_util.h b/chrome/installer/util/shell_util.h
index 3ec721d..c169018 100644
--- a/chrome/installer/util/shell_util.h
+++ b/chrome/installer/util/shell_util.h
@@ -426,7 +426,7 @@ class ShellUtil {
// browsing, e.g. http, https, .html etc., and requesting to become the
// default handler for each. If any of these fails the operation will return
// false to indicate failure, which is consistent with the return value of
- // ShellIntegration::GetDefaultBrowser.
+ // shell_integration::GetDefaultBrowser.
//
// In the case of failure any successful changes will be left, however no
// more changes will be attempted.
diff --git a/chrome/test/base/testing_browser_process.cc b/chrome/test/base/testing_browser_process.cc
index 0c3a254..7d1b999 100644
--- a/chrome/test/base/testing_browser_process.cc
+++ b/chrome/test/base/testing_browser_process.cc
@@ -394,9 +394,9 @@ memory::TabManager* TestingBrowserProcess::GetTabManager() {
return nullptr;
}
-ShellIntegration::DefaultWebClientState
+shell_integration::DefaultWebClientState
TestingBrowserProcess::CachedDefaultWebClientState() {
- return ShellIntegration::UNKNOWN_DEFAULT;
+ return shell_integration::UNKNOWN_DEFAULT;
}
void TestingBrowserProcess::SetSystemRequestContext(
net::URLRequestContextGetter* context_getter) {
diff --git a/chrome/test/base/testing_browser_process.h b/chrome/test/base/testing_browser_process.h
index 0a185e8..6ce6267 100644
--- a/chrome/test/base/testing_browser_process.h
+++ b/chrome/test/base/testing_browser_process.h
@@ -127,7 +127,7 @@ class TestingBrowserProcess : public BrowserProcess {
gcm::GCMDriver* gcm_driver() override;
memory::TabManager* GetTabManager() override;
- ShellIntegration::DefaultWebClientState CachedDefaultWebClientState()
+ shell_integration::DefaultWebClientState CachedDefaultWebClientState()
override;
// Set the local state for tests. Consumer is responsible for cleaning it up