Index: athena/extensions/athena_app_delegate_base.cc |
diff --git a/athena/extensions/chrome/athena_app_delegate.cc b/athena/extensions/athena_app_delegate_base.cc |
similarity index 32% |
copy from athena/extensions/chrome/athena_app_delegate.cc |
copy to athena/extensions/athena_app_delegate_base.cc |
index 1046cc756584b9315017305c4e8e470f96933384..b3e2458c1aa5e0578fe10b27124eba091b6459a4 100644 |
--- a/athena/extensions/chrome/athena_app_delegate.cc |
+++ b/athena/extensions/athena_app_delegate_base.cc |
@@ -2,52 +2,24 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "athena/extensions/chrome/athena_app_delegate.h" |
+#include "athena/extensions/athena_app_delegate_base.h" |
#include "athena/activity/public/activity_factory.h" |
#include "athena/activity/public/activity_manager.h" |
#include "athena/env/public/athena_env.h" |
-#include "base/memory/scoped_ptr.h" |
-#include "base/strings/stringprintf.h" |
-#include "chrome/browser/chrome_notification_types.h" |
-#include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
-#include "chrome/browser/favicon/favicon_tab_helper.h" |
-#include "chrome/browser/file_select_helper.h" |
-#include "chrome/browser/media/media_capture_devices_dispatcher.h" |
-#include "chrome/browser/platform_util.h" |
-#include "chrome/browser/profiles/profile.h" |
-#include "chrome/browser/shell_integration.h" |
-#include "chrome/browser/ui/browser.h" |
-#include "chrome/browser/ui/browser_dialogs.h" |
-#include "chrome/browser/ui/browser_tabstrip.h" |
-#include "chrome/browser/ui/browser_window.h" |
-#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
-#include "chrome/browser/ui/web_contents_sizer.h" |
-#include "chrome/common/extensions/chrome_extension_messages.h" |
-#include "content/public/browser/browser_context.h" |
-#include "content/public/browser/notification_service.h" |
-#include "content/public/browser/render_view_host.h" |
#include "content/public/browser/web_contents.h" |
#include "content/public/browser/web_contents_delegate.h" |
#include "extensions/common/constants.h" |
#include "extensions/grit/extensions_browser_resources.h" |
+#include "ui/aura/window.h" |
#include "ui/base/resource/resource_bundle.h" |
- |
-#if defined(ENABLE_PRINTING) |
-#if defined(ENABLE_FULL_PRINTING) |
-#include "chrome/browser/printing/print_preview_message_handler.h" |
-#include "chrome/browser/printing/print_view_manager.h" |
-#else |
-#include "chrome/browser/printing/print_view_manager_basic.h" |
-#endif // defined(ENABLE_FULL_PRINTING) |
-#endif // defined(ENABLE_PRINTING) |
+#include "ui/gfx/geometry/rect.h" |
namespace athena { |
namespace { |
-content::WebContents* OpenURLInActivity( |
- content::BrowserContext* context, |
- const content::OpenURLParams& params) { |
+content::WebContents* OpenURLInActivity(content::BrowserContext* context, |
+ const content::OpenURLParams& params) { |
// Force all links to open in a new activity. |
Activity* activity = ActivityFactory::Get()->CreateWebActivity( |
context, base::string16(), params.url); |
@@ -60,11 +32,11 @@ content::WebContents* OpenURLInActivity( |
// This is a extra step to open a new Activity when a link is simply clicked |
// on an app activity (which usually replaces the content). |
-class AthenaAppDelegate::NewWindowContentsDelegate |
+class AthenaAppDelegateBase::NewActivityContentsDelegate |
: public content::WebContentsDelegate { |
public: |
- NewWindowContentsDelegate() {} |
- virtual ~NewWindowContentsDelegate() {} |
+ NewActivityContentsDelegate() {} |
+ virtual ~NewActivityContentsDelegate() {} |
// content::WebContentsDelegate: |
virtual content::WebContents* OpenURLFromTab( |
@@ -72,117 +44,62 @@ class AthenaAppDelegate::NewWindowContentsDelegate |
const content::OpenURLParams& params) OVERRIDE { |
if (!source) |
return NULL; |
- |
return OpenURLInActivity(source->GetBrowserContext(), params); |
} |
private: |
- DISALLOW_COPY_AND_ASSIGN(NewWindowContentsDelegate); |
+ DISALLOW_COPY_AND_ASSIGN(NewActivityContentsDelegate); |
}; |
-AthenaAppDelegate::AthenaAppDelegate() |
- : new_window_contents_delegate_(new NewWindowContentsDelegate()) { |
+AthenaAppDelegateBase::AthenaAppDelegateBase() |
+ : new_window_contents_delegate_(new NewActivityContentsDelegate) { |
} |
-AthenaAppDelegate::~AthenaAppDelegate() { |
+AthenaAppDelegateBase::~AthenaAppDelegateBase() { |
if (!terminating_callback_.is_null()) |
AthenaEnv::Get()->RemoveTerminatingCallback(terminating_callback_); |
} |
-void AthenaAppDelegate::InitWebContents(content::WebContents* web_contents) { |
- FaviconTabHelper::CreateForWebContents(web_contents); |
- |
-#if defined(ENABLE_PRINTING) |
-#if defined(ENABLE_FULL_PRINTING) |
- printing::PrintViewManager::CreateForWebContents(web_contents); |
- printing::PrintPreviewMessageHandler::CreateForWebContents(web_contents); |
-#else |
- printing::PrintViewManagerBasic::CreateForWebContents(web_contents); |
-#endif // defined(ENABLE_FULL_PRINTING) |
-#endif // defined(ENABLE_PRINTING) |
- extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( |
- web_contents); |
-} |
- |
-void AthenaAppDelegate::ResizeWebContents(content::WebContents* web_contents, |
- const gfx::Size& size) { |
- ::ResizeWebContents(web_contents, size); |
+void AthenaAppDelegateBase::ResizeWebContents( |
+ content::WebContents* web_contents, |
+ const gfx::Size& size) { |
+ aura::Window* window = web_contents->GetNativeView(); |
+ window->SetBounds(gfx::Rect(window->bounds().origin(), size)); |
} |
-content::WebContents* AthenaAppDelegate::OpenURLFromTab( |
+content::WebContents* AthenaAppDelegateBase::OpenURLFromTab( |
content::BrowserContext* context, |
content::WebContents* source, |
const content::OpenURLParams& params) { |
return OpenURLInActivity(context, params); |
} |
-void AthenaAppDelegate::AddNewContents(content::BrowserContext* context, |
- content::WebContents* new_contents, |
- WindowOpenDisposition disposition, |
- const gfx::Rect& initial_pos, |
- bool user_gesture, |
- bool* was_blocked) { |
+void AthenaAppDelegateBase::AddNewContents(content::BrowserContext* context, |
+ content::WebContents* new_contents, |
+ WindowOpenDisposition disposition, |
+ const gfx::Rect& initial_pos, |
+ bool user_gesture, |
+ bool* was_blocked) { |
new_contents->SetDelegate(new_window_contents_delegate_.get()); |
} |
-content::ColorChooser* AthenaAppDelegate::ShowColorChooser( |
- content::WebContents* web_contents, |
- SkColor initial_color) { |
- return chrome::ShowColorChooser(web_contents, initial_color); |
-} |
- |
-void AthenaAppDelegate::RunFileChooser( |
- content::WebContents* tab, |
- const content::FileChooserParams& params) { |
- FileSelectHelper::RunFileChooser(tab, params); |
-} |
- |
-void AthenaAppDelegate::RequestMediaAccessPermission( |
- content::WebContents* web_contents, |
- const content::MediaStreamRequest& request, |
- const content::MediaResponseCallback& callback, |
- const extensions::Extension* extension) { |
- MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest( |
- web_contents, request, callback, extension); |
-} |
- |
-bool AthenaAppDelegate::CheckMediaAccessPermission( |
- content::WebContents* web_contents, |
- const GURL& security_origin, |
- content::MediaStreamType type, |
- const extensions::Extension* extension) { |
- return MediaCaptureDevicesDispatcher::GetInstance() |
- ->CheckMediaAccessPermission( |
- web_contents, security_origin, type, extension); |
-} |
- |
-int AthenaAppDelegate::PreferredIconSize() { |
+int AthenaAppDelegateBase::PreferredIconSize() { |
// TODO(oshima): Find out what to use. |
return extension_misc::EXTENSION_ICON_SMALL; |
} |
-gfx::ImageSkia AthenaAppDelegate::GetAppDefaultIcon() { |
+gfx::ImageSkia AthenaAppDelegateBase::GetAppDefaultIcon() { |
return *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
IDR_APP_DEFAULT_ICON); |
} |
-void AthenaAppDelegate::SetWebContentsBlocked( |
- content::WebContents* web_contents, |
- bool blocked) { |
- // RenderViewHost may be NULL during shutdown. |
- content::RenderViewHost* host = web_contents->GetRenderViewHost(); |
- if (host) { |
- host->Send(new ChromeViewMsg_SetVisuallyDeemphasized(host->GetRoutingID(), |
- blocked)); |
- } |
-} |
- |
-bool AthenaAppDelegate::IsWebContentsVisible( |
+bool AthenaAppDelegateBase::IsWebContentsVisible( |
content::WebContents* web_contents) { |
- return platform_util::IsVisible(web_contents->GetNativeView()); |
+ return web_contents->GetNativeView()->IsVisible(); |
} |
-void AthenaAppDelegate::SetTerminatingCallback(const base::Closure& callback) { |
+void AthenaAppDelegateBase::SetTerminatingCallback( |
+ const base::Closure& callback) { |
if (!terminating_callback_.is_null()) |
AthenaEnv::Get()->RemoveTerminatingCallback(terminating_callback_); |
terminating_callback_ = callback; |