| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/extensions/api/tabs/ash_panel_contents.h" | |
| 6 | |
| 7 #include "base/values.h" | |
| 8 #include "chrome/browser/chrome_notification_types.h" | |
| 9 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | |
| 10 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" | |
| 11 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" | |
| 12 #include "chrome/browser/extensions/extension_tab_util.h" | |
| 13 #include "chrome/browser/extensions/window_controller_list.h" | |
| 14 #include "chrome/browser/profiles/profile.h" | |
| 15 #include "chrome/browser/sessions/session_tab_helper.h" | |
| 16 #include "content/public/browser/browser_context.h" | |
| 17 #include "content/public/browser/render_frame_host.h" | |
| 18 #include "content/public/browser/render_process_host.h" | |
| 19 #include "content/public/browser/site_instance.h" | |
| 20 #include "content/public/browser/web_contents.h" | |
| 21 #include "extensions/browser/app_window/native_app_window.h" | |
| 22 #include "extensions/common/extension.h" | |
| 23 #include "extensions/common/permissions/api_permission.h" | |
| 24 #include "extensions/common/permissions/permissions_data.h" | |
| 25 #include "ui/gfx/image/image.h" | |
| 26 | |
| 27 using extensions::AppWindow; | |
| 28 using extensions::NativeAppWindow; | |
| 29 | |
| 30 // AshPanelContents ----------------------------------------------------- | |
| 31 | |
| 32 AshPanelContents::AshPanelContents(AppWindow* host) : host_(host) {} | |
| 33 | |
| 34 AshPanelContents::~AshPanelContents() { | |
| 35 } | |
| 36 | |
| 37 void AshPanelContents::Initialize(content::BrowserContext* context, | |
| 38 content::RenderFrameHost* creator_frame, | |
| 39 const GURL& url) { | |
| 40 url_ = url; | |
| 41 | |
| 42 content::WebContents::CreateParams create_params( | |
| 43 context, creator_frame->GetSiteInstance()); | |
| 44 create_params.opener_render_process_id = creator_frame->GetProcess()->GetID(); | |
| 45 create_params.opener_render_frame_id = creator_frame->GetRoutingID(); | |
| 46 web_contents_.reset(content::WebContents::Create(create_params)); | |
| 47 | |
| 48 // Needed to give the web contents a Window ID. Extension APIs expect web | |
| 49 // contents to have a Window ID. Also required for FaviconDriver to correctly | |
| 50 // set the window icon and title. | |
| 51 SessionTabHelper::CreateForWebContents(web_contents_.get()); | |
| 52 SessionTabHelper::FromWebContents(web_contents_.get())->SetWindowID( | |
| 53 host_->session_id()); | |
| 54 | |
| 55 // Responsible for loading favicons for the Launcher, which uses different | |
| 56 // logic than the FaviconDriver associated with web_contents_ (instantiated in | |
| 57 // AppWindow::Init()) | |
| 58 launcher_favicon_loader_.reset( | |
| 59 new LauncherFaviconLoader(this, web_contents_.get())); | |
| 60 } | |
| 61 | |
| 62 void AshPanelContents::LoadContents(int32_t creator_process_id) { | |
| 63 web_contents_->GetController().LoadURL( | |
| 64 url_, content::Referrer(), ui::PAGE_TRANSITION_LINK, | |
| 65 std::string()); | |
| 66 } | |
| 67 | |
| 68 void AshPanelContents::NativeWindowChanged(NativeAppWindow* native_app_window) { | |
| 69 } | |
| 70 | |
| 71 void AshPanelContents::NativeWindowClosed() { | |
| 72 } | |
| 73 | |
| 74 void AshPanelContents::OnWindowReady() {} | |
| 75 | |
| 76 content::WebContents* AshPanelContents::GetWebContents() const { | |
| 77 return web_contents_.get(); | |
| 78 } | |
| 79 | |
| 80 extensions::WindowController* AshPanelContents::GetWindowController() const { | |
| 81 return nullptr; | |
| 82 } | |
| 83 | |
| 84 void AshPanelContents::FaviconUpdated() { | |
| 85 gfx::Image new_image = gfx::Image::CreateFrom1xBitmap( | |
| 86 launcher_favicon_loader_->GetFavicon()); | |
| 87 host_->UpdateAppIcon(new_image); | |
| 88 } | |
| OLD | NEW |