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

Side by Side Diff: services/shell/shell.cc

Issue 1871223003: Use ShellClientFactory interface to load mojo:profile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
« no previous file with comments | « services/shell/shell.h ('k') | services/shell/tests/connect/connect_test.mojom » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "services/shell/shell.h" 5 #include "services/shell/shell.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 void Shell::AddInstanceListener(mojom::InstanceListenerPtr listener) { 635 void Shell::AddInstanceListener(mojom::InstanceListenerPtr listener) {
636 // TODO(beng): filter instances provided by those visible to this client. 636 // TODO(beng): filter instances provided by those visible to this client.
637 Array<mojom::InstanceInfoPtr> instances; 637 Array<mojom::InstanceInfoPtr> instances;
638 for (auto& instance : identity_to_instance_) 638 for (auto& instance : identity_to_instance_)
639 instances.push_back(instance.second->CreateInstanceInfo()); 639 instances.push_back(instance.second->CreateInstanceInfo());
640 listener->SetExistingInstances(std::move(instances)); 640 listener->SetExistingInstances(std::move(instances));
641 641
642 instance_listeners_.AddPtr(std::move(listener)); 642 instance_listeners_.AddPtr(std::move(listener));
643 } 643 }
644 644
645 void Shell::CreateShellClientWithFactory(const Identity& source, 645 void Shell::CreateShellClientWithFactory(const Identity& shell_client_factory,
646 const Identity& shell_client_factory,
647 const std::string& name, 646 const std::string& name,
648 mojom::ShellClientRequest request) { 647 mojom::ShellClientRequest request) {
649 mojom::ShellClientFactory* factory = 648 mojom::ShellClientFactory* factory =
650 GetShellClientFactory(shell_client_factory, source); 649 GetShellClientFactory(shell_client_factory);
651 factory->CreateShellClient(std::move(request), name); 650 factory->CreateShellClient(std::move(request), name);
652 } 651 }
653 652
654 mojom::ShellClientFactory* Shell::GetShellClientFactory( 653 mojom::ShellClientFactory* Shell::GetShellClientFactory(
655 const Identity& shell_client_factory_identity, 654 const Identity& shell_client_factory_identity) {
656 const Identity& source_identity) {
657 auto it = shell_client_factories_.find(shell_client_factory_identity); 655 auto it = shell_client_factories_.find(shell_client_factory_identity);
658 if (it != shell_client_factories_.end()) 656 if (it != shell_client_factories_.end())
659 return it->second.get(); 657 return it->second.get();
660 658
659 Identity source_identity(kShellName, mojom::kInheritUserID);
661 mojom::ShellClientFactoryPtr factory; 660 mojom::ShellClientFactoryPtr factory;
662 ConnectToInterface(this, source_identity, shell_client_factory_identity, 661 ConnectToInterface(this, source_identity, shell_client_factory_identity,
663 &factory); 662 &factory);
664 mojom::ShellClientFactory* factory_interface = factory.get(); 663 mojom::ShellClientFactory* factory_interface = factory.get();
665 factory.set_connection_error_handler( 664 factory.set_connection_error_handler(
666 base::Bind(&Shell::OnShellClientFactoryLost, 665 base::Bind(&Shell::OnShellClientFactoryLost,
667 weak_ptr_factory_.GetWeakPtr(), 666 weak_ptr_factory_.GetWeakPtr(),
668 shell_client_factory_identity)); 667 shell_client_factory_identity));
669 shell_client_factories_[shell_client_factory_identity] = std::move(factory); 668 shell_client_factories_[shell_client_factory_identity] = std::move(factory);
670 return factory_interface; 669 return factory_interface;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 mojom::ShellClientRequest request = GetProxy(&client); 737 mojom::ShellClientRequest request = GetProxy(&client);
739 if (LoadWithLoader(target, &request)) { 738 if (LoadWithLoader(target, &request)) {
740 instance->StartWithClient(std::move(client)); 739 instance->StartWithClient(std::move(client));
741 } else { 740 } else {
742 CHECK(!result->package_url.is_null() && !result->capabilities.is_null()); 741 CHECK(!result->package_url.is_null() && !result->capabilities.is_null());
743 742
744 if (target.name() != result->resolved_name) { 743 if (target.name() != result->resolved_name) {
745 instance->StartWithClient(std::move(client)); 744 instance->StartWithClient(std::move(client));
746 Identity factory(result->resolved_name, target.user_id(), 745 Identity factory(result->resolved_name, target.user_id(),
747 instance_name); 746 instance_name);
748 CreateShellClientWithFactory(source, factory, target.name(), 747 CreateShellClientWithFactory(factory, target.name(),
749 std::move(request)); 748 std::move(request));
750 } else { 749 } else {
751 instance->StartWithFilePath( 750 instance->StartWithFilePath(
752 util::UrlToFilePath(result->package_url.To<GURL>())); 751 util::UrlToFilePath(result->package_url.To<GURL>()));
753 } 752 }
754 } 753 }
755 } 754 }
756 755
757 // Now that the instance has a ShellClient, we can connect to it. 756 // Now that the instance has a ShellClient, we can connect to it.
758 instance->ConnectToClient(std::move(params)); 757 instance->ConnectToClient(std::move(params));
(...skipping 23 matching lines...) Expand all
782 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) { 781 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) {
783 if (it->get() == runner) { 782 if (it->get() == runner) {
784 native_runners_.erase(it); 783 native_runners_.erase(it);
785 return; 784 return;
786 } 785 }
787 } 786 }
788 } 787 }
789 788
790 } // namespace shell 789 } // namespace shell
791 } // namespace mojo 790 } // namespace mojo
OLDNEW
« no previous file with comments | « services/shell/shell.h ('k') | services/shell/tests/connect/connect_test.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698