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