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

Side by Side Diff: athena/extensions/athena_app_delegate_base.cc

Issue 863033002: Delete athena/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 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 "athena/extensions/athena_app_delegate_base.h"
6
7 #include "athena/activity/public/activity.h"
8 #include "athena/activity/public/activity_factory.h"
9 #include "athena/env/public/athena_env.h"
10 #include "content/public/browser/web_contents.h"
11 #include "content/public/browser/web_contents_delegate.h"
12 #include "extensions/common/constants.h"
13 #include "extensions/grit/extensions_browser_resources.h"
14 #include "ui/aura/window.h"
15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/geometry/rect.h"
17
18 namespace athena {
19 namespace {
20
21 content::WebContents* OpenURLInActivity(content::BrowserContext* context,
22 const content::OpenURLParams& params) {
23 // Force all links to open in a new activity.
24 Activity* activity = ActivityFactory::Get()->CreateWebActivity(
25 context, base::string16(), params.url);
26 Activity::Show(activity);
27 // TODO(oshima): Get the web cotnents from activity.
28 return nullptr;
29 }
30
31 } // namespace
32
33 // This is a extra step to open a new Activity when a link is simply clicked
34 // on an app activity (which usually replaces the content).
35 class AthenaAppDelegateBase::NewActivityContentsDelegate
36 : public content::WebContentsDelegate {
37 public:
38 NewActivityContentsDelegate() {}
39 ~NewActivityContentsDelegate() override {}
40
41 // content::WebContentsDelegate:
42 content::WebContents* OpenURLFromTab(
43 content::WebContents* source,
44 const content::OpenURLParams& params) override {
45 if (!source)
46 return nullptr;
47 return OpenURLInActivity(source->GetBrowserContext(), params);
48 }
49
50 private:
51 DISALLOW_COPY_AND_ASSIGN(NewActivityContentsDelegate);
52 };
53
54 AthenaAppDelegateBase::AthenaAppDelegateBase()
55 : new_window_contents_delegate_(new NewActivityContentsDelegate) {
56 }
57
58 AthenaAppDelegateBase::~AthenaAppDelegateBase() {
59 if (!terminating_callback_.is_null())
60 AthenaEnv::Get()->RemoveTerminatingCallback(terminating_callback_);
61 }
62
63 void AthenaAppDelegateBase::RenderViewCreated(
64 content::RenderViewHost* render_view_host) {
65 // No implementation necessary for athena.
66 }
67
68 void AthenaAppDelegateBase::ResizeWebContents(
69 content::WebContents* web_contents,
70 const gfx::Size& size) {
71 aura::Window* window = web_contents->GetNativeView();
72 window->SetBounds(gfx::Rect(window->bounds().origin(), size));
73 }
74
75 content::WebContents* AthenaAppDelegateBase::OpenURLFromTab(
76 content::BrowserContext* context,
77 content::WebContents* source,
78 const content::OpenURLParams& params) {
79 return OpenURLInActivity(context, params);
80 }
81
82 void AthenaAppDelegateBase::AddNewContents(content::BrowserContext* context,
83 content::WebContents* new_contents,
84 WindowOpenDisposition disposition,
85 const gfx::Rect& initial_pos,
86 bool user_gesture,
87 bool* was_blocked) {
88 new_contents->SetDelegate(new_window_contents_delegate_.get());
89 }
90
91 int AthenaAppDelegateBase::PreferredIconSize() {
92 // TODO(oshima): Find out what to use.
93 return extension_misc::EXTENSION_ICON_SMALL;
94 }
95
96 bool AthenaAppDelegateBase::IsWebContentsVisible(
97 content::WebContents* web_contents) {
98 return web_contents->GetNativeView()->IsVisible();
99 }
100
101 void AthenaAppDelegateBase::SetTerminatingCallback(
102 const base::Closure& callback) {
103 if (!terminating_callback_.is_null())
104 AthenaEnv::Get()->RemoveTerminatingCallback(terminating_callback_);
105 terminating_callback_ = callback;
106 if (!terminating_callback_.is_null())
107 AthenaEnv::Get()->AddTerminatingCallback(terminating_callback_);
108 }
109
110 } // namespace athena
OLDNEW
« no previous file with comments | « athena/extensions/athena_app_delegate_base.h ('k') | athena/extensions/athena_app_window_client_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698