Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / extensions / api / tabs / ash_panel_contents.cc
blobac891e49e9d7eee87f9dbe7becac729d224fac7a
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.
5 #include "chrome/browser/extensions/api/tabs/ash_panel_contents.h"
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/site_instance.h"
18 #include "content/public/browser/web_contents.h"
19 #include "extensions/browser/app_window/native_app_window.h"
20 #include "extensions/common/extension.h"
21 #include "extensions/common/permissions/api_permission.h"
22 #include "extensions/common/permissions/permissions_data.h"
23 #include "ui/gfx/image/image.h"
25 using extensions::AppWindow;
26 using extensions::NativeAppWindow;
28 // AshPanelContents -----------------------------------------------------
30 AshPanelContents::AshPanelContents(AppWindow* host) : host_(host) {}
32 AshPanelContents::~AshPanelContents() {
35 void AshPanelContents::Initialize(content::BrowserContext* context,
36 const GURL& url) {
37 url_ = url;
39 web_contents_.reset(
40 content::WebContents::Create(content::WebContents::CreateParams(
41 context, content::SiteInstance::CreateForURL(context, url_))));
43 // Needed to give the web contents a Window ID. Extension APIs expect web
44 // contents to have a Window ID. Also required for FaviconDriver to correctly
45 // set the window icon and title.
46 SessionTabHelper::CreateForWebContents(web_contents_.get());
47 SessionTabHelper::FromWebContents(web_contents_.get())->SetWindowID(
48 host_->session_id());
50 // Responsible for loading favicons for the Launcher, which uses different
51 // logic than the FaviconDriver associated with web_contents_ (instantiated in
52 // AppWindow::Init())
53 launcher_favicon_loader_.reset(
54 new LauncherFaviconLoader(this, web_contents_.get()));
57 void AshPanelContents::LoadContents(int32 creator_process_id) {
58 web_contents_->GetController().LoadURL(
59 url_, content::Referrer(), ui::PAGE_TRANSITION_LINK,
60 std::string());
63 void AshPanelContents::NativeWindowChanged(NativeAppWindow* native_app_window) {
66 void AshPanelContents::NativeWindowClosed() {
69 void AshPanelContents::DispatchWindowShownForTests() const {
72 void AshPanelContents::OnWindowReady() {}
74 content::WebContents* AshPanelContents::GetWebContents() const {
75 return web_contents_.get();
78 extensions::WindowController* AshPanelContents::GetWindowController() const {
79 return nullptr;
82 void AshPanelContents::FaviconUpdated() {
83 gfx::Image new_image = gfx::Image::CreateFrom1xBitmap(
84 launcher_favicon_loader_->GetFavicon());
85 host_->UpdateAppIcon(new_image);