Skip to content

Commit

Permalink
Build Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
itskartike910 authored and devjangid15 committed Jan 30, 2025
1 parent e0d9b76 commit 4a5ef1c
Show file tree
Hide file tree
Showing 17 changed files with 117 additions and 248 deletions.
4 changes: 2 additions & 2 deletions src/build/config/android/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ if (is_android || is_chromeos) {

# Forced Android versionCode

android_override_version_code = "28"
android_override_version_code = "30"

# Forced Android versionName
android_override_version_name = "0.24"
android_override_version_name = "0.26"

# The path to the keystore to use for signing builds.
android_keystore_path = default_android_keystore_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import java.util.List;
import java.util.ArrayList;
import org.chromium.chrome.browser.ntp.NewTabPageLayout;
import android.content.Context;
import android.widget.Toast;
import org.chromium.base.ContextUtils;

import org.jni_zero.CalledByNative;
import org.jni_zero.NativeMethods;
Expand All @@ -31,15 +28,7 @@ public static ArrayList<ExtensionInfo> getExtensionsInfo() {
JSONArray array = new JSONArray(jsonString);
for (int i = 0; i < array.length(); i++) {
JSONObject obj = array.getJSONObject(i);

// Validate the url
// String popupUrl = obj.getString("popup_url");
// Log.w("Extensions", "popupUrl: " + popupUrl);
// if (!isUrlfromOfficialStore(popupUrl)) {
// Log.w("Extensions", "Invalid popup url: " + popupUrl);
// continue;
// }


// Decode base64 icon
String iconBase64 = obj.getString("icon_base64");
Bitmap icon = null;
Expand All @@ -48,33 +37,20 @@ public static ArrayList<ExtensionInfo> getExtensionsInfo() {
icon = BitmapFactory.decodeByteArray(iconBytes, 0, iconBytes.length);
}
result.add(new ExtensionInfo(
obj.getString("id"),
obj.getString("name"),
obj.getString("description"),
obj.getString("popup_url"),
obj.getString("widget_url"),
icon));
obj.getString("id"),
obj.getString("name"),
obj.getString("description"),
obj.getString("popup_url"),
obj.getString("widget_url"),
icon
));
}
} catch (JSONException e) {
Log.e("ExtensionInfo", "Error parsing JSON", e);
}
return result;
}

public static boolean isUrlfromOfficialStore(String url) {
return url.contains("github.com/wootzapp/ext-store");
}

public static void installExtension(String url) {
Log.w("Extensions", "url: " + url);
if (!isUrlfromOfficialStore(url)) {
Context context = ContextUtils.getApplicationContext();
Toast.makeText(context, "Install from official store", Toast.LENGTH_SHORT).show();
return;
}
ExtensionsJni.get().installExtension(url);
}

public static void uninstallExtension(String extensionId) {
Log.d("Extensions", "Uninstalling extension: " + extensionId);
ExtensionsJni.get().uninstallExtension(extensionId);
Expand All @@ -88,7 +64,6 @@ public static void uninstallExtension(String extensionId) {
@NativeMethods
interface Natives {
String getExtensionsInfo();
void installExtension(String url);
void uninstallExtension(String extensionId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,7 @@ protected void onDetachedFromWindow() {
cleanupWebContents();
}

public void cleanupWebContents() {
private void cleanupWebContents() {
Log.d(TAG, "cleanupWebContents called");
if (mCurrentWebContents != null) {
Log.d(TAG, "Destroying current WebContents");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2300,4 +2300,4 @@ public void destroyActivityForTesting() {
// a test is done. Just null it out to give an effect of |onDestroy| being invoked.
mActivity = null;
}
}
}
20 changes: 10 additions & 10 deletions src/chrome/browser/download/download_crx_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
#include <memory>

#include "chrome/browser/android/tab_android.h"
#include "chrome/browser/ui/android/tab_model/tab_model.h"
#include "chrome/browser/ui/android/tab_model/tab_model_list.h"
#include "chrome/browser/extensions/crx_installer.h"
#include "chrome/browser/extensions/extension_install_prompt.h"
#include "chrome/browser/extensions/extension_management.h"
#include "chrome/browser/extensions/webstore_installer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/android/tab_model/tab_model.h"
#include "chrome/browser/ui/android/tab_model/tab_model_list.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
Expand Down Expand Up @@ -63,8 +63,9 @@ std::unique_ptr<ExtensionInstallPrompt> CreateExtensionInstallPrompt(
// }
// web_contents = browser->tab_strip_model()->GetActiveWebContents();
for (const TabModel* model : TabModelList::models()) {
if (model->IsActiveModel())
if (model->IsActiveModel()) {
web_contents = model->GetActiveWebContents();
}
}
}
return std::make_unique<ExtensionInstallPrompt>(web_contents);
Expand Down Expand Up @@ -95,10 +96,9 @@ scoped_refptr<extensions::CrxInstaller> CreateCrxInstaller(

scoped_refptr<extensions::CrxInstaller> installer(
extensions::CrxInstaller::Create(
service,
CreateExtensionInstallPrompt(profile, download_item),
nullptr)); // woots exts patch
// WebstoreInstaller::GetAssociatedApproval(download_item)));
service, CreateExtensionInstallPrompt(profile, download_item),
nullptr)); // woots exts patch
// WebstoreInstaller::GetAssociatedApproval(download_item)));

installer->set_error_on_unsupported_requirements(true);
installer->set_delete_source(true);
Expand All @@ -114,9 +114,9 @@ scoped_refptr<extensions::CrxInstaller> CreateCrxInstaller(
// DownloadItem::TARGET_DISPOSITION_PROMPT)
// return false;

// if (download_item.GetMimeType() == extensions::Extension::kMimeType ||
// extensions::UserScript::IsURLUserScript(download_item.GetURL(),
// download_item.GetMimeType())) {
// if (download_item.GetMimeType() == extensions::Extension::kMimeType ||
// extensions::UserScript::IsURLUserScript(download_item.GetURL(),
// download_item.GetMimeType())) {
// return true;
// } else {
// return false;
Expand Down
52 changes: 23 additions & 29 deletions src/chrome/browser/extensions/extensions_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,41 +140,35 @@ void JNI_Extensions_InstallExtension(
Profile* profile = ProfileManager::GetActiveUserProfile();
if (!profile) {
LOG(ERROR) << "No Active Profile FOUND";
return;
return;
}

extensions::ExtensionService* extension_service =
extensions::ExtensionSystem::Get(profile)->extension_service();

if (!extension_service) {
LOG(ERROR) << "Extension Service Not Available";
return;
}

}



void JNI_Extensions_UninstallExtension(
JNIEnv * env,
const base::android::JavaParamRef<jstring>& j_extension_id) {
std::string extension_id =
base::android::ConvertJavaStringToUTF8(env, j_extension_id);


if (!extension_service) {
LOG(ERROR) << "Extension Service Not Available";
return;
}
}

Profile* profile = ProfileManager::GetActiveUserProfile();
if (!profile) {
return;
}
void JNI_Extensions_UninstallExtension(
JNIEnv* env,
const base::android::JavaParamRef<jstring>& j_extension_id) {
std::string extension_id =
base::android::ConvertJavaStringToUTF8(env, j_extension_id);

extensions::ExtensionService* extension_service =
extensions::ExtensionSystem::Get(profile)->extension_service();
if (!extension_service) {
return;
}
Profile* profile = ProfileManager::GetActiveUserProfile();
if (!profile) {
return;
}

extensions::ExtensionService* extension_service =
extensions::ExtensionSystem::Get(profile)->extension_service();
if (!extension_service) {
return;
}

extension_service->UninstallExtension(
extension_id, extensions::UNINSTALL_REASON_USER_INITIATED, nullptr);
}
extension_service->UninstallExtension(
extension_id, extensions::UNINSTALL_REASON_USER_INITIATED, nullptr);
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,18 @@ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (mTarget == null) {
return;
}

// Force the target view to be measured with a very large height
// This will push any bottom content (like search box) off screen
mTarget.measure(
MeasureSpec.makeMeasureSpec(
getMeasuredWidth() - getPaddingLeft() - getPaddingRight(),
MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(
0, // Height of 0 with UNSPECIFIED lets the view size to its content
MeasureSpec.UNSPECIFIED)); // UNSPECIFIED allows the view to determine its own size
Integer.MAX_VALUE,
MeasureSpec.AT_MOST));

// Update the measured dimensions to match the child's height plus padding
// Set the measured dimension to be very tall
setMeasuredDimension(getMeasuredWidth(),
Math.max(mTarget.getMeasuredHeight() + getPaddingTop() + getPaddingBottom(), getMeasuredHeight()));
}
Expand Down
Loading

0 comments on commit 4a5ef1c

Please sign in to comment.