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

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

Issue 525793002: Make WebContentsObserver::web_contents() public (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments addressed Created 6 years, 3 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 "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"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
103 WebContents::CreateParams params(browser_context(), options_site_instance); 103 WebContents::CreateParams params(browser_context(), options_site_instance);
104 params.guest_delegate = this; 104 params.guest_delegate = this;
105 callback.Run(WebContents::Create(params)); 105 callback.Run(WebContents::Create(params));
106 } 106 }
107 107
108 void ExtensionOptionsGuest::DidAttachToEmbedder() { 108 void ExtensionOptionsGuest::DidAttachToEmbedder() {
109 SetUpAutoSize(); 109 SetUpAutoSize();
110 guest_web_contents()->GetController().LoadURL(options_page_, 110 web_contents()->GetController().LoadURL(options_page_,
111 content::Referrer(), 111 content::Referrer(),
112 content::PAGE_TRANSITION_LINK, 112 content::PAGE_TRANSITION_LINK,
113 std::string()); 113 std::string());
114 } 114 }
115 115
116 void ExtensionOptionsGuest::DidInitialize() { 116 void ExtensionOptionsGuest::DidInitialize() {
117 extension_function_dispatcher_.reset( 117 extension_function_dispatcher_.reset(
118 new extensions::ExtensionFunctionDispatcher(browser_context(), this)); 118 new extensions::ExtensionFunctionDispatcher(browser_context(), this));
119 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( 119 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
120 guest_web_contents()); 120 web_contents());
121 } 121 }
122 122
123 void ExtensionOptionsGuest::DidStopLoading() { 123 void ExtensionOptionsGuest::DidStopLoading() {
124 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 124 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
125 DispatchEventToEmbedder(new extensions::GuestViewBase::Event( 125 DispatchEventToEmbedder(new extensions::GuestViewBase::Event(
126 extensions::api::extension_options_internal::OnLoad::kEventName, 126 extensions::api::extension_options_internal::OnLoad::kEventName,
127 args.Pass())); 127 args.Pass()));
128 } 128 }
129 129
130 const char* ExtensionOptionsGuest::GetAPINamespace() const { 130 const char* ExtensionOptionsGuest::GetAPINamespace() const {
(...skipping 14 matching lines...) Expand all
145 args->SetInteger(extensionoptions::kOldHeight, old_size.height()); 145 args->SetInteger(extensionoptions::kOldHeight, old_size.height());
146 DispatchEventToEmbedder(new extensions::GuestViewBase::Event( 146 DispatchEventToEmbedder(new extensions::GuestViewBase::Event(
147 extension_options_internal::OnSizeChanged::kEventName, args.Pass())); 147 extension_options_internal::OnSizeChanged::kEventName, args.Pass()));
148 } 148 }
149 149
150 bool ExtensionOptionsGuest::IsAutoSizeSupported() const { 150 bool ExtensionOptionsGuest::IsAutoSizeSupported() const {
151 return true; 151 return true;
152 } 152 }
153 153
154 content::WebContents* ExtensionOptionsGuest::GetAssociatedWebContents() const { 154 content::WebContents* ExtensionOptionsGuest::GetAssociatedWebContents() const {
155 return guest_web_contents(); 155 return web_contents();
156 } 156 }
157 157
158 void ExtensionOptionsGuest::CloseContents(content::WebContents* source) { 158 void ExtensionOptionsGuest::CloseContents(content::WebContents* source) {
159 DispatchEventToEmbedder(new extensions::GuestViewBase::Event( 159 DispatchEventToEmbedder(new extensions::GuestViewBase::Event(
160 extension_options_internal::OnClose::kEventName, 160 extension_options_internal::OnClose::kEventName,
161 make_scoped_ptr(new base::DictionaryValue()))); 161 make_scoped_ptr(new base::DictionaryValue())));
162 } 162 }
163 163
164 bool ExtensionOptionsGuest::HandleContextMenu( 164 bool ExtensionOptionsGuest::HandleContextMenu(
165 const content::ContextMenuParams& params) { 165 const content::ContextMenuParams& params) {
166 ContextMenuDelegate* menu_delegate = 166 ContextMenuDelegate* menu_delegate =
167 ContextMenuDelegate::FromWebContents(guest_web_contents()); 167 ContextMenuDelegate::FromWebContents(web_contents());
168 DCHECK(menu_delegate); 168 DCHECK(menu_delegate);
169 169
170 scoped_ptr<RenderViewContextMenu> menu = 170 scoped_ptr<RenderViewContextMenu> menu =
171 menu_delegate->BuildMenu(guest_web_contents(), params); 171 menu_delegate->BuildMenu(web_contents(), params);
172 menu_delegate->ShowMenu(menu.Pass()); 172 menu_delegate->ShowMenu(menu.Pass());
173 return true; 173 return true;
174 } 174 }
175 175
176 bool ExtensionOptionsGuest::ShouldCreateWebContents( 176 bool ExtensionOptionsGuest::ShouldCreateWebContents(
177 content::WebContents* web_contents, 177 content::WebContents* web_contents,
178 int route_id, 178 int route_id,
179 WindowContainerType window_container_type, 179 WindowContainerType window_container_type,
180 const base::string16& frame_name, 180 const base::string16& frame_name,
181 const GURL& target_url, 181 const GURL& target_url,
(...skipping 22 matching lines...) Expand all
204 IPC_BEGIN_MESSAGE_MAP(ExtensionOptionsGuest, message) 204 IPC_BEGIN_MESSAGE_MAP(ExtensionOptionsGuest, message)
205 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) 205 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
206 IPC_MESSAGE_UNHANDLED(handled = false) 206 IPC_MESSAGE_UNHANDLED(handled = false)
207 IPC_END_MESSAGE_MAP() 207 IPC_END_MESSAGE_MAP()
208 return handled; 208 return handled;
209 } 209 }
210 210
211 void ExtensionOptionsGuest::OnRequest( 211 void ExtensionOptionsGuest::OnRequest(
212 const ExtensionHostMsg_Request_Params& params) { 212 const ExtensionHostMsg_Request_Params& params) {
213 extension_function_dispatcher_->Dispatch( 213 extension_function_dispatcher_->Dispatch(
214 params, guest_web_contents()->GetRenderViewHost()); 214 params, web_contents()->GetRenderViewHost());
215 } 215 }
216 216
217 void ExtensionOptionsGuest::SetUpAutoSize() { 217 void ExtensionOptionsGuest::SetUpAutoSize() {
218 // Read the autosize parameters passed in from the embedder. 218 // Read the autosize parameters passed in from the embedder.
219 bool auto_size_enabled = false; 219 bool auto_size_enabled = false;
220 attach_params()->GetBoolean(extensionoptions::kAttributeAutoSize, 220 attach_params()->GetBoolean(extensionoptions::kAttributeAutoSize,
221 &auto_size_enabled); 221 &auto_size_enabled);
222 222
223 int max_height = 0; 223 int max_height = 0;
224 int max_width = 0; 224 int max_width = 0;
225 attach_params()->GetInteger(extensionoptions::kAttributeMaxHeight, 225 attach_params()->GetInteger(extensionoptions::kAttributeMaxHeight,
226 &max_height); 226 &max_height);
227 attach_params()->GetInteger(extensionoptions::kAttributeMaxWidth, &max_width); 227 attach_params()->GetInteger(extensionoptions::kAttributeMaxWidth, &max_width);
228 228
229 int min_height = 0; 229 int min_height = 0;
230 int min_width = 0; 230 int min_width = 0;
231 attach_params()->GetInteger(extensionoptions::kAttributeMinHeight, 231 attach_params()->GetInteger(extensionoptions::kAttributeMinHeight,
232 &min_height); 232 &min_height);
233 attach_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width); 233 attach_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width);
234 234
235 // Call SetAutoSize to apply all the appropriate validation and clipping of 235 // Call SetAutoSize to apply all the appropriate validation and clipping of
236 // values. 236 // values.
237 SetAutoSize(auto_size_enabled, 237 SetAutoSize(auto_size_enabled,
238 gfx::Size(min_width, min_height), 238 gfx::Size(min_width, min_height),
239 gfx::Size(max_width, max_height)); 239 gfx::Size(max_width, max_height));
240 } 240 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/tab_helper.h ('k') | chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698