Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Unified Diff: chrome/browser/sidebar/sidebar_container.cc

Issue 9006027: Rip Out the Sidebar API (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sidebar/sidebar_container.h ('k') | chrome/browser/sidebar/sidebar_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sidebar/sidebar_container.cc
===================================================================
--- chrome/browser/sidebar/sidebar_container.cc (revision 116830)
+++ chrome/browser/sidebar/sidebar_container.cc (working copy)
@@ -1,131 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/sidebar/sidebar_container.h"
-
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h"
-#include "chrome/common/extensions/extension.h"
-#include "chrome/common/extensions/extension_resource.h"
-#include "chrome/common/extensions/extension_sidebar_defaults.h"
-#include "chrome/common/extensions/extension_sidebar_utils.h"
-#include "content/browser/renderer_host/render_view_host.h"
-#include "content/browser/tab_contents/tab_contents.h"
-#include "content/browser/tab_contents/tab_contents_view.h"
-#include "content/public/browser/navigation_controller.h"
-#include "content/public/browser/render_process_host.h"
-#include "googleurl/src/gurl.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-
-SidebarContainer::SidebarContainer(TabContents* tab,
- const std::string& content_id,
- Delegate* delegate)
- : tab_(tab),
- content_id_(content_id),
- delegate_(delegate),
- icon_(new SkBitmap),
- navigate_to_default_page_on_expand_(true),
- use_default_icon_(true) {
- // Create TabContents for sidebar.
- sidebar_contents_.reset(
- new TabContents(Profile::FromBrowserContext(tab->GetBrowserContext()),
- NULL, MSG_ROUTING_NONE, NULL, NULL));
- sidebar_contents_->SetDelegate(this);
-}
-
-SidebarContainer::~SidebarContainer() {
-}
-
-void SidebarContainer::SidebarClosing() {
- delegate_->UpdateSidebar(this);
-}
-
-void SidebarContainer::LoadDefaults() {
- const Extension* extension = GetExtension();
- if (!extension)
- return; // Can be NULL in tests.
- const ExtensionSidebarDefaults* sidebar_defaults =
- extension->sidebar_defaults();
-
- title_ = sidebar_defaults->default_title();
-
- if (!sidebar_defaults->default_icon_path().empty()) {
- image_loading_tracker_.reset(new ImageLoadingTracker(this));
- image_loading_tracker_->LoadImage(
- extension,
- extension->GetResource(sidebar_defaults->default_icon_path()),
- gfx::Size(Extension::kSidebarIconMaxSize,
- Extension::kSidebarIconMaxSize),
- ImageLoadingTracker::CACHE);
- }
-}
-
-void SidebarContainer::Show() {
- delegate_->UpdateSidebar(this);
-}
-
-void SidebarContainer::Expand() {
- if (navigate_to_default_page_on_expand_) {
- navigate_to_default_page_on_expand_ = false;
- // Check whether a default page is specified for this sidebar.
- const Extension* extension = GetExtension();
- if (extension) { // Can be NULL in tests.
- if (extension->sidebar_defaults()->default_page().is_valid())
- Navigate(extension->sidebar_defaults()->default_page());
- }
- }
-
- delegate_->UpdateSidebar(this);
- sidebar_contents_->GetView()->SetInitialFocus();
-}
-
-void SidebarContainer::Collapse() {
- delegate_->UpdateSidebar(this);
-}
-
-void SidebarContainer::Navigate(const GURL& url) {
- // TODO(alekseys): add a progress UI.
- navigate_to_default_page_on_expand_ = false;
- sidebar_contents_->GetController().LoadURL(
- url, content::Referrer(), content::PAGE_TRANSITION_START_PAGE,
- std::string());
-}
-
-void SidebarContainer::SetBadgeText(const string16& badge_text) {
- badge_text_ = badge_text;
-}
-
-void SidebarContainer::SetIcon(const SkBitmap& bitmap) {
- use_default_icon_ = false;
- *icon_ = bitmap;
-}
-
-void SidebarContainer::SetTitle(const string16& title) {
- title_ = title;
-}
-
-content::JavaScriptDialogCreator*
-SidebarContainer::GetJavaScriptDialogCreator() {
- return GetJavaScriptDialogCreatorInstance();
-}
-
-void SidebarContainer::OnImageLoaded(SkBitmap* image,
- const ExtensionResource& resource,
- int index) {
- if (image && use_default_icon_) {
- *icon_ = *image;
- delegate_->UpdateSidebar(this);
- }
-}
-
-const Extension* SidebarContainer::GetExtension() const {
- Profile* profile =
- Profile::FromBrowserContext(sidebar_contents_->GetBrowserContext());
- ExtensionService* service = profile->GetExtensionService();
- if (!service)
- return NULL;
- return service->GetExtensionById(
- extension_sidebar_utils::GetExtensionIdByContentId(content_id_), false);
-}
« no previous file with comments | « chrome/browser/sidebar/sidebar_container.h ('k') | chrome/browser/sidebar/sidebar_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698