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