| OLD | NEW |
| 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 "chrome/browser/guest_view/extension_options/extension_options_guest.h" | 5 #include "chrome/browser/guest_view/extension_options/extension_options_guest.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
| 9 #include "chrome/browser/extensions/extension_tab_util.h" | 9 #include "chrome/browser/extensions/extension_tab_util.h" |
| 10 #include "chrome/browser/guest_view/extension_options/extension_options_constant
s.h" | 10 #include "chrome/browser/guest_view/extension_options/extension_options_constant
s.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" | 12 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_finder.h" | 14 #include "chrome/browser/ui/browser_finder.h" |
| 15 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 17 #include "chrome/common/extensions/api/extension_options_internal.h" | 17 #include "chrome/common/extensions/api/extension_options_internal.h" |
| 18 #include "chrome/common/extensions/manifest_url_handler.h" | |
| 19 #include "components/crx_file/id_util.h" | 18 #include "components/crx_file/id_util.h" |
| 20 #include "components/renderer_context_menu/context_menu_delegate.h" | 19 #include "components/renderer_context_menu/context_menu_delegate.h" |
| 21 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
| 22 #include "content/public/browser/site_instance.h" | 21 #include "content/public/browser/site_instance.h" |
| 23 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 24 #include "extensions/browser/extension_function_dispatcher.h" | 23 #include "extensions/browser/extension_function_dispatcher.h" |
| 25 #include "extensions/browser/extension_registry.h" | 24 #include "extensions/browser/extension_registry.h" |
| 26 #include "extensions/browser/guest_view/guest_view_manager.h" | 25 #include "extensions/browser/guest_view/guest_view_manager.h" |
| 27 #include "extensions/common/extension.h" | 26 #include "extensions/common/extension.h" |
| 28 #include "extensions/common/extension_messages.h" | 27 #include "extensions/common/extension_messages.h" |
| 29 #include "extensions/common/feature_switch.h" | 28 #include "extensions/common/feature_switch.h" |
| 29 #include "extensions/common/manifest_handlers/options_page_info.h" |
| 30 #include "extensions/common/permissions/permissions_data.h" | 30 #include "extensions/common/permissions/permissions_data.h" |
| 31 #include "extensions/strings/grit/extensions_strings.h" | 31 #include "extensions/strings/grit/extensions_strings.h" |
| 32 #include "ipc/ipc_message_macros.h" | 32 #include "ipc/ipc_message_macros.h" |
| 33 | 33 |
| 34 using content::WebContents; | 34 using content::WebContents; |
| 35 using namespace extensions::api; | 35 using namespace extensions::api; |
| 36 | 36 |
| 37 // static | 37 // static |
| 38 const char ExtensionOptionsGuest::Type[] = "extensionoptions"; | 38 const char ExtensionOptionsGuest::Type[] = "extensionoptions"; |
| 39 | 39 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 if (!extension_url.is_valid()) { | 82 if (!extension_url.is_valid()) { |
| 83 callback.Run(NULL); | 83 callback.Run(NULL); |
| 84 return; | 84 return; |
| 85 } | 85 } |
| 86 | 86 |
| 87 // Get the options page URL for later use. | 87 // Get the options page URL for later use. |
| 88 extensions::ExtensionRegistry* registry = | 88 extensions::ExtensionRegistry* registry = |
| 89 extensions::ExtensionRegistry::Get(browser_context()); | 89 extensions::ExtensionRegistry::Get(browser_context()); |
| 90 const extensions::Extension* extension = | 90 const extensions::Extension* extension = |
| 91 registry->enabled_extensions().GetByID(extension_id); | 91 registry->enabled_extensions().GetByID(extension_id); |
| 92 options_page_ = extensions::ManifestURL::GetOptionsPage(extension); | 92 options_page_ = extensions::OptionsPageInfo::GetOptionsPage(extension); |
| 93 if (!options_page_.is_valid()) { | 93 if (!options_page_.is_valid()) { |
| 94 callback.Run(NULL); | 94 callback.Run(NULL); |
| 95 return; | 95 return; |
| 96 } | 96 } |
| 97 | 97 |
| 98 // Create a WebContents using the extension URL. The options page's | 98 // Create a WebContents using the extension URL. The options page's |
| 99 // WebContents should live in the same process as its parent extension's | 99 // WebContents should live in the same process as its parent extension's |
| 100 // WebContents, so we can use |extension_url| for creating the SiteInstance. | 100 // WebContents, so we can use |extension_url| for creating the SiteInstance. |
| 101 content::SiteInstance* options_site_instance = | 101 content::SiteInstance* options_site_instance = |
| 102 content::SiteInstance::CreateForURL(browser_context(), extension_url); | 102 content::SiteInstance::CreateForURL(browser_context(), extension_url); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 content::OpenURLParams params(target_url, | 230 content::OpenURLParams params(target_url, |
| 231 content::Referrer(), | 231 content::Referrer(), |
| 232 NEW_FOREGROUND_TAB, | 232 NEW_FOREGROUND_TAB, |
| 233 content::PAGE_TRANSITION_LINK, | 233 content::PAGE_TRANSITION_LINK, |
| 234 false); | 234 false); |
| 235 browser->OpenURL(params); | 235 browser->OpenURL(params); |
| 236 // TODO(ericzeng): Open the tab in the background if the click was a | 236 // TODO(ericzeng): Open the tab in the background if the click was a |
| 237 // ctrl-click or middle mouse button click | 237 // ctrl-click or middle mouse button click |
| 238 return false; | 238 return false; |
| 239 } | 239 } |
| OLD | NEW |