| 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 "extensions/browser/guest_view/extension_options/extension_options_gues
t.h" | 5 #include "extensions/browser/guest_view/extension_options/extension_options_gues
t.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "components/crx_file/id_util.h" | 8 #include "components/crx_file/id_util.h" |
| 9 #include "content/public/browser/navigation_details.h" | 9 #include "content/public/browser/navigation_details.h" |
| 10 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
| 11 #include "content/public/browser/site_instance.h" | 11 #include "content/public/browser/site_instance.h" |
| 12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 13 #include "content/public/common/result_codes.h" | 13 #include "content/public/common/result_codes.h" |
| 14 #include "extensions/browser/api/extensions_api_client.h" | 14 #include "extensions/browser/api/extensions_api_client.h" |
| 15 #include "extensions/browser/bad_message.h" | 15 #include "extensions/browser/bad_message.h" |
| 16 #include "extensions/browser/extension_function_dispatcher.h" | 16 #include "extensions/browser/extension_function_dispatcher.h" |
| 17 #include "extensions/browser/extension_registry.h" | 17 #include "extensions/browser/extension_registry.h" |
| 18 #include "extensions/browser/extension_web_contents_observer.h" | 18 #include "extensions/browser/extension_web_contents_observer.h" |
| 19 #include "extensions/browser/guest_view/extension_options/extension_options_cons
tants.h" | 19 #include "extensions/browser/guest_view/extension_options/extension_options_cons
tants.h" |
| 20 #include "extensions/browser/guest_view/extension_options/extension_options_gues
t_delegate.h" | 20 #include "extensions/browser/guest_view/extension_options/extension_options_gues
t_delegate.h" |
| 21 #include "extensions/browser/guest_view/guest_view_event.h" |
| 21 #include "extensions/browser/guest_view/guest_view_manager.h" | 22 #include "extensions/browser/guest_view/guest_view_manager.h" |
| 22 #include "extensions/common/api/extension_options_internal.h" | 23 #include "extensions/common/api/extension_options_internal.h" |
| 23 #include "extensions/common/constants.h" | 24 #include "extensions/common/constants.h" |
| 24 #include "extensions/common/extension.h" | 25 #include "extensions/common/extension.h" |
| 25 #include "extensions/common/extension_messages.h" | 26 #include "extensions/common/extension_messages.h" |
| 26 #include "extensions/common/manifest_handlers/options_page_info.h" | 27 #include "extensions/common/manifest_handlers/options_page_info.h" |
| 27 #include "extensions/common/permissions/permissions_data.h" | 28 #include "extensions/common/permissions/permissions_data.h" |
| 28 #include "extensions/strings/grit/extensions_strings.h" | 29 #include "extensions/strings/grit/extensions_strings.h" |
| 29 #include "ipc/ipc_message_macros.h" | 30 #include "ipc/ipc_message_macros.h" |
| 30 | 31 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 extension_options_guest_delegate_->DidInitialize(); | 121 extension_options_guest_delegate_->DidInitialize(); |
| 121 } | 122 } |
| 122 web_contents()->GetController().LoadURL(options_page_, | 123 web_contents()->GetController().LoadURL(options_page_, |
| 123 content::Referrer(), | 124 content::Referrer(), |
| 124 ui::PAGE_TRANSITION_LINK, | 125 ui::PAGE_TRANSITION_LINK, |
| 125 std::string()); | 126 std::string()); |
| 126 } | 127 } |
| 127 | 128 |
| 128 void ExtensionOptionsGuest::GuestViewDidStopLoading() { | 129 void ExtensionOptionsGuest::GuestViewDidStopLoading() { |
| 129 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 130 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 130 DispatchEventToView(new GuestViewBase::Event( | 131 DispatchEventToView(new GuestViewEvent( |
| 131 extension_options_internal::OnLoad::kEventName, args.Pass())); | 132 this, extension_options_internal::OnLoad::kEventName, args.Pass())); |
| 132 } | 133 } |
| 133 | 134 |
| 134 const char* ExtensionOptionsGuest::GetAPINamespace() const { | 135 const char* ExtensionOptionsGuest::GetAPINamespace() const { |
| 135 return extensionoptions::kAPINamespace; | 136 return extensionoptions::kAPINamespace; |
| 136 } | 137 } |
| 137 | 138 |
| 138 int ExtensionOptionsGuest::GetTaskPrefix() const { | 139 int ExtensionOptionsGuest::GetTaskPrefix() const { |
| 139 return IDS_EXTENSION_TASK_MANAGER_EXTENSIONOPTIONS_TAG_PREFIX; | 140 return IDS_EXTENSION_TASK_MANAGER_EXTENSIONOPTIONS_TAG_PREFIX; |
| 140 } | 141 } |
| 141 | 142 |
| 142 bool ExtensionOptionsGuest::IsPreferredSizeModeEnabled() const { | 143 bool ExtensionOptionsGuest::IsPreferredSizeModeEnabled() const { |
| 143 return true; | 144 return true; |
| 144 } | 145 } |
| 145 | 146 |
| 146 bool ExtensionOptionsGuest::IsDragAndDropEnabled() const { | 147 bool ExtensionOptionsGuest::IsDragAndDropEnabled() const { |
| 147 return true; | 148 return true; |
| 148 } | 149 } |
| 149 | 150 |
| 150 void ExtensionOptionsGuest::OnPreferredSizeChanged(const gfx::Size& pref_size) { | 151 void ExtensionOptionsGuest::OnPreferredSizeChanged(const gfx::Size& pref_size) { |
| 151 extension_options_internal::PreferredSizeChangedOptions options; | 152 extension_options_internal::PreferredSizeChangedOptions options; |
| 152 // Convert the size from physical pixels to logical pixels. | 153 // Convert the size from physical pixels to logical pixels. |
| 153 options.width = PhysicalPixelsToLogicalPixels(pref_size.width()); | 154 options.width = PhysicalPixelsToLogicalPixels(pref_size.width()); |
| 154 options.height = PhysicalPixelsToLogicalPixels(pref_size.height()); | 155 options.height = PhysicalPixelsToLogicalPixels(pref_size.height()); |
| 155 DispatchEventToView(new GuestViewBase::Event( | 156 DispatchEventToView(new GuestViewEvent( |
| 157 this, |
| 156 extension_options_internal::OnPreferredSizeChanged::kEventName, | 158 extension_options_internal::OnPreferredSizeChanged::kEventName, |
| 157 options.ToValue())); | 159 options.ToValue())); |
| 158 } | 160 } |
| 159 | 161 |
| 160 content::WebContents* ExtensionOptionsGuest::GetAssociatedWebContents() const { | 162 content::WebContents* ExtensionOptionsGuest::GetAssociatedWebContents() const { |
| 161 return web_contents(); | 163 return web_contents(); |
| 162 } | 164 } |
| 163 | 165 |
| 164 content::WebContents* ExtensionOptionsGuest::OpenURLFromTab( | 166 content::WebContents* ExtensionOptionsGuest::OpenURLFromTab( |
| 165 content::WebContents* source, | 167 content::WebContents* source, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 178 params.frame_tree_node_id, | 180 params.frame_tree_node_id, |
| 179 NEW_FOREGROUND_TAB, | 181 NEW_FOREGROUND_TAB, |
| 180 params.transition, | 182 params.transition, |
| 181 params.is_renderer_initiated)); | 183 params.is_renderer_initiated)); |
| 182 } | 184 } |
| 183 return extension_options_guest_delegate_->OpenURLInNewTab(params); | 185 return extension_options_guest_delegate_->OpenURLInNewTab(params); |
| 184 } | 186 } |
| 185 | 187 |
| 186 void ExtensionOptionsGuest::CloseContents(content::WebContents* source) { | 188 void ExtensionOptionsGuest::CloseContents(content::WebContents* source) { |
| 187 DispatchEventToView( | 189 DispatchEventToView( |
| 188 new GuestViewBase::Event(extension_options_internal::OnClose::kEventName, | 190 new GuestViewEvent(this, |
| 189 make_scoped_ptr(new base::DictionaryValue()))); | 191 extension_options_internal::OnClose::kEventName, |
| 192 make_scoped_ptr(new base::DictionaryValue()))); |
| 190 } | 193 } |
| 191 | 194 |
| 192 bool ExtensionOptionsGuest::HandleContextMenu( | 195 bool ExtensionOptionsGuest::HandleContextMenu( |
| 193 const content::ContextMenuParams& params) { | 196 const content::ContextMenuParams& params) { |
| 194 if (!extension_options_guest_delegate_) | 197 if (!extension_options_guest_delegate_) |
| 195 return false; | 198 return false; |
| 196 | 199 |
| 197 return extension_options_guest_delegate_->HandleContextMenu(params); | 200 return extension_options_guest_delegate_->HandleContextMenu(params); |
| 198 } | 201 } |
| 199 | 202 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 return handled; | 253 return handled; |
| 251 } | 254 } |
| 252 | 255 |
| 253 void ExtensionOptionsGuest::OnRequest( | 256 void ExtensionOptionsGuest::OnRequest( |
| 254 const ExtensionHostMsg_Request_Params& params) { | 257 const ExtensionHostMsg_Request_Params& params) { |
| 255 extension_function_dispatcher_->Dispatch(params, | 258 extension_function_dispatcher_->Dispatch(params, |
| 256 web_contents()->GetRenderViewHost()); | 259 web_contents()->GetRenderViewHost()); |
| 257 } | 260 } |
| 258 | 261 |
| 259 } // namespace extensions | 262 } // namespace extensions |
| OLD | NEW |