OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Implements the Chrome Extensions Tab Capture API. | 5 // Implements the Chrome Extensions Tab Capture API. |
6 | 6 |
7 #include "chrome/browser/extensions/api/tab_capture/tab_capture_api.h" | 7 #include "chrome/browser/extensions/api/tab_capture/tab_capture_api.h" |
8 | 8 |
| 9 #include <algorithm> |
9 #include <set> | 10 #include <set> |
10 #include <string> | 11 #include <string> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
14 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/browser/extensions/api/tab_capture/offscreen_presentation.h" |
16 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" | 18 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" |
17 #include "chrome/browser/extensions/extension_renderer_state.h" | 19 #include "chrome/browser/extensions/extension_renderer_state.h" |
18 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/sessions/session_tab_helper.h" | 21 #include "chrome/browser/sessions/session_tab_helper.h" |
20 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/browser_finder.h" | 23 #include "chrome/browser/ui/browser_finder.h" |
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 24 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 25 #include "chrome/common/chrome_switches.h" |
23 #include "content/public/browser/render_frame_host.h" | 26 #include "content/public/browser/render_frame_host.h" |
24 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
| 28 #include "content/public/browser/web_contents.h" |
25 #include "extensions/common/features/feature.h" | 29 #include "extensions/common/features/feature.h" |
26 #include "extensions/common/features/feature_provider.h" | 30 #include "extensions/common/features/feature_provider.h" |
27 #include "extensions/common/features/simple_feature.h" | 31 #include "extensions/common/features/simple_feature.h" |
28 #include "extensions/common/permissions/permissions_data.h" | 32 #include "extensions/common/permissions/permissions_data.h" |
29 #include "extensions/common/switches.h" | 33 #include "extensions/common/switches.h" |
30 | 34 |
31 using extensions::api::tab_capture::MediaStreamConstraint; | 35 using extensions::api::tab_capture::MediaStreamConstraint; |
32 | 36 |
33 namespace TabCapture = extensions::api::tab_capture; | 37 namespace TabCapture = extensions::api::tab_capture; |
34 namespace GetCapturedTabs = TabCapture::GetCapturedTabs; | 38 namespace GetCapturedTabs = TabCapture::GetCapturedTabs; |
35 | 39 |
36 namespace extensions { | 40 namespace extensions { |
37 namespace { | 41 namespace { |
38 | 42 |
39 const char kCapturingSameTab[] = "Cannot capture a tab with an active stream."; | 43 const char kCapturingSameTab[] = "Cannot capture a tab with an active stream."; |
40 const char kFindingTabError[] = "Error finding tab to capture."; | 44 const char kFindingTabError[] = "Error finding tab to capture."; |
41 const char kNoAudioOrVideo[] = "Capture failed. No audio or video requested."; | 45 const char kNoAudioOrVideo[] = "Capture failed. No audio or video requested."; |
42 const char kGrantError[] = | 46 const char kGrantError[] = |
43 "Extension has not been invoked for the current page (see activeTab " | 47 "Extension has not been invoked for the current page (see activeTab " |
44 "permission). Chrome pages cannot be captured."; | 48 "permission). Chrome pages cannot be captured."; |
45 | 49 |
46 // Keys/values for media stream constraints. | 50 const char kNotWhitelistedForOffscreenTabApi[] = |
| 51 "Extension is not whitelisted for use of the unstable, in-development " |
| 52 "chrome.tabCapture.captureOffscreenTab API."; |
| 53 const char kInvalidStartUrl[] = |
| 54 "Invalid/Missing/Malformatted starting URL for off-screen tab."; |
| 55 const char kTooManyOffscreenTabs[] = |
| 56 "Extension has already started too many off-screen tabs."; |
| 57 const char kCapturingSameOffscreenTab[] = |
| 58 "Cannot capture the same off-screen tab more than once."; |
| 59 |
| 60 // Keys/values passed to renderer-side JS bindings. |
47 const char kMediaStreamSource[] = "chromeMediaSource"; | 61 const char kMediaStreamSource[] = "chromeMediaSource"; |
48 const char kMediaStreamSourceId[] = "chromeMediaSourceId"; | 62 const char kMediaStreamSourceId[] = "chromeMediaSourceId"; |
49 const char kMediaStreamSourceTab[] = "tab"; | 63 const char kMediaStreamSourceTab[] = "tab"; |
50 | 64 |
51 // Tab Capture-specific video constraint to enable automatic resolution/rate | 65 // Tab Capture-specific video constraint to enable automatic resolution/rate |
52 // throttling mode in the capture pipeline. | 66 // throttling mode in the capture pipeline. |
53 const char kEnableAutoThrottlingKey[] = "enableAutoThrottling"; | 67 const char kEnableAutoThrottlingKey[] = "enableAutoThrottling"; |
54 | 68 |
| 69 bool OptionsSpecifyAudioOrVideo(const TabCapture::CaptureOptions& options) { |
| 70 return (options.audio && *options.audio) || (options.video && *options.video); |
| 71 } |
| 72 |
| 73 bool IsAcceptableOffscreenTabUrl(const GURL& url) { |
| 74 return url.is_valid() && (url.SchemeIsHTTPOrHTTPS() || url.SchemeIs("data")); |
| 75 } |
| 76 |
| 77 // Add Chrome-specific source identifiers to the MediaStreamConstraints objects |
| 78 // in |options| to provide references to the |target_contents| to be captured. |
| 79 void AddMediaStreamSourceConstraints(content::WebContents* target_contents, |
| 80 TabCapture::CaptureOptions* options) { |
| 81 DCHECK(options); |
| 82 DCHECK(target_contents); |
| 83 |
| 84 MediaStreamConstraint* constraints_to_modify[2] = { nullptr, nullptr }; |
| 85 |
| 86 if (options->audio && *options->audio) { |
| 87 if (!options->audio_constraints) |
| 88 options->audio_constraints.reset(new MediaStreamConstraint); |
| 89 constraints_to_modify[0] = options->audio_constraints.get(); |
| 90 } |
| 91 |
| 92 bool enable_auto_throttling = false; |
| 93 if (options->video && *options->video) { |
| 94 if (options->video_constraints) { |
| 95 // Check for the Tab Capture-specific video constraint for enabling |
| 96 // automatic resolution/rate throttling mode in the capture pipeline. See |
| 97 // implementation comments for content::WebContentsVideoCaptureDevice. |
| 98 base::DictionaryValue& props = |
| 99 options->video_constraints->mandatory.additional_properties; |
| 100 if (!props.GetBooleanWithoutPathExpansion( |
| 101 kEnableAutoThrottlingKey, &enable_auto_throttling)) { |
| 102 enable_auto_throttling = false; |
| 103 } |
| 104 // Remove the key from the properties to avoid an "unrecognized |
| 105 // constraint" error in the renderer. |
| 106 props.RemoveWithoutPathExpansion(kEnableAutoThrottlingKey, nullptr); |
| 107 } else { |
| 108 options->video_constraints.reset(new MediaStreamConstraint); |
| 109 } |
| 110 constraints_to_modify[1] = options->video_constraints.get(); |
| 111 } |
| 112 |
| 113 // Format the device ID that references the target tab. |
| 114 content::RenderFrameHost* const main_frame = target_contents->GetMainFrame(); |
| 115 // TODO(miu): We should instead use a "randomly generated device ID" scheme, |
| 116 // like that employed by the desktop capture API. http://crbug.com/163100 |
| 117 const std::string device_id = base::StringPrintf( |
| 118 "web-contents-media-stream://%i:%i%s", |
| 119 main_frame->GetProcess()->GetID(), |
| 120 main_frame->GetRoutingID(), |
| 121 enable_auto_throttling ? "?throttling=auto" : ""); |
| 122 |
| 123 // Append chrome specific tab constraints. |
| 124 for (MediaStreamConstraint* msc : constraints_to_modify) { |
| 125 if (!msc) |
| 126 continue; |
| 127 base::DictionaryValue* constraint = &msc->mandatory.additional_properties; |
| 128 constraint->SetString(kMediaStreamSource, kMediaStreamSourceTab); |
| 129 constraint->SetString(kMediaStreamSourceId, device_id); |
| 130 } |
| 131 } |
| 132 |
55 } // namespace | 133 } // namespace |
56 | 134 |
57 // Whitelisted extensions that do not check for a browser action grant because | 135 // Whitelisted extensions that do not check for a browser action grant because |
58 // they provide API's. If there are additional extension ids that need | 136 // they provide API's. If there are additional extension ids that need |
59 // whitelisting and are *not* the Chromecast extension, add them to a new | 137 // whitelisting and are *not* the Chromecast extension, add them to a new |
60 // kWhitelist array. | 138 // kWhitelist array. |
61 // | 139 // |
62 // This list is also used by CastConfigDelegateChromeos to find official Cast | 140 // This list is also used by CastConfigDelegateChromeos to find official Cast |
63 // extensions. | 141 // extensions. |
64 const char* const kChromecastExtensionIds[] = { | 142 const char* const kChromecastExtensionIds[] = { |
65 "enhhojjnijigcajfphajepfemndkmdlo", // Dev | 143 "enhhojjnijigcajfphajepfemndkmdlo", // Dev |
66 "fmfcbgogabcbclcofgocippekhfcmgfj", // Staging | 144 "fmfcbgogabcbclcofgocippekhfcmgfj", // Staging |
67 "hfaagokkkhdbgiakmmlclaapfelnkoah", // Canary | 145 "hfaagokkkhdbgiakmmlclaapfelnkoah", // Canary |
68 "dliochdbjfkdbacpmhlcpmleaejidimm", // Google Cast Beta | 146 "dliochdbjfkdbacpmhlcpmleaejidimm", // Google Cast Beta |
69 "boadgeojelhgndaghljhdicfkmllpafd", // Google Cast Stable | 147 "boadgeojelhgndaghljhdicfkmllpafd", // Google Cast Stable |
70 "hlgmmjhlnlapooncikdpiiokdjcdpjme", // Test cast extension | 148 "hlgmmjhlnlapooncikdpiiokdjcdpjme", // Test cast extension |
71 }; | 149 }; |
72 | 150 |
73 const char* const kMediaRouterExtensionIds[] = { | 151 const char* const kMediaRouterExtensionIds[] = { |
74 "fjhoaacokmgbjemoflkofnenfaiekifl", // Stable | 152 "fjhoaacokmgbjemoflkofnenfaiekifl", // Stable |
75 "ekpaaapppgpmolpcldedioblbkmijaca", // Beta | 153 "ekpaaapppgpmolpcldedioblbkmijaca", // Beta |
76 }; | 154 }; |
77 | 155 |
78 bool TabCaptureCaptureFunction::RunSync() { | 156 bool TabCaptureCaptureFunction::RunSync() { |
79 scoped_ptr<api::tab_capture::Capture::Params> params = | 157 scoped_ptr<api::tab_capture::Capture::Params> params = |
80 TabCapture::Capture::Params::Create(*args_); | 158 TabCapture::Capture::Params::Create(*args_); |
81 EXTENSION_FUNCTION_VALIDATE(params.get()); | 159 EXTENSION_FUNCTION_VALIDATE(params); |
82 | 160 |
83 // Figure out the active WebContents and retrieve the needed ids. | 161 // Figure out the active WebContents and retrieve the needed ids. |
84 Browser* target_browser = chrome::FindAnyBrowser( | 162 Browser* target_browser = chrome::FindAnyBrowser( |
85 GetProfile(), include_incognito(), chrome::GetActiveDesktop()); | 163 GetProfile(), include_incognito(), chrome::GetActiveDesktop()); |
86 if (!target_browser) { | 164 if (!target_browser) { |
87 error_ = kFindingTabError; | 165 error_ = kFindingTabError; |
88 return false; | 166 return false; |
89 } | 167 } |
90 | 168 |
91 content::WebContents* target_contents = | 169 content::WebContents* target_contents = |
(...skipping 13 matching lines...) Expand all Loading... |
105 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 183 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
106 switches::kWhitelistedExtensionID) != extension_id && | 184 switches::kWhitelistedExtensionID) != extension_id && |
107 !SimpleFeature::IsIdInArray(extension_id, kChromecastExtensionIds, | 185 !SimpleFeature::IsIdInArray(extension_id, kChromecastExtensionIds, |
108 arraysize(kChromecastExtensionIds)) && | 186 arraysize(kChromecastExtensionIds)) && |
109 !SimpleFeature::IsIdInArray(extension_id, kMediaRouterExtensionIds, | 187 !SimpleFeature::IsIdInArray(extension_id, kMediaRouterExtensionIds, |
110 arraysize(kMediaRouterExtensionIds))) { | 188 arraysize(kMediaRouterExtensionIds))) { |
111 error_ = kGrantError; | 189 error_ = kGrantError; |
112 return false; | 190 return false; |
113 } | 191 } |
114 | 192 |
115 // Create a constraints vector. We will modify all the constraints in this | 193 if (!OptionsSpecifyAudioOrVideo(params->options)) { |
116 // vector to append our chrome specific constraints. | |
117 std::vector<MediaStreamConstraint*> constraints; | |
118 bool has_audio = params->options.audio.get() && *params->options.audio.get(); | |
119 bool has_video = params->options.video.get() && *params->options.video.get(); | |
120 | |
121 if (!has_audio && !has_video) { | |
122 error_ = kNoAudioOrVideo; | 194 error_ = kNoAudioOrVideo; |
123 return false; | 195 return false; |
124 } | 196 } |
125 | 197 |
126 if (has_audio) { | |
127 if (!params->options.audio_constraints.get()) | |
128 params->options.audio_constraints.reset(new MediaStreamConstraint); | |
129 | |
130 constraints.push_back(params->options.audio_constraints.get()); | |
131 } | |
132 | |
133 bool enable_auto_throttling = false; | |
134 if (has_video) { | |
135 if (params->options.video_constraints.get()) { | |
136 // Check for the Tab Capture-specific video constraint for enabling | |
137 // automatic resolution/rate throttling mode in the capture pipeline. See | |
138 // implementation comments for content::WebContentsVideoCaptureDevice. | |
139 base::DictionaryValue& props = | |
140 params->options.video_constraints->mandatory.additional_properties; | |
141 if (!props.GetBooleanWithoutPathExpansion( | |
142 kEnableAutoThrottlingKey, &enable_auto_throttling)) { | |
143 enable_auto_throttling = false; | |
144 } | |
145 // Remove the key from the properties to avoid an "unrecognized | |
146 // constraint" error in the renderer. | |
147 props.RemoveWithoutPathExpansion(kEnableAutoThrottlingKey, nullptr); | |
148 } else { | |
149 params->options.video_constraints.reset(new MediaStreamConstraint); | |
150 } | |
151 | |
152 constraints.push_back(params->options.video_constraints.get()); | |
153 } | |
154 | |
155 // Device id we use for Tab Capture. | |
156 content::RenderFrameHost* const main_frame = target_contents->GetMainFrame(); | |
157 // TODO(miu): We should instead use a "randomly generated device ID" scheme, | |
158 // like that employed by the desktop capture API. http://crbug.com/163100 | |
159 const std::string device_id = base::StringPrintf( | |
160 "web-contents-media-stream://%i:%i%s", | |
161 main_frame->GetProcess()->GetID(), | |
162 main_frame->GetRoutingID(), | |
163 enable_auto_throttling ? "?throttling=auto" : ""); | |
164 | |
165 // Append chrome specific tab constraints. | |
166 for (std::vector<MediaStreamConstraint*>::iterator it = constraints.begin(); | |
167 it != constraints.end(); ++it) { | |
168 base::DictionaryValue* constraint = &(*it)->mandatory.additional_properties; | |
169 constraint->SetString(kMediaStreamSource, kMediaStreamSourceTab); | |
170 constraint->SetString(kMediaStreamSourceId, device_id); | |
171 } | |
172 | |
173 TabCaptureRegistry* registry = TabCaptureRegistry::Get(GetProfile()); | 198 TabCaptureRegistry* registry = TabCaptureRegistry::Get(GetProfile()); |
174 if (!registry->AddRequest(target_contents, extension_id)) { | 199 if (!registry->AddRequest(target_contents, extension_id, false)) { |
| 200 // TODO(miu): Allow multiple consumers of single tab capture. |
| 201 // http://crbug.com/535336 |
175 error_ = kCapturingSameTab; | 202 error_ = kCapturingSameTab; |
176 return false; | 203 return false; |
177 } | 204 } |
| 205 AddMediaStreamSourceConstraints(target_contents, ¶ms->options); |
178 | 206 |
179 // Copy the result from our modified input parameters. This will be | 207 // At this point, everything is set up in the browser process. It's now up to |
180 // intercepted by custom bindings which will build and send the special | 208 // the custom JS bindings in the extension's render process to request a |
181 // WebRTC user media request. | 209 // MediaStream using navigator.webkitGetUserMedia(). The result dictionary, |
| 210 // passed to SetResult() here, contains the extra "hidden options" that will |
| 211 // allow the Chrome platform implementation for getUserMedia() to start the |
| 212 // virtual audio/video capture devices and set up all the data flows. The |
| 213 // custom JS bindings can be found here: |
| 214 // chrome/renderer/resources/extensions/tab_capture_custom_bindings.js |
182 base::DictionaryValue* result = new base::DictionaryValue(); | 215 base::DictionaryValue* result = new base::DictionaryValue(); |
183 result->MergeDictionary(params->options.ToValue().get()); | 216 result->MergeDictionary(params->options.ToValue().get()); |
184 | |
185 SetResult(result); | 217 SetResult(result); |
186 return true; | 218 return true; |
187 } | 219 } |
188 | 220 |
189 bool TabCaptureGetCapturedTabsFunction::RunSync() { | 221 bool TabCaptureGetCapturedTabsFunction::RunSync() { |
190 TabCaptureRegistry* registry = TabCaptureRegistry::Get(GetProfile()); | 222 TabCaptureRegistry* registry = TabCaptureRegistry::Get(GetProfile()); |
191 base::ListValue* const list = new base::ListValue(); | 223 base::ListValue* const list = new base::ListValue(); |
192 if (registry) | 224 if (registry) |
193 registry->GetCapturedTabs(extension()->id(), list); | 225 registry->GetCapturedTabs(extension()->id(), list); |
194 SetResult(list); | 226 SetResult(list); |
195 return true; | 227 return true; |
196 } | 228 } |
197 | 229 |
| 230 bool TabCaptureCaptureOffscreenTabFunction::RunSync() { |
| 231 scoped_ptr<TabCapture::CaptureOffscreenTab::Params> params = |
| 232 TabCapture::CaptureOffscreenTab::Params::Create(*args_); |
| 233 EXTENSION_FUNCTION_VALIDATE(params); |
| 234 |
| 235 // Make sure the extension is whitelisted for using this API, regardless of |
| 236 // Chrome channel. |
| 237 // |
| 238 // TODO(miu): Use _api_features.json and extensions::Feature library instead. |
| 239 // http://crbug.com/537732 |
| 240 const bool is_whitelisted_extension = |
| 241 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 242 switches::kWhitelistedExtensionID) == extension()->id() || |
| 243 SimpleFeature::IsIdInArray(extension()->id(), kChromecastExtensionIds, |
| 244 arraysize(kChromecastExtensionIds)) || |
| 245 SimpleFeature::IsIdInArray(extension()->id(), kMediaRouterExtensionIds, |
| 246 arraysize(kMediaRouterExtensionIds)); |
| 247 if (!is_whitelisted_extension) { |
| 248 error_ = kNotWhitelistedForOffscreenTabApi; |
| 249 return false; |
| 250 } |
| 251 |
| 252 const GURL start_url(params->start_url); |
| 253 if (!IsAcceptableOffscreenTabUrl(start_url)) { |
| 254 SetError(kInvalidStartUrl); |
| 255 return false; |
| 256 } |
| 257 |
| 258 if (!OptionsSpecifyAudioOrVideo(params->options)) { |
| 259 SetError(kNoAudioOrVideo); |
| 260 return false; |
| 261 } |
| 262 |
| 263 content::WebContents* const extension_web_contents = GetSenderWebContents(); |
| 264 EXTENSION_FUNCTION_VALIDATE(extension_web_contents); |
| 265 OffscreenPresentation* const offscreen_tab = |
| 266 OffscreenPresentationsOwner::Get(extension_web_contents) |
| 267 ->StartPresentation( |
| 268 start_url, |
| 269 (is_whitelisted_extension && params->options.presentation_id) ? |
| 270 *params->options.presentation_id : std::string(), |
| 271 DetermineInitialSize(params->options)); |
| 272 if (!offscreen_tab) { |
| 273 SetError(kTooManyOffscreenTabs); |
| 274 return false; |
| 275 } |
| 276 |
| 277 if (!TabCaptureRegistry::Get(browser_context())->AddRequest( |
| 278 offscreen_tab->web_contents(), extension()->id(), true)) { |
| 279 // TODO(miu): Allow multiple consumers of single tab capture. |
| 280 // http://crbug.com/535336 |
| 281 SetError(kCapturingSameOffscreenTab); |
| 282 return false; |
| 283 } |
| 284 AddMediaStreamSourceConstraints(offscreen_tab->web_contents(), |
| 285 ¶ms->options); |
| 286 |
| 287 // At this point, everything is set up in the browser process. It's now up to |
| 288 // the custom JS bindings in the extension's render process to complete the |
| 289 // request. See the comment at end of TabCaptureCaptureFunction::RunSync() |
| 290 // for more details. |
| 291 base::DictionaryValue* const result = new base::DictionaryValue(); |
| 292 result->MergeDictionary(params->options.ToValue().get()); |
| 293 SetResult(result); |
| 294 return true; |
| 295 } |
| 296 |
| 297 // static |
| 298 gfx::Size TabCaptureCaptureOffscreenTabFunction::DetermineInitialSize( |
| 299 const TabCapture::CaptureOptions& options) { |
| 300 static const int kDefaultWidth = 1280; |
| 301 static const int kDefaultHeight = 720; |
| 302 |
| 303 if (!options.video_constraints) |
| 304 return gfx::Size(kDefaultWidth, kDefaultHeight); |
| 305 |
| 306 gfx::Size min_size; |
| 307 int width = -1; |
| 308 int height = -1; |
| 309 const base::DictionaryValue& mandatory_properties = |
| 310 options.video_constraints->mandatory.additional_properties; |
| 311 if (mandatory_properties.GetInteger("maxWidth", &width) && width >= 0 && |
| 312 mandatory_properties.GetInteger("maxHeight", &height) && height >= 0) { |
| 313 return gfx::Size(width, height); |
| 314 } |
| 315 if (mandatory_properties.GetInteger("minWidth", &width) && width >= 0 && |
| 316 mandatory_properties.GetInteger("minHeight", &height) && height >= 0) { |
| 317 min_size.SetSize(width, height); |
| 318 } |
| 319 |
| 320 // Use optional size constraints if no mandatory ones were provided. |
| 321 if (options.video_constraints->optional) { |
| 322 const base::DictionaryValue& optional_properties = |
| 323 options.video_constraints->optional->additional_properties; |
| 324 if (optional_properties.GetInteger("maxWidth", &width) && width >= 0 && |
| 325 optional_properties.GetInteger("maxHeight", &height) && height >= 0) { |
| 326 if (min_size.IsEmpty()) { |
| 327 return gfx::Size(width, height); |
| 328 } else { |
| 329 return gfx::Size(std::max(width, min_size.width()), |
| 330 std::max(height, min_size.height())); |
| 331 } |
| 332 } |
| 333 if (min_size.IsEmpty() && |
| 334 optional_properties.GetInteger("minWidth", &width) && width >= 0 && |
| 335 optional_properties.GetInteger("minHeight", &height) && height >= 0) { |
| 336 min_size.SetSize(width, height); |
| 337 } |
| 338 } |
| 339 |
| 340 // No maximum size was provided, so just return the default size bounded by |
| 341 // the minimum size. |
| 342 return gfx::Size(std::max(kDefaultWidth, min_size.width()), |
| 343 std::max(kDefaultHeight, min_size.height())); |
| 344 } |
| 345 |
198 } // namespace extensions | 346 } // namespace extensions |
OLD | NEW |