Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: extensions/browser/guest_view/extension_options/extension_options_guest.cc

Issue 1087123002: Towards Decoupling GuestView from Extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed lazyboy@'s comments. Removed unnecessary includes. Simplified GuestViewEvent. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 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(
156 extension_options_internal::OnPreferredSizeChanged::kEventName, 157 extension_options_internal::OnPreferredSizeChanged::kEventName,
157 options.ToValue())); 158 options.ToValue()));
158 } 159 }
159 160
160 content::WebContents* ExtensionOptionsGuest::GetAssociatedWebContents() const { 161 content::WebContents* ExtensionOptionsGuest::GetAssociatedWebContents() const {
161 return web_contents(); 162 return web_contents();
162 } 163 }
163 164
164 content::WebContents* ExtensionOptionsGuest::OpenURLFromTab( 165 content::WebContents* ExtensionOptionsGuest::OpenURLFromTab(
165 content::WebContents* source, 166 content::WebContents* source,
(...skipping 12 matching lines...) Expand all
178 params.frame_tree_node_id, 179 params.frame_tree_node_id,
179 NEW_FOREGROUND_TAB, 180 NEW_FOREGROUND_TAB,
180 params.transition, 181 params.transition,
181 params.is_renderer_initiated)); 182 params.is_renderer_initiated));
182 } 183 }
183 return extension_options_guest_delegate_->OpenURLInNewTab(params); 184 return extension_options_guest_delegate_->OpenURLInNewTab(params);
184 } 185 }
185 186
186 void ExtensionOptionsGuest::CloseContents(content::WebContents* source) { 187 void ExtensionOptionsGuest::CloseContents(content::WebContents* source) {
187 DispatchEventToView( 188 DispatchEventToView(
188 new GuestViewBase::Event(extension_options_internal::OnClose::kEventName, 189 new GuestViewEvent(extension_options_internal::OnClose::kEventName,
189 make_scoped_ptr(new base::DictionaryValue()))); 190 make_scoped_ptr(new base::DictionaryValue())));
190 } 191 }
191 192
192 bool ExtensionOptionsGuest::HandleContextMenu( 193 bool ExtensionOptionsGuest::HandleContextMenu(
193 const content::ContextMenuParams& params) { 194 const content::ContextMenuParams& params) {
194 if (!extension_options_guest_delegate_) 195 if (!extension_options_guest_delegate_)
195 return false; 196 return false;
196 197
197 return extension_options_guest_delegate_->HandleContextMenu(params); 198 return extension_options_guest_delegate_->HandleContextMenu(params);
198 } 199 }
199 200
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 return handled; 251 return handled;
251 } 252 }
252 253
253 void ExtensionOptionsGuest::OnRequest( 254 void ExtensionOptionsGuest::OnRequest(
254 const ExtensionHostMsg_Request_Params& params) { 255 const ExtensionHostMsg_Request_Params& params) {
255 extension_function_dispatcher_->Dispatch(params, 256 extension_function_dispatcher_->Dispatch(params,
256 web_contents()->GetRenderViewHost()); 257 web_contents()->GetRenderViewHost());
257 } 258 }
258 259
259 } // namespace extensions 260 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698