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

Side by Side Diff: chrome/browser/android/offline_pages/offline_page_bridge.cc

Issue 1956633002: Menu hook plumbed through to RequestCoordinator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: A few more changes per JianLi and FGorski. Created 4 years, 7 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/offline_pages/offline_page_bridge.h" 5 #include "chrome/browser/android/offline_pages/offline_page_bridge.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
11 #include "base/android/jni_string.h" 11 #include "base/android/jni_string.h"
12 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" 12 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h"
13 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 13 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
14 #include "chrome/browser/android/offline_pages/offline_page_utils.h" 14 #include "chrome/browser/android/offline_pages/offline_page_utils.h"
15 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/profiles/profile_android.h" 17 #include "chrome/browser/profiles/profile_android.h"
18 #include "components/offline_pages/background/request_coordinator.h"
19 #include "components/offline_pages/background/save_page_request.h"
17 #include "components/offline_pages/offline_page_feature.h" 20 #include "components/offline_pages/offline_page_feature.h"
18 #include "components/offline_pages/offline_page_item.h" 21 #include "components/offline_pages/offline_page_item.h"
19 #include "components/offline_pages/offline_page_model.h" 22 #include "components/offline_pages/offline_page_model.h"
20 #include "components/offline_pages/proto/offline_pages.pb.h" 23 #include "components/offline_pages/proto/offline_pages.pb.h"
21 #include "content/public/browser/browser_context.h" 24 #include "content/public/browser/browser_context.h"
22 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
23 #include "jni/OfflinePageBridge_jni.h" 26 #include "jni/OfflinePageBridge_jni.h"
24 #include "net/base/filename_util.h" 27 #include "net/base/filename_util.h"
25 28
26 using base::android::ConvertJavaStringToUTF8; 29 using base::android::ConvertJavaStringToUTF8;
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 312
310 offline_pages::ClientId client_id; 313 offline_pages::ClientId client_id;
311 client_id.name_space = ConvertJavaStringToUTF8(env, j_client_id_namespace); 314 client_id.name_space = ConvertJavaStringToUTF8(env, j_client_id_namespace);
312 client_id.id = ConvertJavaStringToUTF8(env, j_client_id); 315 client_id.id = ConvertJavaStringToUTF8(env, j_client_id);
313 316
314 offline_page_model_->SavePage( 317 offline_page_model_->SavePage(
315 url, client_id, std::move(archiver), 318 url, client_id, std::move(archiver),
316 base::Bind(&SavePageCallback, j_callback_ref, url)); 319 base::Bind(&SavePageCallback, j_callback_ref, url));
317 } 320 }
318 321
322 void OfflinePageBridge::SavePageLater(
323 JNIEnv* env,
324 const JavaParamRef<jobject>& obj,
325 const JavaParamRef<jstring>& j_url,
326 const JavaParamRef<jstring>& j_client_id_namespace,
327 const JavaParamRef<jstring>& j_client_id) {
328 offline_pages::ClientId client_id;
329 client_id.name_space = ConvertJavaStringToUTF8(env, j_client_id_namespace);
Bernhard Bauer 2016/05/09 10:00:36 Nit: I would rename the field to just |namespace|
Pete Williamson 2016/05/09 18:45:23 Done.
330 client_id.id = ConvertJavaStringToUTF8(env, j_client_id);
331
332 RequestCoordinator* coordinator =
333 offline_pages::RequestCoordinatorFactory::GetInstance()->
334 GetForBrowserContext(browser_context_);
335
336 coordinator->SavePageLater(
337 GURL(ConvertJavaStringToUTF8(env, j_url)), client_id);
338 }
339
319 void OfflinePageBridge::DeletePages( 340 void OfflinePageBridge::DeletePages(
320 JNIEnv* env, 341 JNIEnv* env,
321 const JavaParamRef<jobject>& obj, 342 const JavaParamRef<jobject>& obj,
322 const JavaParamRef<jobject>& j_callback_obj, 343 const JavaParamRef<jobject>& j_callback_obj,
323 const JavaParamRef<jlongArray>& offline_ids_array) { 344 const JavaParamRef<jlongArray>& offline_ids_array) {
324 DCHECK(j_callback_obj); 345 DCHECK(j_callback_obj);
325 346
326 ScopedJavaGlobalRef<jobject> j_callback_ref; 347 ScopedJavaGlobalRef<jobject> j_callback_ref;
327 j_callback_ref.Reset(env, j_callback_obj); 348 j_callback_ref.Reset(env, j_callback_obj);
328 349
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 ConvertUTF8ToJavaString(env, client_id.name_space).obj(), 399 ConvertUTF8ToJavaString(env, client_id.name_space).obj(),
379 ConvertUTF8ToJavaString(env, client_id.id).obj()); 400 ConvertUTF8ToJavaString(env, client_id.id).obj());
380 } 401 }
381 402
382 bool RegisterOfflinePageBridge(JNIEnv* env) { 403 bool RegisterOfflinePageBridge(JNIEnv* env) {
383 return RegisterNativesImpl(env); 404 return RegisterNativesImpl(env);
384 } 405 }
385 406
386 } // namespace android 407 } // namespace android
387 } // namespace offline_pages 408 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698