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

Side by Side Diff: chrome/browser/chromeos/arc/arc_auth_service.cc

Issue 2436903003: Extract ArcSupportMessageHost. (Closed)
Patch Set: Fix tests Created 4 years, 2 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/arc/arc_auth_service.h" 5 #include "chrome/browser/chromeos/arc/arc_auth_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/shelf/shelf_delegate.h" 9 #include "ash/common/shelf/shelf_delegate.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 if (!IsAllowedForProfile(profile)) 462 if (!IsAllowedForProfile(profile))
463 return; 463 return;
464 464
465 // TODO(khmel): Move this to IsAllowedForProfile. 465 // TODO(khmel): Move this to IsAllowedForProfile.
466 if (IsArcDisabledForEnterprise() && IsAccountManaged(profile)) { 466 if (IsArcDisabledForEnterprise() && IsAccountManaged(profile)) {
467 VLOG(2) << "Enterprise users are not supported in ARC."; 467 VLOG(2) << "Enterprise users are not supported in ARC.";
468 return; 468 return;
469 } 469 }
470 470
471 profile_ = profile; 471 profile_ = profile;
472 support_host_.reset(new ArcSupportHost());
khmel 2016/10/21 03:34:49 I would recommend to create it on demand. In most
hidehiko 2016/10/21 07:40:27 Ah, yes it can be in theory, but the current code
khmel 2016/10/24 15:05:36 Took another look. arc_support_host is not trivial
hidehiko 2016/10/24 19:00:58 I agree that observing pref can be wasteful, but i
472 SetState(State::STOPPED); 473 SetState(State::STOPPED);
473 474
474 PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver( 475 PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver(
475 prefs::kArcEnabled, this); 476 prefs::kArcEnabled, this);
476 477
477 context_.reset(new ArcAuthContext(this, profile_)); 478 context_.reset(new ArcAuthContext(this, profile_));
478 479
479 // In case UI is disabled we assume that ARC is opted-in. 480 // In case UI is disabled we assume that ARC is opted-in.
480 if (IsOptInVerificationDisabled()) { 481 if (IsOptInVerificationDisabled()) {
481 auth_code_.clear(); 482 auth_code_.clear();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 if (app_window_registry->GetCurrentAppWindowForApp( 544 if (app_window_registry->GetCurrentAppWindowForApp(
544 ArcSupportHost::kHostAppId)) { 545 ArcSupportHost::kHostAppId)) {
545 return; 546 return;
546 } 547 }
547 548
548 const extensions::Extension* extension = 549 const extensions::Extension* extension =
549 extensions::ExtensionRegistry::Get(profile_)->GetInstalledExtension( 550 extensions::ExtensionRegistry::Get(profile_)->GetInstalledExtension(
550 ArcSupportHost::kHostAppId); 551 ArcSupportHost::kHostAppId);
551 CHECK(extension && extensions::util::IsAppLaunchable( 552 CHECK(extension && extensions::util::IsAppLaunchable(
552 ArcSupportHost::kHostAppId, profile_)); 553 ArcSupportHost::kHostAppId, profile_));
553
554 OpenApplication(CreateAppLaunchParamsUserContainer( 554 OpenApplication(CreateAppLaunchParamsUserContainer(
555 profile_, extension, WindowOpenDisposition::NEW_WINDOW, 555 profile_, extension, WindowOpenDisposition::NEW_WINDOW,
556 extensions::SOURCE_CHROME_INTERNAL)); 556 extensions::SOURCE_CHROME_INTERNAL));
557 } 557 }
558 558
559 void ArcAuthService::OnContextReady() { 559 void ArcAuthService::OnContextReady() {
560 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 560 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
561 561
562 DCHECK(!initial_opt_in_); 562 DCHECK(!initial_opt_in_);
563 CheckAndroidManagement(false); 563 CheckAndroidManagement(false);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 } 660 }
661 661
662 void ArcAuthService::RemoveObserver(Observer* observer) { 662 void ArcAuthService::RemoveObserver(Observer* observer) {
663 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 663 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
664 observer_list_.RemoveObserver(observer); 664 observer_list_.RemoveObserver(observer);
665 } 665 }
666 666
667 void ArcAuthService::CloseUI() { 667 void ArcAuthService::CloseUI() {
668 ui_page_ = UIPage::NO_PAGE; 668 ui_page_ = UIPage::NO_PAGE;
669 ui_page_status_.clear(); 669 ui_page_status_.clear();
670 for (auto& observer : observer_list_) 670 if (support_host_)
671 observer.OnOptInUIClose(); 671 support_host_->Close();
672 if (!g_disable_ui_for_testing) 672 if (!g_disable_ui_for_testing)
673 ArcAuthNotification::Hide(); 673 ArcAuthNotification::Hide();
674 } 674 }
675 675
676 void ArcAuthService::SetUIPage(UIPage page, const base::string16& status) { 676 void ArcAuthService::SetUIPage(UIPage page, const base::string16& status) {
677 ui_page_ = page; 677 ui_page_ = page;
678 ui_page_status_ = status; 678 ui_page_status_ = status;
679 for (auto& observer : observer_list_) 679 if (support_host_)
khmel 2016/10/21 03:34:49 In my previous comment I recommend to create host
hidehiko 2016/10/21 07:40:27 Unfortunately, it cannot, specifically for CloseUI
khmel 2016/10/24 15:05:36 Acknowledged, however it would be nice to have LOG
hidehiko 2016/10/24 19:00:58 Adding log makes sense. But, as I said, it is not
680 observer.OnOptInUIShowPage(ui_page_, ui_page_status_); 680 support_host_->ShowPage(ui_page_, ui_page_status_);
681 } 681 }
682 682
683 // This is the special method to support enterprise mojo API. 683 // This is the special method to support enterprise mojo API.
684 // TODO(hidehiko): Remove this. 684 // TODO(hidehiko): Remove this.
685 void ArcAuthService::StopAndEnableArc() { 685 void ArcAuthService::StopAndEnableArc() {
686 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 686 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
687 DCHECK(!arc_bridge_service()->stopped()); 687 DCHECK(!arc_bridge_service()->stopped());
688 reenable_arc_ = true; 688 reenable_arc_ = true;
689 StopArc(); 689 StopArc();
690 } 690 }
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 return os << kStateFetchingCode; 943 return os << kStateFetchingCode;
944 case ArcAuthService::State::ACTIVE: 944 case ArcAuthService::State::ACTIVE:
945 return os << kStateActive; 945 return os << kStateActive;
946 default: 946 default:
947 NOTREACHED(); 947 NOTREACHED();
948 return os; 948 return os;
949 } 949 }
950 } 950 }
951 951
952 } // namespace arc 952 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698