| Index: chrome/browser/extensions/extension_tabs_module.cc
|
| diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
|
| index db84232f53ebdd463e653f29ca35634c87ebf1f0..0745370d920e47a83d726110ba536bfb2ad2f9ad 100644
|
| --- a/chrome/browser/extensions/extension_tabs_module.cc
|
| +++ b/chrome/browser/extensions/extension_tabs_module.cc
|
| @@ -953,6 +953,98 @@ bool RemoveTabFunction::RunImpl() {
|
| return true;
|
| }
|
|
|
| +bool SetZoomPercentTabFunction::RunImpl() {
|
| + int tab_id;
|
| + EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id));
|
| +
|
| + double zoom_percent = 0;
|
| + if (!args_->GetDouble(1, &zoom_percent)) {
|
| + int int_zoom_percent = 0;
|
| + if (!args_->GetInteger(1, &int_zoom_percent)) {
|
| + bad_message_ = true;
|
| + return false;
|
| + }
|
| + zoom_percent = int_zoom_percent;
|
| + }
|
| +
|
| + // WebKit won't like a negative zoom factor
|
| + if (zoom_percent < 0) {
|
| + return false;
|
| + }
|
| +
|
| + Browser* browser = NULL;
|
| + TabContentsWrapper* contents = NULL;
|
| + if (!GetTabById(tab_id, profile(), include_incognito(),
|
| + &browser, NULL, &contents, NULL, &error_)) {
|
| + return false;
|
| + }
|
| +
|
| + // Store the tab id for later
|
| + tab_id_ = tab_id;
|
| +
|
| + request_id_ = contents->tab_contents()->SetZoomPercent(zoom_percent);
|
| +
|
| + // Need to wait until the render process responds to the request
|
| + // before we can respond to the extension request.
|
| + registrar_.Add(this,
|
| + NotificationType::ZOOM_LEVEL_CHANGED,
|
| + NotificationService::AllSources());
|
| + AddRef(); // Balanced in SetZoomPercentTabFunction::Observe().
|
| +
|
| + return true;
|
| +}
|
| +
|
| +void SetZoomPercentTabFunction::Observe(NotificationType type,
|
| + const NotificationSource& source,
|
| + const NotificationDetails& details) {
|
| + DCHECK(type == NotificationType::ZOOM_LEVEL_CHANGED);
|
| +
|
| + // Wait for our specific request
|
| + int observed_request_id = *Details<int>(details).ptr();
|
| + if (observed_request_id != request_id_) {
|
| + return;
|
| + }
|
| +
|
| + registrar_.RemoveAll();
|
| +
|
| + Browser* browser = NULL;
|
| + TabContentsWrapper* contents = NULL;
|
| + if (!GetTabById(tab_id_, profile(), include_incognito(),
|
| + &browser, NULL, &contents, NULL, &error_)) {
|
| + Release(); // Balanced in SetZoomPercentTabFunction::RunImpl
|
| + return;
|
| + }
|
| +
|
| + bool enable_inc_ignored;
|
| + bool enable_dec_ignored;
|
| + double zoom_percent = contents->tab_contents()->GetZoomPercent(
|
| + &enable_inc_ignored, &enable_dec_ignored);
|
| +
|
| + result_.reset(Value::CreateDoubleValue(zoom_percent));
|
| + SendResponse(true);
|
| + Release(); // Balanced in SetZoomPercentTabFunction::RunImpl
|
| +}
|
| +
|
| +bool GetZoomPercentTabFunction::RunImpl() {
|
| + int tab_id;
|
| + EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id));
|
| +
|
| + Browser* browser = NULL;
|
| + TabContentsWrapper* contents = NULL;
|
| + if (!GetTabById(tab_id, profile(), include_incognito(),
|
| + &browser, NULL, &contents, NULL, &error_)) {
|
| + return false;
|
| + }
|
| +
|
| + bool enable_inc_ignored;
|
| + bool enable_dec_ignored;
|
| + double zoom_percent = contents->tab_contents()->GetZoomPercent(
|
| + &enable_inc_ignored, &enable_dec_ignored);
|
| +
|
| + result_.reset(Value::CreateDoubleValue(zoom_percent));
|
| + return true;
|
| +}
|
| +
|
| bool CaptureVisibleTabFunction::RunImpl() {
|
| Browser* browser;
|
| // windowId defaults to "current" window.
|
|
|