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

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

Issue 2436903003: Extract ArcSupportMessageHost. (Closed)
Patch Set: Address comments. 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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 if (!IsAllowedForProfile(profile)) 477 if (!IsAllowedForProfile(profile))
478 return; 478 return;
479 479
480 // TODO(khmel): Move this to IsAllowedForProfile. 480 // TODO(khmel): Move this to IsAllowedForProfile.
481 if (IsArcDisabledForEnterprise() && IsAccountManaged(profile)) { 481 if (IsArcDisabledForEnterprise() && IsAccountManaged(profile)) {
482 VLOG(2) << "Enterprise users are not supported in ARC."; 482 VLOG(2) << "Enterprise users are not supported in ARC.";
483 return; 483 return;
484 } 484 }
485 485
486 profile_ = profile; 486 profile_ = profile;
487 // Create the support host at initialization. Note that, practically,
488 // ARC support Chrome app is rarely used (only opt-in and re-auth flow).
489 // So, it may be better to initialize it lazily.
490 // TODO(hidehiko): Revisit to think about lazy initialization.
491 support_host_.reset(new ArcSupportHost());
487 SetState(State::STOPPED); 492 SetState(State::STOPPED);
488 493
489 PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver( 494 PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver(
490 prefs::kArcEnabled, this); 495 prefs::kArcEnabled, this);
491 496
492 context_.reset(new ArcAuthContext(this, profile_)); 497 context_.reset(new ArcAuthContext(this, profile_));
493 498
494 // In case UI is disabled we assume that ARC is opted-in. 499 // In case UI is disabled we assume that ARC is opted-in.
495 if (IsOptInVerificationDisabled()) { 500 if (IsOptInVerificationDisabled()) {
496 auth_code_.clear(); 501 auth_code_.clear();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 context_.reset(); 550 context_.reset();
546 profile_ = nullptr; 551 profile_ = nullptr;
547 SetState(State::NOT_INITIALIZED); 552 SetState(State::NOT_INITIALIZED);
548 } 553 }
549 554
550 void ArcAuthService::ShowUI(UIPage page, const base::string16& status) { 555 void ArcAuthService::ShowUI(UIPage page, const base::string16& status) {
551 if (g_disable_ui_for_testing || IsOptInVerificationDisabled()) 556 if (g_disable_ui_for_testing || IsOptInVerificationDisabled())
552 return; 557 return;
553 558
554 SetUIPage(page, status); 559 SetUIPage(page, status);
555 const extensions::AppWindowRegistry* const app_window_registry = 560 const extensions::AppWindowRegistry* const app_window_registry =
khmel 2016/10/21 14:27:23 One more request, can you please move logic of sho
hidehiko 2016/10/24 06:03:26 Sure I will, but let me work on it in a separate C
khmel 2016/10/24 15:05:36 Acknowledged.
556 extensions::AppWindowRegistry::Get(profile_); 561 extensions::AppWindowRegistry::Get(profile_);
557 DCHECK(app_window_registry); 562 DCHECK(app_window_registry);
558 if (app_window_registry->GetCurrentAppWindowForApp( 563 if (app_window_registry->GetCurrentAppWindowForApp(
559 ArcSupportHost::kHostAppId)) { 564 ArcSupportHost::kHostAppId)) {
560 return; 565 return;
561 } 566 }
562 567
563 const extensions::Extension* extension = 568 const extensions::Extension* extension =
564 extensions::ExtensionRegistry::Get(profile_)->GetInstalledExtension( 569 extensions::ExtensionRegistry::Get(profile_)->GetInstalledExtension(
565 ArcSupportHost::kHostAppId); 570 ArcSupportHost::kHostAppId);
566 CHECK(extension && extensions::util::IsAppLaunchable( 571 CHECK(extension && extensions::util::IsAppLaunchable(
567 ArcSupportHost::kHostAppId, profile_)); 572 ArcSupportHost::kHostAppId, profile_));
568
569 OpenApplication(CreateAppLaunchParamsUserContainer( 573 OpenApplication(CreateAppLaunchParamsUserContainer(
570 profile_, extension, WindowOpenDisposition::NEW_WINDOW, 574 profile_, extension, WindowOpenDisposition::NEW_WINDOW,
571 extensions::SOURCE_CHROME_INTERNAL)); 575 extensions::SOURCE_CHROME_INTERNAL));
572 } 576 }
573 577
574 void ArcAuthService::OnContextReady() { 578 void ArcAuthService::OnContextReady() {
575 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 579 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
576 580
577 DCHECK(!initial_opt_in_); 581 DCHECK(!initial_opt_in_);
578 CheckAndroidManagement(false); 582 CheckAndroidManagement(false);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 } 679 }
676 680
677 void ArcAuthService::RemoveObserver(Observer* observer) { 681 void ArcAuthService::RemoveObserver(Observer* observer) {
678 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 682 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
679 observer_list_.RemoveObserver(observer); 683 observer_list_.RemoveObserver(observer);
680 } 684 }
681 685
682 void ArcAuthService::CloseUI() { 686 void ArcAuthService::CloseUI() {
683 ui_page_ = UIPage::NO_PAGE; 687 ui_page_ = UIPage::NO_PAGE;
684 ui_page_status_.clear(); 688 ui_page_status_.clear();
685 for (auto& observer : observer_list_) 689 if (support_host_)
686 observer.OnOptInUIClose(); 690 support_host_->Close();
687 if (!g_disable_ui_for_testing) 691 if (!g_disable_ui_for_testing)
688 ArcAuthNotification::Hide(); 692 ArcAuthNotification::Hide();
689 } 693 }
690 694
691 void ArcAuthService::SetUIPage(UIPage page, const base::string16& status) { 695 void ArcAuthService::SetUIPage(UIPage page, const base::string16& status) {
692 ui_page_ = page; 696 ui_page_ = page;
693 ui_page_status_ = status; 697 ui_page_status_ = status;
694 for (auto& observer : observer_list_) 698 if (support_host_)
695 observer.OnOptInUIShowPage(ui_page_, ui_page_status_); 699 support_host_->ShowPage(ui_page_, ui_page_status_);
696 } 700 }
697 701
698 // This is the special method to support enterprise mojo API. 702 // This is the special method to support enterprise mojo API.
699 // TODO(hidehiko): Remove this. 703 // TODO(hidehiko): Remove this.
700 void ArcAuthService::StopAndEnableArc() { 704 void ArcAuthService::StopAndEnableArc() {
701 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 705 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
702 DCHECK(!arc_bridge_service()->stopped()); 706 DCHECK(!arc_bridge_service()->stopped());
703 reenable_arc_ = true; 707 reenable_arc_ = true;
704 StopArc(); 708 StopArc();
705 } 709 }
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 return os << kStateFetchingCode; 973 return os << kStateFetchingCode;
970 case ArcAuthService::State::ACTIVE: 974 case ArcAuthService::State::ACTIVE:
971 return os << kStateActive; 975 return os << kStateActive;
972 default: 976 default:
973 NOTREACHED(); 977 NOTREACHED();
974 return os; 978 return os;
975 } 979 }
976 } 980 }
977 981
978 } // namespace arc 982 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698