OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/ash/launcher/chrome_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 using extensions::Extension; | 73 using extensions::Extension; |
74 using extensions::Manifest; | 74 using extensions::Manifest; |
75 using extensions::UnloadedExtensionInfo; | 75 using extensions::UnloadedExtensionInfo; |
76 | 76 |
77 namespace { | 77 namespace { |
78 const char* offline_gmail_url = "https://mail.google.com/mail/mu/u"; | 78 const char* offline_gmail_url = "https://mail.google.com/mail/mu/u"; |
79 const char* gmail_url = "https://mail.google.com/mail/u"; | 79 const char* gmail_url = "https://mail.google.com/mail/u"; |
80 const char* kGmailLaunchURL = "https://mail.google.com/mail/ca"; | 80 const char* kGmailLaunchURL = "https://mail.google.com/mail/ca"; |
81 | 81 |
82 #if defined(OS_CHROMEOS) | 82 #if defined(OS_CHROMEOS) |
83 // As defined in /chromeos/dbus/cryptohome_client.cc. | |
84 const char kUserIdHashSuffix[] = "-hash"; | |
85 | |
86 // An extension prefix. | 83 // An extension prefix. |
87 const char kCrxAppPrefix[] = "_crx_"; | 84 const char kCrxAppPrefix[] = "_crx_"; |
88 #endif | 85 #endif |
89 | 86 |
90 // ShelfModelObserver implementation that tracks what messages are invoked. | 87 // ShelfModelObserver implementation that tracks what messages are invoked. |
91 class TestShelfModelObserver : public ash::ShelfModelObserver { | 88 class TestShelfModelObserver : public ash::ShelfModelObserver { |
92 public: | 89 public: |
93 TestShelfModelObserver() | 90 TestShelfModelObserver() |
94 : added_(0), | 91 : added_(0), |
95 removed_(0), | 92 removed_(0), |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 // the ownership of the created object. | 817 // the ownership of the created object. |
821 TestingProfile* CreateMultiUserProfile(const std::string& user_name) { | 818 TestingProfile* CreateMultiUserProfile(const std::string& user_name) { |
822 std::string email_string = user_name + "@example.com"; | 819 std::string email_string = user_name + "@example.com"; |
823 static_cast<ash::test::TestSessionStateDelegate*>( | 820 static_cast<ash::test::TestSessionStateDelegate*>( |
824 ash::Shell::GetInstance()->session_state_delegate()) | 821 ash::Shell::GetInstance()->session_state_delegate()) |
825 ->AddUser(email_string); | 822 ->AddUser(email_string); |
826 // Add a user to the fake user manager. | 823 // Add a user to the fake user manager. |
827 session_delegate()->AddUser(email_string); | 824 session_delegate()->AddUser(email_string); |
828 GetFakeUserManager()->AddUser(email_string); | 825 GetFakeUserManager()->AddUser(email_string); |
829 | 826 |
830 GetFakeUserManager()->UserLoggedIn( | 827 GetFakeUserManager()->LoginUser(email_string); |
831 email_string, | |
832 email_string + kUserIdHashSuffix, | |
833 false); | |
834 | 828 |
835 std::string profile_name = | 829 TestingProfile* profile = |
836 chrome::kProfileDirPrefix + email_string + kUserIdHashSuffix; | 830 profile_manager()->CreateTestingProfile(email_string); |
837 TestingProfile* profile = profile_manager()->CreateTestingProfile( | |
838 profile_name, | |
839 scoped_ptr<PrefServiceSyncable>(), | |
840 ASCIIToUTF16(email_string), 0, std::string(), | |
841 TestingProfile::TestingFactories()); | |
842 profile->set_profile_name(email_string); | |
843 EXPECT_TRUE(profile); | 831 EXPECT_TRUE(profile); |
| 832 |
844 // Remember the profile name so that we can destroy it upon destruction. | 833 // Remember the profile name so that we can destroy it upon destruction. |
845 created_profiles_[profile] = profile_name; | 834 created_profiles_[profile] = email_string; |
846 if (chrome::MultiUserWindowManager::GetInstance()) | 835 if (chrome::MultiUserWindowManager::GetInstance()) |
847 chrome::MultiUserWindowManager::GetInstance()->AddUser(profile); | 836 chrome::MultiUserWindowManager::GetInstance()->AddUser(profile); |
848 if (launcher_controller_) | 837 if (launcher_controller_) |
849 launcher_controller_->AdditionalUserAddedToSession(profile); | 838 launcher_controller_->AdditionalUserAddedToSession(profile); |
850 return profile; | 839 return profile; |
851 } | 840 } |
852 | 841 |
853 // Switch to another user. | 842 // Switch to another user. |
854 void SwitchActiveUser(const std::string& name) { | 843 void SwitchActiveUser(const std::string& name) { |
855 session_delegate()->SwitchActiveUser(name); | 844 session_delegate()->SwitchActiveUser(name); |
(...skipping 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2692 | 2681 |
2693 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 2682 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
2694 ASSERT_EQ(initial_size + 1, model_->items().size()); | 2683 ASSERT_EQ(initial_size + 1, model_->items().size()); |
2695 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 2684 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
2696 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 2685 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
2697 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); | 2686 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); |
2698 | 2687 |
2699 launcher_controller_->UnpinAppWithID("1"); | 2688 launcher_controller_->UnpinAppWithID("1"); |
2700 ASSERT_EQ(initial_size, model_->items().size()); | 2689 ASSERT_EQ(initial_size, model_->items().size()); |
2701 } | 2690 } |
OLD | NEW |