Commit e9b8e2e2 authored by ericzeng's avatar ericzeng Committed by Commit bot

Fix ExtensionOptionsGuest style and minor bug

- Reorganize methods in cc file so they match up with the header
- In SetUpAutoSize, use the autosize flag parameter read in from
  the embedder to enable/disable autosize instead of passing true

BUG=386838

Review URL: https://codereview.chromium.org/510183002

Cr-Commit-Position: refs/heads/master@{#292629}
parent 358e9ee7
...@@ -135,25 +135,6 @@ int ExtensionOptionsGuest::GetTaskPrefix() const { ...@@ -135,25 +135,6 @@ int ExtensionOptionsGuest::GetTaskPrefix() const {
return IDS_EXTENSION_TASK_MANAGER_EXTENSIONOPTIONS_TAG_PREFIX; return IDS_EXTENSION_TASK_MANAGER_EXTENSIONOPTIONS_TAG_PREFIX;
} }
content::WebContents* ExtensionOptionsGuest::GetAssociatedWebContents() const {
return guest_web_contents();
}
bool ExtensionOptionsGuest::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ExtensionOptionsGuest, message)
IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void ExtensionOptionsGuest::OnRequest(
const ExtensionHostMsg_Request_Params& params) {
extension_function_dispatcher_->Dispatch(
params, guest_web_contents()->GetRenderViewHost());
}
void ExtensionOptionsGuest::GuestSizeChangedDueToAutoSize( void ExtensionOptionsGuest::GuestSizeChangedDueToAutoSize(
const gfx::Size& old_size, const gfx::Size& old_size,
const gfx::Size& new_size) { const gfx::Size& new_size) {
...@@ -170,28 +151,8 @@ bool ExtensionOptionsGuest::IsAutoSizeSupported() const { ...@@ -170,28 +151,8 @@ bool ExtensionOptionsGuest::IsAutoSizeSupported() const {
return true; return true;
} }
void ExtensionOptionsGuest::SetUpAutoSize() { content::WebContents* ExtensionOptionsGuest::GetAssociatedWebContents() const {
// Read the autosize parameters passed in from the embedder. return guest_web_contents();
bool auto_size_enabled = false;
attach_params()->GetBoolean(extensionoptions::kAttributeAutoSize,
&auto_size_enabled);
int max_height = 0;
int max_width = 0;
attach_params()->GetInteger(extensionoptions::kAttributeMaxHeight,
&max_height);
attach_params()->GetInteger(extensionoptions::kAttributeMaxWidth, &max_width);
int min_height = 0;
int min_width = 0;
attach_params()->GetInteger(extensionoptions::kAttributeMinHeight,
&min_height);
attach_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width);
// Call SetAutoSize to apply all the appropriate validation and clipping of
// values.
SetAutoSize(
true, gfx::Size(min_width, min_height), gfx::Size(max_width, max_height));
} }
void ExtensionOptionsGuest::CloseContents(content::WebContents* source) { void ExtensionOptionsGuest::CloseContents(content::WebContents* source) {
...@@ -237,3 +198,43 @@ bool ExtensionOptionsGuest::ShouldCreateWebContents( ...@@ -237,3 +198,43 @@ bool ExtensionOptionsGuest::ShouldCreateWebContents(
// ctrl-click or middle mouse button click // ctrl-click or middle mouse button click
return false; return false;
} }
bool ExtensionOptionsGuest::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ExtensionOptionsGuest, message)
IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void ExtensionOptionsGuest::OnRequest(
const ExtensionHostMsg_Request_Params& params) {
extension_function_dispatcher_->Dispatch(
params, guest_web_contents()->GetRenderViewHost());
}
void ExtensionOptionsGuest::SetUpAutoSize() {
// Read the autosize parameters passed in from the embedder.
bool auto_size_enabled = false;
attach_params()->GetBoolean(extensionoptions::kAttributeAutoSize,
&auto_size_enabled);
int max_height = 0;
int max_width = 0;
attach_params()->GetInteger(extensionoptions::kAttributeMaxHeight,
&max_height);
attach_params()->GetInteger(extensionoptions::kAttributeMaxWidth, &max_width);
int min_height = 0;
int min_width = 0;
attach_params()->GetInteger(extensionoptions::kAttributeMinHeight,
&min_height);
attach_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width);
// Call SetAutoSize to apply all the appropriate validation and clipping of
// values.
SetAutoSize(auto_size_enabled,
gfx::Size(min_width, min_height),
gfx::Size(max_width, max_height));
}
...@@ -61,8 +61,8 @@ class ExtensionOptionsGuest ...@@ -61,8 +61,8 @@ class ExtensionOptionsGuest
ExtensionOptionsGuest(content::BrowserContext* browser_context, ExtensionOptionsGuest(content::BrowserContext* browser_context,
int guest_instance_id); int guest_instance_id);
virtual ~ExtensionOptionsGuest(); virtual ~ExtensionOptionsGuest();
void SetUpAutoSize();
void OnRequest(const ExtensionHostMsg_Request_Params& params); void OnRequest(const ExtensionHostMsg_Request_Params& params);
void SetUpAutoSize();
scoped_ptr<extensions::ExtensionFunctionDispatcher> scoped_ptr<extensions::ExtensionFunctionDispatcher>
extension_function_dispatcher_; extension_function_dispatcher_;
......
...@@ -53,7 +53,7 @@ ExtensionOptionsInternal.prototype.attachWindow = function() { ...@@ -53,7 +53,7 @@ ExtensionOptionsInternal.prototype.attachWindow = function() {
this.internalInstanceId, this.internalInstanceId,
this.guestInstanceId, this.guestInstanceId,
{ {
'autosize': this.autosize, 'autosize': this.extensionoptionsNode.hasAttribute('autosize'),
'instanceId': this.viewInstanceId, 'instanceId': this.viewInstanceId,
'maxheight': parseInt(this.maxheight || 0), 'maxheight': parseInt(this.maxheight || 0),
'maxwidth': parseInt(this.maxwidth || 0), 'maxwidth': parseInt(this.maxwidth || 0),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment