| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_per_app.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 23 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
| 24 #include "chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.h
" | 24 #include "chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.h
" |
| 25 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
| 26 #include "chrome/browser/ui/browser_commands.h" | 26 #include "chrome/browser/ui/browser_commands.h" |
| 27 #include "chrome/browser/ui/browser_finder.h" | 27 #include "chrome/browser/ui/browser_finder.h" |
| 28 #include "chrome/browser/ui/browser_list.h" | 28 #include "chrome/browser/ui/browser_list.h" |
| 29 #include "chrome/browser/ui/host_desktop.h" | 29 #include "chrome/browser/ui/host_desktop.h" |
| 30 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 30 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 31 #include "chrome/common/extensions/extension.h" | 31 #include "chrome/common/extensions/extension.h" |
| 32 #include "chrome/common/extensions/extension_constants.h" | 32 #include "chrome/common/extensions/extension_constants.h" |
| 33 #include "chrome/common/extensions/extension_manifest_constants.h" | |
| 34 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
| 35 #include "chrome/test/base/browser_with_test_window_test.h" | 34 #include "chrome/test/base/browser_with_test_window_test.h" |
| 36 #include "chrome/test/base/testing_pref_service_syncable.h" | 35 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 37 #include "chrome/test/base/testing_profile.h" | 36 #include "chrome/test/base/testing_profile.h" |
| 38 #include "content/public/test/test_browser_thread.h" | 37 #include "content/public/test/test_browser_thread.h" |
| 38 #include "extensions/common/manifest_constants.h" |
| 39 #include "testing/gtest/include/gtest/gtest.h" | 39 #include "testing/gtest/include/gtest/gtest.h" |
| 40 #include "ui/base/models/menu_model.h" | 40 #include "ui/base/models/menu_model.h" |
| 41 | 41 |
| 42 using extensions::Extension; | 42 using extensions::Extension; |
| 43 using extensions::Manifest; | 43 using extensions::Manifest; |
| 44 | 44 |
| 45 namespace { | 45 namespace { |
| 46 const char* offline_gmail_url = "https://mail.google.com/mail/mu/u"; | 46 const char* offline_gmail_url = "https://mail.google.com/mail/mu/u"; |
| 47 const char* gmail_url = "https://mail.google.com/mail/u"; | 47 const char* gmail_url = "https://mail.google.com/mail/u"; |
| 48 } | 48 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 } | 147 } |
| 148 | 148 |
| 149 virtual void SetUp() OVERRIDE { | 149 virtual void SetUp() OVERRIDE { |
| 150 BrowserWithTestWindowTest::SetUp(); | 150 BrowserWithTestWindowTest::SetUp(); |
| 151 | 151 |
| 152 model_.reset(new ash::LauncherModel); | 152 model_.reset(new ash::LauncherModel); |
| 153 model_observer_.reset(new TestLauncherModelObserver); | 153 model_observer_.reset(new TestLauncherModelObserver); |
| 154 model_->AddObserver(model_observer_.get()); | 154 model_->AddObserver(model_observer_.get()); |
| 155 | 155 |
| 156 DictionaryValue manifest; | 156 DictionaryValue manifest; |
| 157 manifest.SetString(extension_manifest_keys::kName, | 157 manifest.SetString(extensions::manifest_keys::kName, |
| 158 "launcher controller test extension"); | 158 "launcher controller test extension"); |
| 159 manifest.SetString(extension_manifest_keys::kVersion, "1"); | 159 manifest.SetString(extensions::manifest_keys::kVersion, "1"); |
| 160 manifest.SetString(extension_manifest_keys::kDescription, | 160 manifest.SetString(extensions::manifest_keys::kDescription, |
| 161 "for testing pinned apps"); | 161 "for testing pinned apps"); |
| 162 | 162 |
| 163 extensions::TestExtensionSystem* extension_system( | 163 extensions::TestExtensionSystem* extension_system( |
| 164 static_cast<extensions::TestExtensionSystem*>( | 164 static_cast<extensions::TestExtensionSystem*>( |
| 165 extensions::ExtensionSystem::Get(profile()))); | 165 extensions::ExtensionSystem::Get(profile()))); |
| 166 extension_service_ = extension_system->CreateExtensionService( | 166 extension_service_ = extension_system->CreateExtensionService( |
| 167 CommandLine::ForCurrentProcess(), base::FilePath(), false); | 167 CommandLine::ForCurrentProcess(), base::FilePath(), false); |
| 168 | 168 |
| 169 std::string error; | 169 std::string error; |
| 170 extension1_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 170 extension1_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 171 manifest, | 171 manifest, |
| 172 Extension::NO_FLAGS, | 172 Extension::NO_FLAGS, |
| 173 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", | 173 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", |
| 174 &error); | 174 &error); |
| 175 extension2_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 175 extension2_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 176 manifest, | 176 manifest, |
| 177 Extension::NO_FLAGS, | 177 Extension::NO_FLAGS, |
| 178 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", | 178 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", |
| 179 &error); | 179 &error); |
| 180 // Fake gmail extension. | 180 // Fake gmail extension. |
| 181 DictionaryValue manifest_gmail; | 181 DictionaryValue manifest_gmail; |
| 182 manifest_gmail.SetString(extension_manifest_keys::kName, | 182 manifest_gmail.SetString(extensions::manifest_keys::kName, |
| 183 "Gmail launcher controller test extension"); | 183 "Gmail launcher controller test extension"); |
| 184 manifest_gmail.SetString(extension_manifest_keys::kVersion, "1"); | 184 manifest_gmail.SetString(extensions::manifest_keys::kVersion, "1"); |
| 185 manifest_gmail.SetString(extension_manifest_keys::kDescription, | 185 manifest_gmail.SetString(extensions::manifest_keys::kDescription, |
| 186 "for testing pinned Gmail"); | 186 "for testing pinned Gmail"); |
| 187 manifest_gmail.SetString(extension_manifest_keys::kLaunchWebURL, | 187 manifest_gmail.SetString(extensions::manifest_keys::kLaunchWebURL, |
| 188 "https://mail.google.com/mail/ca"); | 188 "https://mail.google.com/mail/ca"); |
| 189 ListValue* list = new ListValue(); | 189 ListValue* list = new ListValue(); |
| 190 list->Append(Value::CreateStringValue("*://mail.google.com/mail/ca")); | 190 list->Append(Value::CreateStringValue("*://mail.google.com/mail/ca")); |
| 191 manifest_gmail.Set(extension_manifest_keys::kWebURLs, list); | 191 manifest_gmail.Set(extensions::manifest_keys::kWebURLs, list); |
| 192 | 192 |
| 193 extension3_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 193 extension3_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 194 manifest_gmail, | 194 manifest_gmail, |
| 195 Extension::NO_FLAGS, | 195 Extension::NO_FLAGS, |
| 196 extension_misc::kGmailAppId, | 196 extension_misc::kGmailAppId, |
| 197 &error); | 197 &error); |
| 198 | 198 |
| 199 // Fake search extension. | 199 // Fake search extension. |
| 200 extension4_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 200 extension4_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 201 manifest, | 201 manifest, |
| (...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 ash::LauncherID gmail_id = model_->next_id(); | 1147 ash::LauncherID gmail_id = model_->next_id(); |
| 1148 extension_service_->AddExtension(extension3_.get()); | 1148 extension_service_->AddExtension(extension3_.get()); |
| 1149 EXPECT_EQ(3, model_->item_count()); | 1149 EXPECT_EQ(3, model_->item_count()); |
| 1150 int gmail_index = model_->ItemIndexByID(gmail_id); | 1150 int gmail_index = model_->ItemIndexByID(gmail_id); |
| 1151 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[gmail_index].type); | 1151 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[gmail_index].type); |
| 1152 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 1152 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 1153 | 1153 |
| 1154 // The content should not be able to be handled by the app. | 1154 // The content should not be able to be handled by the app. |
| 1155 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); | 1155 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); |
| 1156 } | 1156 } |
| OLD | NEW |