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/automation/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 5719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5730 AutomationJSONReply(this, reply_message).SendError( | 5730 AutomationJSONReply(this, reply_message).SendError( |
5731 StringPrintf("Extension with ID '%s' doesn't exist or is disabled.", | 5731 StringPrintf("Extension with ID '%s' doesn't exist or is disabled.", |
5732 id.c_str())); | 5732 id.c_str())); |
5733 return; | 5733 return; |
5734 } | 5734 } |
5735 | 5735 |
5736 // Look at preferences to find the right launch container. If no preference | 5736 // Look at preferences to find the right launch container. If no preference |
5737 // is set, launch as a regular tab. | 5737 // is set, launch as a regular tab. |
5738 extension_misc::LaunchContainer launch_container = | 5738 extension_misc::LaunchContainer launch_container = |
5739 service->extension_prefs()->GetLaunchContainer( | 5739 service->extension_prefs()->GetLaunchContainer( |
5740 extension, ExtensionPrefs::LAUNCH_REGULAR); | 5740 extension, extensions::ExtensionPrefs::LAUNCH_REGULAR); |
5741 | 5741 |
5742 WebContents* old_contents = chrome::GetActiveWebContents(browser); | 5742 WebContents* old_contents = chrome::GetActiveWebContents(browser); |
5743 if (!old_contents) { | 5743 if (!old_contents) { |
5744 AutomationJSONReply(this, reply_message).SendError( | 5744 AutomationJSONReply(this, reply_message).SendError( |
5745 "Cannot identify selected tab contents."); | 5745 "Cannot identify selected tab contents."); |
5746 return; | 5746 return; |
5747 } | 5747 } |
5748 | 5748 |
5749 // This observer will delete itself. | 5749 // This observer will delete itself. |
5750 new AppLaunchObserver(&old_contents->GetController(), this, reply_message, | 5750 new AppLaunchObserver(&old_contents->GetController(), this, reply_message, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5782 } | 5782 } |
5783 | 5783 |
5784 const Extension* extension = service->GetExtensionById( | 5784 const Extension* extension = service->GetExtensionById( |
5785 id, true /* include disabled extensions */); | 5785 id, true /* include disabled extensions */); |
5786 if (!extension) { | 5786 if (!extension) { |
5787 reply.SendError( | 5787 reply.SendError( |
5788 StringPrintf("Extension with ID '%s' doesn't exist.", id.c_str())); | 5788 StringPrintf("Extension with ID '%s' doesn't exist.", id.c_str())); |
5789 return; | 5789 return; |
5790 } | 5790 } |
5791 | 5791 |
5792 ExtensionPrefs::LaunchType launch_type; | 5792 extensions::ExtensionPrefs::LaunchType launch_type; |
5793 if (launch_type_str == "pinned") { | 5793 if (launch_type_str == "pinned") { |
5794 launch_type = ExtensionPrefs::LAUNCH_PINNED; | 5794 launch_type = extensions::ExtensionPrefs::LAUNCH_PINNED; |
5795 } else if (launch_type_str == "regular") { | 5795 } else if (launch_type_str == "regular") { |
5796 launch_type = ExtensionPrefs::LAUNCH_REGULAR; | 5796 launch_type = extensions::ExtensionPrefs::LAUNCH_REGULAR; |
5797 } else if (launch_type_str == "fullscreen") { | 5797 } else if (launch_type_str == "fullscreen") { |
5798 launch_type = ExtensionPrefs::LAUNCH_FULLSCREEN; | 5798 launch_type = extensions::ExtensionPrefs::LAUNCH_FULLSCREEN; |
5799 } else if (launch_type_str == "window") { | 5799 } else if (launch_type_str == "window") { |
5800 launch_type = ExtensionPrefs::LAUNCH_WINDOW; | 5800 launch_type = extensions::ExtensionPrefs::LAUNCH_WINDOW; |
5801 } else { | 5801 } else { |
5802 reply.SendError( | 5802 reply.SendError( |
5803 StringPrintf("Unexpected launch type '%s'.", launch_type_str.c_str())); | 5803 StringPrintf("Unexpected launch type '%s'.", launch_type_str.c_str())); |
5804 return; | 5804 return; |
5805 } | 5805 } |
5806 | 5806 |
5807 service->extension_prefs()->SetLaunchType(extension->id(), launch_type); | 5807 service->extension_prefs()->SetLaunchType(extension->id(), launch_type); |
5808 reply.SendSuccess(NULL); | 5808 reply.SendSuccess(NULL); |
5809 } | 5809 } |
5810 | 5810 |
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6770 void TestingAutomationProvider::OnRemoveProvider() { | 6770 void TestingAutomationProvider::OnRemoveProvider() { |
6771 if (g_browser_process) | 6771 if (g_browser_process) |
6772 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6772 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
6773 } | 6773 } |
6774 | 6774 |
6775 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 6775 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
6776 WebContents* tab) { | 6776 WebContents* tab) { |
6777 if (chrome::GetActiveWebContents(browser) != tab) | 6777 if (chrome::GetActiveWebContents(browser) != tab) |
6778 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); | 6778 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); |
6779 } | 6779 } |
OLD | NEW |