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

Unified Diff: chrome/browser/ui/webui/welcome_win10_handler.cc

Issue 2512553007: Add GetIsPinnedToTaskbarState() (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/welcome_win10_handler.cc
diff --git a/chrome/browser/ui/webui/welcome_win10_handler.cc b/chrome/browser/ui/webui/welcome_win10_handler.cc
index 95124b556aba29591fcb0457bfa4471573422847..9ab794fb6e146025e102abc36417dd4b82f35eb0 100644
--- a/chrome/browser/ui/webui/welcome_win10_handler.cc
+++ b/chrome/browser/ui/webui/welcome_win10_handler.cc
@@ -5,16 +5,15 @@
#include "chrome/browser/ui/webui/welcome_win10_handler.h"
#include "base/bind.h"
-#include "base/memory/ptr_util.h"
+#include "base/values.h"
#include "chrome/browser/shell_integration.h"
+#include "chrome/browser/shell_integration_win.h"
#include "chrome/common/url_constants.h"
-#include "chrome/grit/generated_resources.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
-#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
-WelcomeWin10Handler::WelcomeWin10Handler() {
+WelcomeWin10Handler::WelcomeWin10Handler() : weak_ptr_factory_(this) {
// The check is started as early as possible because waiting for the page to
// be fully loaded is unnecessarily wasting time.
StartIsPinnedToTaskbarCheck();
@@ -75,20 +74,15 @@ void WelcomeWin10Handler::HandleContinue(const base::ListValue* args) {
}
void WelcomeWin10Handler::StartIsPinnedToTaskbarCheck() {
- // Start the utility process that will handle the IsPinnedToTaskbar() call.
- client_ =
- base::MakeUnique<content::UtilityProcessMojoClient<mojom::ShellHandler>>(
- l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_SHELL_HANDLER_NAME));
-
// Assume that Chrome is pinned to the taskbar if an error occurs.
- client_->set_error_callback(
+ base::Closure error_callback =
base::Bind(&WelcomeWin10Handler::OnIsPinnedToTaskbarDetermined,
- base::Unretained(this), true));
- client_->set_disable_sandbox();
- client_->Start();
+ weak_ptr_factory_.GetWeakPtr(), true);
- client_->service()->IsPinnedToTaskbar(base::Bind(
- &WelcomeWin10Handler::OnIsPinnedToTaskbarResult, base::Unretained(this)));
+ shell_integration::win::GetIsPinnedToTaskbarState(
+ error_callback,
+ base::Bind(&WelcomeWin10Handler::OnIsPinnedToTaskbarResult,
+ weak_ptr_factory_.GetWeakPtr()));
}
void WelcomeWin10Handler::OnIsPinnedToTaskbarResult(bool succeeded,
@@ -100,9 +94,11 @@ void WelcomeWin10Handler::OnIsPinnedToTaskbarDetermined(
bool is_pinned_to_taskbar) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- // Reset the client and the timer to make sure this function only gets called
- // once.
- client_.reset();
+ // Early exit if the pinned_state was already determined.
+ if (pinned_state_result_)
+ return;
+
+ // Stop the timer if it's still running.
timer_.Stop();
pinned_state_result_ = is_pinned_to_taskbar;
« chrome/browser/shell_integration_win.cc ('K') | « chrome/browser/ui/webui/welcome_win10_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698