| 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 #include "chrome/browser/extensions/extension_tabs_module.h" | 5 #include "chrome/browser/extensions/extension_tabs_module.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "chrome/common/pref_names.h" | 51 #include "chrome/common/pref_names.h" |
| 52 #include "chrome/common/url_constants.h" | 52 #include "chrome/common/url_constants.h" |
| 53 #include "content/public/browser/navigation_controller.h" | 53 #include "content/public/browser/navigation_controller.h" |
| 54 #include "content/public/browser/navigation_entry.h" | 54 #include "content/public/browser/navigation_entry.h" |
| 55 #include "content/public/browser/notification_details.h" | 55 #include "content/public/browser/notification_details.h" |
| 56 #include "content/public/browser/notification_source.h" | 56 #include "content/public/browser/notification_source.h" |
| 57 #include "content/public/browser/render_view_host.h" | 57 #include "content/public/browser/render_view_host.h" |
| 58 #include "content/public/browser/render_view_host_delegate.h" | 58 #include "content/public/browser/render_view_host_delegate.h" |
| 59 #include "content/public/browser/web_contents.h" | 59 #include "content/public/browser/web_contents.h" |
| 60 #include "content/public/browser/web_contents_view.h" | 60 #include "content/public/browser/web_contents_view.h" |
| 61 #include "content/public/common/url_constants.h" |
| 61 #include "skia/ext/image_operations.h" | 62 #include "skia/ext/image_operations.h" |
| 62 #include "skia/ext/platform_canvas.h" | 63 #include "skia/ext/platform_canvas.h" |
| 63 #include "third_party/skia/include/core/SkBitmap.h" | 64 #include "third_party/skia/include/core/SkBitmap.h" |
| 64 #include "ui/base/ui_base_types.h" | 65 #include "ui/base/ui_base_types.h" |
| 65 #include "ui/gfx/codec/jpeg_codec.h" | 66 #include "ui/gfx/codec/jpeg_codec.h" |
| 66 #include "ui/gfx/codec/png_codec.h" | 67 #include "ui/gfx/codec/png_codec.h" |
| 67 | 68 |
| 68 #if defined(USE_ASH) | 69 #if defined(USE_ASH) |
| 69 #include "ash/ash_switches.h" | 70 #include "ash/ash_switches.h" |
| 70 #include "base/command_line.h" | 71 #include "base/command_line.h" |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 contents = source_tab_strip->DetachTabContentsAt(tab_index); | 454 contents = source_tab_strip->DetachTabContentsAt(tab_index); |
| 454 if (!contents) { | 455 if (!contents) { |
| 455 error_ = ExtensionErrorUtils::FormatErrorMessage( | 456 error_ = ExtensionErrorUtils::FormatErrorMessage( |
| 456 keys::kTabNotFoundError, base::IntToString(tab_id)); | 457 keys::kTabNotFoundError, base::IntToString(tab_id)); |
| 457 return false; | 458 return false; |
| 458 } | 459 } |
| 459 } | 460 } |
| 460 } | 461 } |
| 461 | 462 |
| 462 // Try to position the new browser relative its originating browser window. | 463 // Try to position the new browser relative its originating browser window. |
| 463 gfx::Rect window_bounds; | 464 gfx::Rect window_bounds; |
| 464 // The call offsets the bounds by kWindowTilePixels (defined in WindowSizer to | 465 // The call offsets the bounds by kWindowTilePixels (defined in WindowSizer to |
| 465 // be 10) | 466 // be 10) |
| 466 // | 467 // |
| 467 // NOTE(rafaelw): It's ok if GetCurrentBrowser() returns NULL here. | 468 // NOTE(rafaelw): It's ok if GetCurrentBrowser() returns NULL here. |
| 468 // GetBrowserWindowBounds will default to saved "default" values for the app. | 469 // GetBrowserWindowBounds will default to saved "default" values for the app. |
| 469 WindowSizer::GetBrowserWindowBounds(std::string(), gfx::Rect(), | 470 WindowSizer::GetBrowserWindowBounds(std::string(), gfx::Rect(), |
| 470 GetCurrentBrowser(), &window_bounds); | 471 GetCurrentBrowser(), &window_bounds); |
| 471 | 472 |
| 472 // Calculate popup and panels bounds separately. | 473 // Calculate popup and panels bounds separately. |
| 473 gfx::Rect popup_bounds; | 474 gfx::Rect popup_bounds; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 if (CommandLine::ForCurrentProcess()->HasSwitch( | 559 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 559 ash::switches::kAuraPanelManager)) | 560 ash::switches::kAuraPanelManager)) |
| 560 use_panels = true; | 561 use_panels = true; |
| 561 #endif | 562 #endif |
| 562 if (use_panels) | 563 if (use_panels) |
| 563 window_type = Browser::TYPE_PANEL; | 564 window_type = Browser::TYPE_PANEL; |
| 564 else | 565 else |
| 565 window_type = Browser::TYPE_POPUP; | 566 window_type = Browser::TYPE_POPUP; |
| 566 } else if (type_str == keys::kWindowTypeValueShell && | 567 } else if (type_str == keys::kWindowTypeValueShell && |
| 567 GetExtension()->is_platform_app()) { | 568 GetExtension()->is_platform_app()) { |
| 568 GURL window_url = | 569 GURL window_url = urls.empty() ? GURL(chrome::kAboutBlankURL) : urls[0]; |
| 569 urls.empty() ? GetExtension()->GetFullLaunchURL() : urls[0]; | |
| 570 ShellWindow* shell_window = | 570 ShellWindow* shell_window = |
| 571 ShellWindow::Create(window_profile, GetExtension(), window_url); | 571 ShellWindow::Create(window_profile, GetExtension(), window_url); |
| 572 // TODO(mihaip): It might be less janky to pass in the desired bounds |
| 573 // into ShellWindow::Create directly. |
| 574 shell_window->SetBounds(window_bounds); |
| 572 result_.reset(shell_window->extension_window_controller()-> | 575 result_.reset(shell_window->extension_window_controller()-> |
| 573 CreateWindowValueWithTabs()); | 576 CreateWindowValueWithTabs()); |
| 574 return true; | 577 return true; |
| 575 } else if (type_str != keys::kWindowTypeValueNormal) { | 578 } else if (type_str != keys::kWindowTypeValueNormal) { |
| 576 error_ = keys::kInvalidWindowTypeError; | 579 error_ = keys::kInvalidWindowTypeError; |
| 577 return false; | 580 return false; |
| 578 } | 581 } |
| 579 } | 582 } |
| 580 } | 583 } |
| 581 | 584 |
| (...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1822 // called for every API call the extension made. | 1825 // called for every API call the extension made. |
| 1823 GotLanguage(language); | 1826 GotLanguage(language); |
| 1824 } | 1827 } |
| 1825 | 1828 |
| 1826 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1829 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
| 1827 result_.reset(Value::CreateStringValue(language.c_str())); | 1830 result_.reset(Value::CreateStringValue(language.c_str())); |
| 1828 SendResponse(true); | 1831 SendResponse(true); |
| 1829 | 1832 |
| 1830 Release(); // Balanced in Run() | 1833 Release(); // Balanced in Run() |
| 1831 } | 1834 } |
| OLD | NEW |