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 <utility> | 7 #include <utility> |
8 | 8 |
| 9 #include "base/memory/ptr_util.h" |
9 #include "base/values.h" | 10 #include "base/values.h" |
10 #include "components/crx_file/id_util.h" | 11 #include "components/crx_file/id_util.h" |
11 #include "components/guest_view/browser/guest_view_event.h" | 12 #include "components/guest_view/browser/guest_view_event.h" |
12 #include "components/guest_view/browser/guest_view_manager.h" | 13 #include "components/guest_view/browser/guest_view_manager.h" |
13 #include "content/public/browser/navigation_details.h" | 14 #include "content/public/browser/navigation_details.h" |
14 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
15 #include "content/public/browser/site_instance.h" | 16 #include "content/public/browser/site_instance.h" |
16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
17 #include "content/public/common/result_codes.h" | 18 #include "content/public/common/result_codes.h" |
18 #include "extensions/browser/api/extensions_api_client.h" | 19 #include "extensions/browser/api/extensions_api_client.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 void ExtensionOptionsGuest::DidInitialize( | 120 void ExtensionOptionsGuest::DidInitialize( |
120 const base::DictionaryValue& create_params) { | 121 const base::DictionaryValue& create_params) { |
121 ExtensionsAPIClient::Get()->AttachWebContentsHelpers(web_contents()); | 122 ExtensionsAPIClient::Get()->AttachWebContentsHelpers(web_contents()); |
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 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
130 DispatchEventToView(make_scoped_ptr(new GuestViewEvent( | 131 DispatchEventToView(base::WrapUnique(new GuestViewEvent( |
131 extension_options_internal::OnLoad::kEventName, std::move(args)))); | 132 extension_options_internal::OnLoad::kEventName, std::move(args)))); |
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 void ExtensionOptionsGuest::OnPreferredSizeChanged(const gfx::Size& pref_size) { | 147 void ExtensionOptionsGuest::OnPreferredSizeChanged(const gfx::Size& pref_size) { |
147 extension_options_internal::PreferredSizeChangedOptions options; | 148 extension_options_internal::PreferredSizeChangedOptions options; |
148 // Convert the size from physical pixels to logical pixels. | 149 // Convert the size from physical pixels to logical pixels. |
149 options.width = PhysicalPixelsToLogicalPixels(pref_size.width()); | 150 options.width = PhysicalPixelsToLogicalPixels(pref_size.width()); |
150 options.height = PhysicalPixelsToLogicalPixels(pref_size.height()); | 151 options.height = PhysicalPixelsToLogicalPixels(pref_size.height()); |
151 DispatchEventToView(make_scoped_ptr(new GuestViewEvent( | 152 DispatchEventToView(base::WrapUnique(new GuestViewEvent( |
152 extension_options_internal::OnPreferredSizeChanged::kEventName, | 153 extension_options_internal::OnPreferredSizeChanged::kEventName, |
153 options.ToValue()))); | 154 options.ToValue()))); |
154 } | 155 } |
155 | 156 |
156 bool ExtensionOptionsGuest::ShouldHandleFindRequestsForEmbedder() const { | 157 bool ExtensionOptionsGuest::ShouldHandleFindRequestsForEmbedder() const { |
157 return true; | 158 return true; |
158 } | 159 } |
159 | 160 |
160 WebContents* ExtensionOptionsGuest::OpenURLFromTab( | 161 WebContents* ExtensionOptionsGuest::OpenURLFromTab( |
161 WebContents* source, | 162 WebContents* source, |
(...skipping 11 matching lines...) Expand all Loading... |
173 params.referrer, | 174 params.referrer, |
174 params.frame_tree_node_id, | 175 params.frame_tree_node_id, |
175 NEW_FOREGROUND_TAB, | 176 NEW_FOREGROUND_TAB, |
176 params.transition, | 177 params.transition, |
177 params.is_renderer_initiated)); | 178 params.is_renderer_initiated)); |
178 } | 179 } |
179 return extension_options_guest_delegate_->OpenURLInNewTab(params); | 180 return extension_options_guest_delegate_->OpenURLInNewTab(params); |
180 } | 181 } |
181 | 182 |
182 void ExtensionOptionsGuest::CloseContents(WebContents* source) { | 183 void ExtensionOptionsGuest::CloseContents(WebContents* source) { |
183 DispatchEventToView(make_scoped_ptr( | 184 DispatchEventToView(base::WrapUnique( |
184 new GuestViewEvent(extension_options_internal::OnClose::kEventName, | 185 new GuestViewEvent(extension_options_internal::OnClose::kEventName, |
185 make_scoped_ptr(new base::DictionaryValue())))); | 186 base::WrapUnique(new base::DictionaryValue())))); |
186 } | 187 } |
187 | 188 |
188 bool ExtensionOptionsGuest::HandleContextMenu( | 189 bool ExtensionOptionsGuest::HandleContextMenu( |
189 const content::ContextMenuParams& params) { | 190 const content::ContextMenuParams& params) { |
190 if (!extension_options_guest_delegate_) | 191 if (!extension_options_guest_delegate_) |
191 return false; | 192 return false; |
192 | 193 |
193 return extension_options_guest_delegate_->HandleContextMenu(params); | 194 return extension_options_guest_delegate_->HandleContextMenu(params); |
194 } | 195 } |
195 | 196 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 SetGuestZoomLevelToMatchEmbedder(); | 233 SetGuestZoomLevelToMatchEmbedder(); |
233 | 234 |
234 if (!url::IsSameOriginWith(params.url, options_page_)) { | 235 if (!url::IsSameOriginWith(params.url, options_page_)) { |
235 bad_message::ReceivedBadMessage(web_contents()->GetRenderProcessHost(), | 236 bad_message::ReceivedBadMessage(web_contents()->GetRenderProcessHost(), |
236 bad_message::EOG_BAD_ORIGIN); | 237 bad_message::EOG_BAD_ORIGIN); |
237 } | 238 } |
238 } | 239 } |
239 } | 240 } |
240 | 241 |
241 } // namespace extensions | 242 } // namespace extensions |
OLD | NEW |