Chromium Code Reviews| 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 "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/guest_view/extension_options/extension_options_constant s.h" | 9 #include "chrome/browser/guest_view/extension_options/extension_options_constant s.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 const WebContentsCreatedCallback& callback) { | 57 const WebContentsCreatedCallback& callback) { |
| 58 // Get the extension's base URL. | 58 // Get the extension's base URL. |
| 59 std::string extension_id; | 59 std::string extension_id; |
| 60 create_params.GetString(extensionoptions::kExtensionId, &extension_id); | 60 create_params.GetString(extensionoptions::kExtensionId, &extension_id); |
| 61 | 61 |
| 62 if (!extensions::Extension::IdIsValid(extension_id)) { | 62 if (!extensions::Extension::IdIsValid(extension_id)) { |
| 63 callback.Run(NULL); | 63 callback.Run(NULL); |
| 64 return; | 64 return; |
| 65 } | 65 } |
| 66 | 66 |
| 67 if (extension_id != embedder_extension_id) { | 67 if (!embedder_extension_id.empty()) { |
| 68 callback.Run(NULL); | 68 if (extension_id != embedder_extension_id) { |
|
not at google - send to devlin
2014/08/12 00:08:23
how about:
if (extensions::Extension::IdIsValid(e
ericzeng
2014/08/12 00:32:26
Done.
| |
| 69 return; | 69 callback.Run(NULL); |
| 70 return; | |
| 71 } | |
| 70 } | 72 } |
| 71 | 73 |
| 72 GURL extension_url = | 74 GURL extension_url = |
| 73 extensions::Extension::GetBaseURLFromExtensionId(extension_id); | 75 extensions::Extension::GetBaseURLFromExtensionId(extension_id); |
| 74 if (!extension_url.is_valid()) { | 76 if (!extension_url.is_valid()) { |
| 75 callback.Run(NULL); | 77 callback.Run(NULL); |
| 76 return; | 78 return; |
| 77 } | 79 } |
| 78 | 80 |
| 79 // Get the options page URL for later use. | 81 // Get the options page URL for later use. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 DispatchEventToEmbedder(new GuestViewBase::Event( | 149 DispatchEventToEmbedder(new GuestViewBase::Event( |
| 148 extension_options_internal::OnSizeChanged::kEventName, args.Pass())); | 150 extension_options_internal::OnSizeChanged::kEventName, args.Pass())); |
| 149 } | 151 } |
| 150 | 152 |
| 151 bool ExtensionOptionsGuest::IsAutoSizeSupported() const { | 153 bool ExtensionOptionsGuest::IsAutoSizeSupported() const { |
| 152 return true; | 154 return true; |
| 153 } | 155 } |
| 154 | 156 |
| 155 void ExtensionOptionsGuest::SetUpAutoSize() { | 157 void ExtensionOptionsGuest::SetUpAutoSize() { |
| 156 // Read the autosize parameters passed in from the embedder. | 158 // Read the autosize parameters passed in from the embedder. |
| 157 bool auto_size_enabled; | 159 bool auto_size_enabled = false; |
| 158 extra_params()->GetBoolean(extensionoptions::kAttributeAutoSize, | 160 extra_params()->GetBoolean(extensionoptions::kAttributeAutoSize, |
| 159 &auto_size_enabled); | 161 &auto_size_enabled); |
| 160 | 162 |
| 161 int max_height = 0; | 163 int max_height = 0; |
| 162 int max_width = 0; | 164 int max_width = 0; |
| 163 extra_params()->GetInteger(extensionoptions::kAttributeMaxHeight, | 165 extra_params()->GetInteger(extensionoptions::kAttributeMaxHeight, |
| 164 &max_height); | 166 &max_height); |
| 165 extra_params()->GetInteger(extensionoptions::kAttributeMaxWidth, &max_width); | 167 extra_params()->GetInteger(extensionoptions::kAttributeMaxWidth, &max_width); |
| 166 | 168 |
| 167 int min_height = 0; | 169 int min_height = 0; |
| 168 int min_width = 0; | 170 int min_width = 0; |
| 169 extra_params()->GetInteger(extensionoptions::kAttributeMinHeight, | 171 extra_params()->GetInteger(extensionoptions::kAttributeMinHeight, |
| 170 &min_height); | 172 &min_height); |
| 171 extra_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width); | 173 extra_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width); |
| 172 | 174 |
| 173 // Call SetAutoSize to apply all the appropriate validation and clipping of | 175 // Call SetAutoSize to apply all the appropriate validation and clipping of |
| 174 // values. | 176 // values. |
| 175 SetAutoSize( | 177 SetAutoSize( |
| 176 true, gfx::Size(min_width, min_height), gfx::Size(max_width, max_height)); | 178 true, gfx::Size(min_width, min_height), gfx::Size(max_width, max_height)); |
| 177 } | 179 } |
| OLD | NEW |