Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 "chrome/browser/android/banners/app_banner_manager.h" | |
| 6 | |
| 7 #include "base/android/jni_android.h" | |
| 8 #include "base/android/jni_string.h" | |
| 9 #include "base/command_line.h" | |
| 10 #include "chrome/browser/android/banners/app_banner_settings_helper.h" | |
| 11 #include "chrome/browser/profiles/profile.h" | |
| 12 #include "chrome/common/chrome_switches.h" | |
| 13 #include "content/public/browser/android/content_view_core.h" | |
| 14 #include "content/public/browser/navigation_details.h" | |
| 15 #include "content/public/browser/web_contents.h" | |
| 16 #include "content/public/common/frame_navigate_params.h" | |
| 17 #include "jni/AppBannerManager_jni.h" | |
| 18 #include "ui/gfx/android/java_bitmap.h" | |
| 19 | |
| 20 using base::android::ConvertJavaStringToUTF8; | |
| 21 using base::android::ConvertUTF8ToJavaString; | |
| 22 | |
| 23 AppBannerManager::AppBannerManager(JNIEnv* env, jobject obj) | |
| 24 : MetaTagObserver("google-play-id"), | |
|
Ted C
2014/02/11 17:48:45
should this be a static?
gone
2014/02/11 19:04:14
Done.
| |
| 25 weak_java_banner_view_manager_(env, obj) {} | |
| 26 | |
| 27 AppBannerManager::~AppBannerManager() { | |
| 28 weak_java_banner_view_manager_.reset(); | |
|
Ted C
2014/02/11 17:48:45
won't this happen in the destructor of the java we
gone
2014/02/11 19:04:14
Done.
| |
| 29 } | |
| 30 | |
| 31 void AppBannerManager::Destroy(JNIEnv* env, jobject obj) { delete this; } | |
|
Ted C
2014/02/11 17:48:45
This looks odd to me. I would probably put the de
gone
2014/02/11 19:04:14
Done.
| |
| 32 | |
| 33 void AppBannerManager::ReplaceWebContents(JNIEnv* env, | |
| 34 jobject obj, | |
| 35 jlong native_content_view_core) { | |
| 36 content::ContentViewCore* content_view_core = | |
| 37 reinterpret_cast<content::ContentViewCore*>(native_content_view_core); | |
| 38 if (web_contents() != content_view_core->GetWebContents()) | |
|
Ted C
2014/02/11 17:48:45
looks like web_contents_observer already does this
gone
2014/02/11 19:04:14
Done.
| |
| 39 Observe(content_view_core->GetWebContents()); | |
| 40 } | |
| 41 | |
| 42 void AppBannerManager::DidNavigateMainFrame( | |
| 43 const content::LoadCommittedDetails& details, | |
| 44 const content::FrameNavigateParams& params) { | |
| 45 // TODO(dfalcantara): Get rid of the current banner. | |
| 46 } | |
| 47 | |
| 48 void AppBannerManager::HandleMetaTagContent(const std::string& tag_content, | |
| 49 const GURL& expected_url) { | |
| 50 if (!web_contents() || !AppBannerSettingsHelper::IsAllowed( | |
| 51 web_contents(), expected_url, tag_content)) { | |
|
Ted C
2014/02/11 17:48:45
This also looks odd to me. Maybe:
!AppBannerSetti
gone
2014/02/11 19:04:14
Formatter sure is fond of doing weird things.
| |
| 52 return; | |
| 53 } | |
| 54 | |
| 55 request_url_ = GURL(expected_url); | |
|
Ted C
2014/02/11 17:48:45
Do you actually need to store these in native? Se
gone
2014/02/11 19:04:14
They're needed for the rest of the async pipeline,
| |
| 56 request_package_ = tag_content; | |
| 57 | |
| 58 // TODO(dfalcantara): Send the info to the Java side to begin building the | |
| 59 // app banner. | |
| 60 } | |
| 61 | |
| 62 jlong Init(JNIEnv* env, jobject obj) { | |
| 63 AppBannerManager* manager = new AppBannerManager(env, obj); | |
| 64 return reinterpret_cast<intptr_t>(manager); | |
| 65 } | |
| 66 | |
| 67 jboolean IsEnabled(JNIEnv* env, jclass clazz) { | |
| 68 return false; | |
| 69 | |
| 70 // TODO(dfalcantara): Enable this when more of the pipeline is checked in. | |
| 71 // return !CommandLine::ForCurrentProcess()->HasSwitch( | |
| 72 // switches::kDisableAppBanners); | |
| 73 } | |
| 74 | |
| 75 // Register native methods | |
| 76 bool RegisterAppBannerManager(JNIEnv* env) { return RegisterNativesImpl(env); } | |
|
Ted C
2014/02/11 17:48:45
same comment about the delete above. I don't see
gone
2014/02/11 19:04:14
Yay formatter!
| |
| OLD | NEW |